From 70ddf8009c9eb53425339dbc6eb26f7ad549c423 Mon Sep 17 00:00:00 2001 From: lianghuikang <505519763@qq.com> Date: Wed, 7 Jul 2021 10:48:34 +0800 Subject: [PATCH 1/2] fix static check --- tf_adapter/util/ge_plugin.cc | 5 ++++- tf_adapter_2.x/npu_device/core/npu_parser.h | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tf_adapter/util/ge_plugin.cc b/tf_adapter/util/ge_plugin.cc index a74f3be57..dbad404f2 100644 --- a/tf_adapter/util/ge_plugin.cc +++ b/tf_adapter/util/ge_plugin.cc @@ -268,7 +268,10 @@ uint64_t GePlugin::GetFusionTensorSize() { return default_fusion_tensor_size; } std::string temp_fusion_tensor_size(env_fusion_tensor_size); - std::istringstream string_stream(temp_fusion_tensor_size); + std::istringstream string_stream; + if (!temp_fusion_tensor_size.empty()) { + string_stream.str(temp_fusion_tensor_size); + } uint64_t fusion_tensor_size = 0; if (!(string_stream >> fusion_tensor_size)) { fusion_tensor_size = default_fusion_tensor_size; diff --git a/tf_adapter_2.x/npu_device/core/npu_parser.h b/tf_adapter_2.x/npu_device/core/npu_parser.h index 8cc4ac61e..484802f47 100644 --- a/tf_adapter_2.x/npu_device/core/npu_parser.h +++ b/tf_adapter_2.x/npu_device/core/npu_parser.h @@ -117,13 +117,13 @@ __attribute__((unused)) static void AssembleOpDef(tensorflow::Node *n) { n->AddAttr("op_def", serialized_op_def); } -static void AssembleOpDef(const tensorflow::OpRegistrationData *op_data, tensorflow::NodeDef *ndef) { +__attribute__((unused)) static void AssembleOpDef(const tensorflow::OpRegistrationData *op_data, tensorflow::NodeDef *ndef) { std::string serialized_op_def; op_data->op_def.SerializeToString(&serialized_op_def); tensorflow::AddNodeAttr("op_def", serialized_op_def, ndef); } -static void AssembleOpDef(tensorflow::NodeDef *ndef) { +__attribute__((unused)) static void AssembleOpDef(tensorflow::NodeDef *ndef) { const tensorflow::OpRegistrationData *op_reg_data; tensorflow::OpRegistry::Global()->LookUp(ndef->op(), &op_reg_data); std::string serialized_op_def; -- Gitee From 5d8376ec0590fda71143cb7023dde40af8d435e9 Mon Sep 17 00:00:00 2001 From: lianghuikang <505519763@qq.com> Date: Thu, 15 Jul 2021 15:29:00 +0800 Subject: [PATCH 2/2] fix static check --- tf_adapter/util/ge_plugin.cc | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/tf_adapter/util/ge_plugin.cc b/tf_adapter/util/ge_plugin.cc index dbad404f2..98f49a9f2 100644 --- a/tf_adapter/util/ge_plugin.cc +++ b/tf_adapter/util/ge_plugin.cc @@ -260,23 +260,13 @@ std::map GePlugin::GetInitOptions() { } uint64_t GePlugin::GetFusionTensorSize() { - const char *env_fusion_tensor_size = getenv("FUSION_TENSOR_SIZE"); - - // default (50KBytes) - const uint64_t default_fusion_tensor_size = 524288000; - if (env_fusion_tensor_size == nullptr || strlen(env_fusion_tensor_size) >= ADAPTER_ENV_MAX_LENTH) { - return default_fusion_tensor_size; - } - std::string temp_fusion_tensor_size(env_fusion_tensor_size); - std::istringstream string_stream; - if (!temp_fusion_tensor_size.empty()) { - string_stream.str(temp_fusion_tensor_size); - } - uint64_t fusion_tensor_size = 0; - if (!(string_stream >> fusion_tensor_size)) { - fusion_tensor_size = default_fusion_tensor_size; + const int64 fusion_tensor_size_default = 524288000; + int64 fusion_tensor_size = fusion_tensor_size_default; + Status s = ReadInt64FromEnvVar("FUSION_TENSOR_SIZE", fusion_tensor_size_default, &fusion_tensor_size); + if (s.ok() && fusion_tensor_size >= 0) { + return fusion_tensor_size; } - return fusion_tensor_size; + return static_cast(fusion_tensor_size_default); } void GePlugin::Finalize() { -- Gitee