diff --git a/tf_adapter_2.x/npu_device/core/npu_managed_buffer.cpp b/tf_adapter_2.x/npu_device/core/npu_managed_buffer.cpp index 82decffc57b5f8af892dfe11c6248046d8337944..feaa6d7fce708a14a23dea91d59930c4943cf5de 100644 --- a/tf_adapter_2.x/npu_device/core/npu_managed_buffer.cpp +++ b/tf_adapter_2.x/npu_device/core/npu_managed_buffer.cpp @@ -239,9 +239,9 @@ tensorflow::Status NpuManagedBuffer::Create(ge::Format format, const std::vector break; } NPU_REQUIRES(dim_size >= 0, tensorflow::errors::InvalidArgument("Dim size invalid for shape ", VecToString(shape))); - NPU_REQUIRES(total_bytes <= total_bytes * dim_size, + NPU_REQUIRES(total_bytes <= total_bytes * static_cast(dim_size), tensorflow::errors::InvalidArgument("Total bytes overflow for shape ", VecToString(shape))); - total_bytes *= dim_size; + total_bytes *= static_cast(dim_size); } void *data = nullptr; NPU_REQUIRES_OK(NpuMemory::Malloc(total_bytes, &data)); diff --git a/tf_adapter_2.x/npu_device/core/npu_types.h b/tf_adapter_2.x/npu_device/core/npu_types.h index 26137888f255a103fa5da910c229d3ae32245367..7fed0f3d376311565f058b1e8077763d39eb3dc0 100644 --- a/tf_adapter_2.x/npu_device/core/npu_types.h +++ b/tf_adapter_2.x/npu_device/core/npu_types.h @@ -36,7 +36,7 @@ const static uint64_t kEmptyGeGraphId = -2; class ResourceGenerator { public: - ResourceGenerator(std::shared_ptr def, int index) : def_(def), index_(index) {} + ResourceGenerator(const std::shared_ptr def, int index) : def_(def), index_(index) {} std::shared_ptr NodeDef() const { return def_; } int Index() const { return index_; } diff --git a/tf_adapter_2.x/npu_device/core/npu_utils.cpp b/tf_adapter_2.x/npu_device/core/npu_utils.cpp index f7953dd2e6d5b0e58eb33db92edf5b7c553e0013..c6f120a2f2c5ac9ee5e9138756ce609e9fa701f0 100644 --- a/tf_adapter_2.x/npu_device/core/npu_utils.cpp +++ b/tf_adapter_2.x/npu_device/core/npu_utils.cpp @@ -326,7 +326,7 @@ tensorflow::Status GetSubgraphUnsupportedOps(const NpuDevice *device, const tens return tensorflow::Status::OK(); } -tensorflow::Status GetGraphUnsupportedOps(NpuDevice *device, tensorflow::Graph *graph, +tensorflow::Status GetGraphUnsupportedOps(NpuDevice *device, const tensorflow::Graph *graph, const tensorflow::FunctionLibraryDefinition *lib_def, std::set &unsupported_ops) { for (auto node : graph->op_nodes()) { @@ -458,7 +458,7 @@ uint64_t NextUUID() { * @brief: fix graph arg return value index * @param graph: graph */ -void FixGraphArgRetvalIndex(tensorflow::Graph *graph) { +void FixGraphArgRetvalIndex(const tensorflow::Graph *graph) { std::map indexed_args; std::map indexed_retvals; for (auto node : graph->nodes()) { @@ -550,7 +550,7 @@ size_t CreateChannelCapacity(const npu::TensorPartialShapes &shapes, const npu:: } else { result = shapes[i].num_elements() * tensorflow::DataTypeSize(data_type); } - if (result > kSizeTMaxsize - total_sizes) { + if (result > kSizeTMaxsize - static_cast(total_sizes)) { return kInvalidCpacity; } total_sizes += static_cast(result); diff --git a/tf_adapter_2.x/npu_device/core/npu_utils.h b/tf_adapter_2.x/npu_device/core/npu_utils.h index e7ef6f21c111e4eb62df41fb929cb22449f22068..28b8eb1d53f7f034460422c54ddea69232708584 100644 --- a/tf_adapter_2.x/npu_device/core/npu_utils.h +++ b/tf_adapter_2.x/npu_device/core/npu_utils.h @@ -108,7 +108,7 @@ struct ResourceCompare { void PruneGraphByFunctionSignature(const tensorflow::FunctionDef &fdef, tensorflow::Graph *g, bool keep_signature = false); -void FixGraphArgRetvalIndex(tensorflow::Graph *graph); +void FixGraphArgRetvalIndex(const tensorflow::Graph *graph); bool IsSubstituteNode(const tensorflow::Node *node); @@ -124,7 +124,7 @@ std::set GetNodeSubgraph(const tensorflow::Node *node); tensorflow::Status GetSubgraphUnsupportedOps(const NpuDevice *device, const tensorflow::Node *node, const tensorflow::FunctionLibraryDefinition *lib_def, std::set &unsupported_ops); -tensorflow::Status GetGraphUnsupportedOps(NpuDevice *device, tensorflow::Graph *graph, +tensorflow::Status GetGraphUnsupportedOps(NpuDevice *device, const tensorflow::Graph *graph, const tensorflow::FunctionLibraryDefinition *lib_def, std::set &unsupported_ops); diff --git a/tf_adapter_2.x/npu_device/core/op_executors/npu_resource_op.cpp b/tf_adapter_2.x/npu_device/core/op_executors/npu_resource_op.cpp index 3656edf767fb10438641916bb618fbd86762a432..966c96de8feac51604fee0913448c05e96e8f44b 100644 --- a/tf_adapter_2.x/npu_device/core/op_executors/npu_resource_op.cpp +++ b/tf_adapter_2.x/npu_device/core/op_executors/npu_resource_op.cpp @@ -115,7 +115,7 @@ void NpuResourceOp::RunImpl(TFE_Context *context, NpuDevice *device, int num_inp for (int i = 0; i < num_inputs; i++) { if (types[static_cast(i)] == tensorflow::DT_RESOURCE) { std::shared_ptr generator = nullptr; - const auto &handle = npu_resources[resource_index++]; + const auto &handle = npu_resources[static_cast(resource_index++)]; device->GetResourceGeneratorDef(handle, &generator); NPU_CTX_REQUIRES(status, generator != nullptr, tensorflow::errors::Internal("Unknown npu resource ", handle.DebugString())); @@ -131,7 +131,7 @@ void NpuResourceOp::RunImpl(TFE_Context *context, NpuDevice *device, int num_inp } else { tensorflow::Node *node = nullptr; NPU_CTX_REQUIRES_OK(status, tensorflow::NodeBuilder("arg_" + std::to_string(i), "_Arg") - .Attr("T", types[i]) + .Attr("T", types[static_cast(i)]) .Attr("index", arg_index++) .Attr("_output_shapes", {shapes[static_cast(i)]}) .Finalize(graph.get(), &node)); @@ -146,7 +146,7 @@ void NpuResourceOp::RunImpl(TFE_Context *context, NpuDevice *device, int num_inp tensorflow::Node *node = nullptr; NPU_CTX_REQUIRES_OK(status, tensorflow::NodeBuilder("ret_" + std::to_string(i), "_Retval") .Input(target_node, i) - .Attr("T", output_types[i]) + .Attr("T", output_types[static_cast(i)]) .Attr("index", i) .Finalize(graph.get(), &node)); } @@ -159,7 +159,7 @@ void NpuResourceOp::RunImpl(TFE_Context *context, NpuDevice *device, int num_inp std::string suffix = npu_resources[0].name(); for (int i = 1; i < static_cast(npu_resources.size()); i++) { suffix += "."; - suffix += npu_resources[i].name(); + suffix += npu_resources[static_cast(i)].name(); } graph_dumper.Dump(suffix, graph->ToGraphDefDebug()); }