forked from OSSInnovation/mindspore
!2646 Fix grad value is wrong when register hook in pynative
Merge pull request !2646 from JoyLvliang/r0.5
This commit is contained in:
commit
84cdb9f4ed
|
@ -261,8 +261,10 @@ py::object RunOpInVM(const OpExecInfoPtr &op_exec_info, PynativeStatusCode *stat
|
|||
if (py::hasattr(input, "__parameter__")) {
|
||||
result[i] = py::getattr(input, "data");
|
||||
} else {
|
||||
auto tensor = py::cast<tensor::TensorPtr>(op_inputs[i]);
|
||||
auto tensor = py::cast<tensor::TensorPtr>(input);
|
||||
auto new_tensor = std::make_shared<tensor::Tensor>(tensor->data());
|
||||
new_tensor->set_device_address(tensor->device_address());
|
||||
new_tensor->set_dirty(tensor->is_dirty());
|
||||
result[i] = new_tensor;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue