Explicitly ban uninitialized tensors when invoking Predictor classes (#14377)
authorJerry Zhang <jerryzh@fb.com>
Fri, 30 Nov 2018 21:19:31 +0000 (13:19 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 30 Nov 2018 21:26:00 +0000 (13:26 -0800)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/14377

att

Reviewed By: dzhulgakov

Differential Revision: D13197348

fbshipit-source-id: 85a451bde3a57a8acdd3af548606c05e223896a6

aten/src/ATen/core/TensorImpl.h

index a4ebc36..7e35cb0 100644 (file)
@@ -1189,6 +1189,13 @@ struct CAFFE2_API TensorImpl : public c10::intrusive_ptr_target {
     // It is possible that the source tensor hasn't called mutable_data() yet,
     // in which case ShareData() doesn't make much sense since we don't really
     // know what to share yet.
+    // TODO: Add the assert after all uninitialized states are eliminated
+    // AT_ASSERTM(src.dtype_initialized(),
+    //            "Source tensor don't have a data type (did you call mutable_data<T> on the tensor?)");
+    if (!src.dtype_initialized()) {
+      C10_LOG_EVERY_MS(WARNING, 1000) <<
+                   "Source tensor don't have a data type (did you call mutable_data<T> on the tensor?)";
+    }
     AT_ASSERTM(
         src.storage_initialized(),
         "Source tensor has no content and has size > 0");