Fix old tensor OutputTensorCopyFrom usage in ImageInput operator (#15094)
authorJunjie Bai <bai@in.tum.de>
Thu, 13 Dec 2018 19:46:03 +0000 (11:46 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 13 Dec 2018 19:48:19 +0000 (11:48 -0800)
Summary:
cc jerryzh168
Pull Request resolved: https://github.com/pytorch/pytorch/pull/15094

Differential Revision: D13451898

Pulled By: bddppq

fbshipit-source-id: 27906be62fb88aaa13c257441a2e35a285b445ee

caffe2/image/image_input_op.h

index 321d017..f5db8b3 100644 (file)
@@ -1243,12 +1243,14 @@ bool ImageInputOp<Context>::CopyPrefetched() {
   // Note(jiayq): The if statement below should be optimized away by the
   // compiler since std::is_same is a constexpr.
   if (std::is_same<Context, CPUContext>::value) {
-    OperatorBase::OutputTensorCopyFrom(0, options, prefetched_image_, &context_);
-    OperatorBase::OutputTensorCopyFrom(1, options, prefetched_label_, &context_);
+    OperatorBase::OutputTensorCopyFrom(
+        0, options, prefetched_image_, /* async */ true);
+    OperatorBase::OutputTensorCopyFrom(
+        1, options, prefetched_label_, /* async */ true);
 
     for (int i = 2; i < OutputSize(); ++i) {
       OperatorBase::OutputTensorCopyFrom(
-          i, options, prefetched_additional_outputs_[i - 2], &context_);
+          i, options, prefetched_additional_outputs_[i - 2], /* async */ true);
     }
   } else {
     // TODO: support color jitter and color lighting in gpu_transform
@@ -1276,14 +1278,17 @@ bool ImageInputOp<Context>::CopyPrefetched() {
 
     } else {
       OperatorBase::OutputTensorCopyFrom(
-          0, type, prefetched_image_on_device_, &context_);
+          0, type, prefetched_image_on_device_, /* async */ true);
     }
     OperatorBase::OutputTensorCopyFrom(
-        1, type, prefetched_label_on_device_, &context_);
+        1, type, prefetched_label_on_device_, /* async */ true);
 
     for (int i = 2; i < OutputSize(); ++i) {
       OperatorBase::OutputTensorCopyFrom(
-          i, type, prefetched_additional_outputs_on_device_[i - 2], &context_);
+          i,
+          type,
+          prefetched_additional_outputs_on_device_[i - 2],
+          /* async */ true);
     }
   }
   return true;