diff --git a/tf_adapter/kernels/geop_npu.cc b/tf_adapter/kernels/geop_npu.cc index 4fb744f4ac516b463392f0c3df0e336e4ebc1fdf..6472ffecb0bbd5d233bcbb3aa91040483f76c718 100644 --- a/tf_adapter/kernels/geop_npu.cc +++ b/tf_adapter/kernels/geop_npu.cc @@ -76,7 +76,8 @@ #include "graph/model.h" #include "tf_adapter_2.x/npu_device/core/npu_micros.h" #include "tensorflow/core/graph/algorithm.h" -#include "tensorflow/core/framework/graph_to_functiondef.h" +#include "tensorflow/core/framework/graph_to_functiondef.h"a +#include "acl/acl_rt.h" namespace tensorflow { #ifdef TF_VERSION_TF2 @@ -89,6 +90,7 @@ namespace { const std::string ATTR_NAME_CONST_INPUT_NAME = "_const_input"; const std::string kMdatTuning = "mdat"; const std::string kAutoRecompute = "auto"; +const char* kFloatOverflowMode[] = {"SAT", "INF_NAN", "UNDEF"}; using geDataUniquePtr = std::unique_ptr>; class NpuHostFixedAllocator : public tensorflow::Allocator, public tensorflow::core::RefCounted { @@ -989,6 +991,17 @@ void GeOp::ComputeAsync(OpKernelContext *ctx, DoneCallback done) { << error_message; OP_REQUIRES_ASYNC(ctx, run_graph_status == ge::SUCCESS, errors::Unavailable(ss.str()), done); } + + // set floatOverflowMode to FE + aclrtFloatOverflowMode floatOverflowMode = ACL_RT_OVERFLOW_MODE_UNDEF; + aclError ret = aclrtGetDeviceSatMode(&floatOverflowMode); + if (ret != ACL_SUCCESS) { + ADP_LOG(ERROR) << "[GePlugin] get device satMode failed, ret: " << ToString(ret); + LOG(ERROR) << "[GePlugin] get device satMode failed, ret: " << ToString(ret); + return; + } + ADP_LOG(INFO) << "[GePlugin] get device satMode success."; + graph_options_["ge.satuateMode"] = kFloatOverflowMode[static_cast(floatOverflowMode)]; endTime = InferShapeUtil::GetCurrentTimestap(); ADP_LOG(INFO) << "[GEOP] End GeOp::ComputeAsync, kernel_name:" << geop_name