Browse Source

!13565 [Pynative]Fix Pynative AMP Backprop Bugs

From: @chenyijie6
Reviewed-by: @wilfchen,@chujinjin
Signed-off-by: @chujinjin
pull/13565/MERGE
mindspore-ci-bot Gitee 5 years ago
parent
commit
542142af8a
1 changed files with 10 additions and 0 deletions
  1. +10
    -0
      mindspore/ccsrc/pipeline/pynative/pynative_execute.cc

+ 10
- 0
mindspore/ccsrc/pipeline/pynative/pynative_execute.cc View File

@@ -897,6 +897,16 @@ py::object ForwardExecutor::DoParamMixPrecisionCast(bool *is_cast, const py::obj
// Update input for cast struct
auto cast_struct = cast_struct_pair->second;
cast_struct->op_inputs[0] = obj;
auto grad = this->grad();
MS_EXCEPTION_IF_NULL(grad);
if (grad->grad_flag()) {
// Get forward op index
if (!grad->cell_op_info_stack().empty()) {
std::string &cell_op_info = grad->cell_op_info_stack().top();
cell_op_info += cast_struct->op_index;
}
grad->op_index_map()[cast_struct->op_name]++;
}
py::object ret = py::none();
RunOpInner(&ret, cast_struct);
return ret;


Loading…
Cancel
Save