fix-grad-value-is-wrong-in-pynative-hook

This commit is contained in:
lvliang 2020-06-28 15:23:41 +08:00
parent 16a75779be
commit 24c0a8256f
1 changed files with 3 additions and 1 deletions

View File

@ -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;
}
}