def _get_end_op_index(self): if _in_amp_guard(): infer_program = self._infer_amp_program elif _in_pure_fp16_guard(): infer_program = self._infer_pure_fp16_program else: infer_program = self._infer_program return infer_program.desc.block(0).op_size()
def _cast_fp16_if_pure_fp16(self, in_vars): if _in_pure_fp16_guard(): for i, var in enumerate(in_vars): name = var.name if (self.program.global_block().has_var(name) and self.program.global_block().var(name).dtype == paddle.float16): in_vars[i] = var.astype('float16') in_vars[i].name = name
def program_id(self): if self.training: if _in_amp_guard(): return self._train_amp_program_id elif _in_pure_fp16_guard(): return self._train_pure_fp16_program_id else: return self._train_program_id else: return self._infer_program_id