mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
[caffe2] Copy tensor in single tensor input case in UnPackRecordsOp (#37454)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/37454 Fix a bug introduced in D21224497. In the case of having a single unpacked tensor as input, we still need to copy the underline memory because only inputs are guaranteed to be read-only. The output could be overwritten later during inference. If we share the tensor, we could potentially overwrite the input, which in principle should be read only. Test Plan: ``` buck test caffe2/caffe2/python/operator_test:dataset_ops_test ``` AdIndexer canary: https://our.intern.facebook.com/intern/ads/canary/426290361213982683 Reviewed By: yinghai Differential Revision: D21274309 fbshipit-source-id: 71931d4b1afbdc700ba070ea618d1679f1bbe5a7
This commit is contained in:
parent
d1a39815f9
commit
5b6f6da18c
1 changed files with 1 additions and 1 deletions
|
|
@ -399,7 +399,7 @@ class UnPackRecordsOp : public Operator<CPUContext> {
|
|||
// input contains a single tensor
|
||||
CAFFE_ENFORCE_EQ(InputSize(), 1);
|
||||
CAFFE_ENFORCE_EQ(OutputSize(), 1);
|
||||
*Output(0) = Input(0);
|
||||
Output(0)->CopyFrom(Input(0));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue