Make BlackBoxPredictor handle networks throwing exceptions (#19080)
authorAlexander Sidorov <salex@fb.com>
Tue, 9 Apr 2019 23:32:52 +0000 (16:32 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 9 Apr 2019 23:42:12 +0000 (16:42 -0700)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/19080

OSS: add a tiny unit test utility function to create tensors given shape and data outside of any workspace. I use it in an internal test

Reviewed By: dzhulgakov

Differential Revision: D14814194

fbshipit-source-id: 6d53b235d99a97da812215f5c7f11fecad363c8c

caffe2/core/test_utils.h

index 7e286e1..bb31c2c 100644 (file)
@@ -98,6 +98,15 @@ caffe2::Tensor* createTensorAndFill(
   return tensor;
 }
 
+template <typename T>
+caffe2::Tensor createTensorAndFill(
+    const std::vector<int64_t>& shape,
+    const std::vector<T>& data) {
+  Tensor tensor(caffe2::CPU);
+  fillTensor<T>(shape, data, &tensor);
+  return tensor;
+}
+
 // Fill a constant to a tensor.
 template <typename T>
 void constantFillTensor(