call raw_mutable_data when data type didn't match in BlobGetMutableTensor (#14513)
authorJerry Zhang <jerryzh@fb.com>
Thu, 29 Nov 2018 23:16:52 +0000 (15:16 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 29 Nov 2018 23:18:58 +0000 (15:18 -0800)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/14513

att

Reviewed By: dzhulgakov

Differential Revision: D13245875

fbshipit-source-id: 3398a1f41a6195e120ed574dee887070e86dfe1f

caffe2/core/blob.h

index 9f493e5..0227c67 100644 (file)
@@ -45,8 +45,7 @@ BlobGetMutableTensor(Blob* blob, at::IntList dims, at::TensorOptions options) {
         if (tensor->dtype() == options.dtype()) {
           tensor->raw_mutable_data();
         } else {
-          // create a new Tensor when the data_type doesn't match
-          return BlobSetTensor(blob, caffe2::empty(dims, options));
+          tensor->raw_mutable_data(options.dtype());
         }
         return tensor;
       }