diff --git a/tf_adapter/kernels/geop_npu.cc b/tf_adapter/kernels/geop_npu.cc index 58726faf56d759ec926fcf2fe9ffe5a8a9d2d740..e674126a1ff391c33e2a99f29bf90ba9a8026ebf 100644 --- a/tf_adapter/kernels/geop_npu.cc +++ b/tf_adapter/kernels/geop_npu.cc @@ -2227,12 +2227,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()); @@ -2241,6 +2243,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(); @@ -2253,6 +2256,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); @@ -2418,10 +2423,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 eef34c856e750cad850d46a3e02a23ca148ada3e..27da95f7b96267cbd18eca699f3a0d2c394db5ea 100644 --- a/tf_adapter/optimizers/om_partition_subgraphs_pass.cc +++ b/tf_adapter/optimizers/om_partition_subgraphs_pass.cc @@ -696,11 +696,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()); } } } @@ -718,18 +719,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()); } } }