condition blob in while_op test changes data type (#14279)
authorJerry Zhang <jerryzh@fb.com>
Tue, 27 Nov 2018 22:10:41 +0000 (14:10 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Tue, 27 Nov 2018 22:16:39 +0000 (14:16 -0800)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/14279

att

Reviewed By: smessmer

Differential Revision: D13144472

fbshipit-source-id: af4d920a3148c648d1a428a5bcd56da19ea8c38c

caffe2/core/blob.h

index 3873572..7726b6d 100644 (file)
@@ -44,7 +44,10 @@ BlobGetMutableTensor(Blob* blob, at::IntList dims, at::TensorOptions options) {
           tensor->raw_mutable_data();
         } else {
           // create a new Tensor when the data_type doesn't match
-          return BlobSetTensor(blob, caffe2::empty(dims, options));
+          C10_LOG_EVERY_MS(WARNING, 1000)
+              << "data type mismatch in BlobGetMutableTensor:"
+              << tensor->dtype() << " and " << options.dtype();
+          tensor->raw_mutable_data(options.dtype());
         }
         return tensor;
       }