diff --git a/tf_adapter/kernels/geop_npu.cc b/tf_adapter/kernels/geop_npu.cc index eae81ed9a50d00274fbb0ad0c6e1ba49ecc4cd60..df02d2d73925b544da9deecdb245b0e6f1d9c185 100644 --- a/tf_adapter/kernels/geop_npu.cc +++ b/tf_adapter/kernels/geop_npu.cc @@ -193,7 +193,7 @@ class NpuHostGetNextAllocator : public tensorflow::Allocator, public tensorflow: }; inline string ToString(ge::Status status) { - return ::ge::StatusFactory::Instance()->GetErrDesc(status); + return "0"; } Status BuildStringOutput(geDataUniquePtr data_ptr, size_t output_size, Tensor &cpu_tensor) { @@ -2196,12 +2196,14 @@ void GeOp::AnalyzeInputDesc(void *tensor_ptr, ge::Tensor &input, ge::DataType ty << ", input data addr: " << reinterpret_cast(data); } -Status GeOp::AnalyzeStringInput(ge::Tensor &input, uint64_t count, const std::string *string_vector) const { +Status GeOp::AnalyzeStringInput(ge::Tensor &input, const std::vector &string_vector) const { + const size_t count = string_vector.size(); + ADP_LOG(INFO) << "[GEOP] count: " << count; uint64_t total_size = 0U; for (uint64_t i = 0U; i < count; i++) { total_size += (string_vector[i].size() + sizeof(ge::StringHead) + 1U); } - + ADP_LOG(INFO) << "total size: " << total_size; std::unique_ptr addr(new (std::nothrow) char[total_size]()); REQUIRES_NOT_NULL(addr); ge::StringHead *string_head = ge::PtrToPtr(addr.get()); @@ -2210,6 +2212,7 @@ Status GeOp::AnalyzeStringInput(ge::Tensor &input, uint64_t count, const std::st for (uint64_t i = 0U; i < count; ++i) { string_head[i].addr = offset; const string &str = string_vector[i]; + ADP_LOG(INFO) << "str[" << i << "] = " << str; string_head[i].len = static_cast(str.size()); size_t str_size = str.size(); const char *string_addr = str.c_str(); @@ -2222,6 +2225,8 @@ Status GeOp::AnalyzeStringInput(ge::Tensor &input, uint64_t count, const std::st string_addr += SECUREC_MEM_MAX_LEN; } auto remain_size = ((total_size - offset) > SECUREC_MEM_MAX_LEN) ? SECUREC_MEM_MAX_LEN : (total_size - offset); + ADP_LOG(INFO) << "[GEOP] dst addr: " << data_addr << ", dst size: " << + remain_size << ", src addr: " << string_addr << ", src size: " << str_size; const auto ret = memcpy_s(data_addr, remain_size, string_addr, str_size + 1U); NPU_REQUIRES(ret == EOK, errors::Internal("call memcpy_s failed, ret:", ret)); data_addr += (str_size + 1U); @@ -2387,10 +2392,12 @@ Status GeOp::BuildInputTensorInfo(OpKernelContext *const ctx, std::vector &partition_graph, std::map &const_value_map); // Analyze sting input data - Status AnalyzeStringInput(ge::Tensor &input, uint64_t count, const std::string *string_vector) const; + Status AnalyzeStringInput(ge::Tensor &input, const std::vector &string_vector) const; // prepare input tensor Status BuildInputTensorInfo(OpKernelContext *const ctx, diff --git a/tf_adapter/optimizers/om_partition_subgraphs_pass.cc b/tf_adapter/optimizers/om_partition_subgraphs_pass.cc index ad7fc1a1cbe4d45f19e5856a1a2274218eab932f..a81a7a9c2c75f702ce5ae410c7665a57d92f7a56 100644 --- a/tf_adapter/optimizers/om_partition_subgraphs_pass.cc +++ b/tf_adapter/optimizers/om_partition_subgraphs_pass.cc @@ -663,11 +663,12 @@ Status FindNpuSupportCandidates(const Graph &graph, OrderedNodeSet *candidates, << node->name() << " REF input."; continue; } - if ((dtype_dst == DT_STRING) || (dtype_dst == DT_RESOURCE) || (dtype_dst == DT_VARIANT)) { + if ((dtype_dst == DT_RESOURCE)) { const AttrValue *attr_value = edge->dst()->attrs().Find(ATTR_NAME_OP_MAX_SIZE); if (attr_value != nullptr) { continue; } if (edge->dst()->type_string() == "Assert") { continue; } if (node->type_string() == "Const") { continue; } + ADP_LOG(INFO) << "remove node: " << edge->dst()->name() << "from candidates because string or resource"; if (candidates->erase(edge->dst()) > 0) { (void) outSet.insert(edge->dst()); } } } @@ -685,18 +686,13 @@ Status FindNpuSupportCandidates(const Graph &graph, OrderedNodeSet *candidates, << node->name() << " REF Output."; continue; } - if ((dtype_dst == DT_STRING) || (dtype_dst == DT_RESOURCE) || (dtype_dst == DT_VARIANT)) { + if (dtype_dst == DT_RESOURCE) { const AttrValue *attr_value = node->attrs().Find(ATTR_NAME_OP_MAX_SIZE); if (attr_value != nullptr) { ADP_LOG(INFO) << "Node : " << node->name() << " add to candidates, because of had max size."; continue; } - const std::string src_node_type = edge->src()->type_string(); - if ((enable_dp) && (!kIsHeterogeneous) && (dtype_dst == DT_STRING) && - (src_node_type == "IteratorGetNext" || src_node_type == "GetNext")) { - ADP_LOG(EVENT) << "GetNext: " << src_node_type << " node should sink if enable_data_pre_proc is true"; - continue; - } + ADP_LOG(INFO) << "remove node: " << edge->src()->name() << "from candidates because string or resource"; if (candidates->erase(edge->src()) > 0) { (void) outSet.insert(edge->src()); } } }