Merged
fix: 修复代码检查告警 #4637
duhuaAdd on Aug 29
fix: 修复代码检查告警 #4637
Merged
duhuaAdd on Aug 29
Total: 13 files changed+66-81
@@ -11,8 +11,6 @@
11#ifndef BASE_COMMON_PYTHON_RUNTIME_PYTHON_BRIDGE_LOADER_UTILS_H_11#ifndef BASE_COMMON_PYTHON_RUNTIME_PYTHON_BRIDGE_LOADER_UTILS_H_
12#define BASE_COMMON_PYTHON_RUNTIME_PYTHON_BRIDGE_LOADER_UTILS_H_12#define BASE_COMMON_PYTHON_RUNTIME_PYTHON_BRIDGE_LOADER_UTILS_H_
13 13 
14-#include <dlfcn.h>
15- 
16#include <cstdint>14#include <cstdint>
17#include <string>15#include <string>
18 16 
@@ -27,8 +27,8 @@ bool IsCustomOpExecOnHostCpu(const OpDescPtr &op_desc) {
27 !CustomOpFactory::IsExistOp(AscendString(op_desc->GetTypePtr()), OpBackend::kHostCPU)) {27 !CustomOpFactory::IsExistOp(AscendString(op_desc->GetTypePtr()), OpBackend::kHostCPU)) {
28 return false;28 return false;
29 }29 }
30- std::string lowering_func;30+ const std::string *lowering_func = AttrUtils::GetStr(op_desc, kAttrLowingFunc);
31- return AttrUtils::GetStr(op_desc, kAttrLowingFunc, lowering_func) && (lowering_func == kHostCpuCustomOpLowerFunc);31+ return (lowering_func != nullptr) && (*lowering_func == kHostCpuCustomOpLowerFunc);
32}32}
33} // namespace33} // namespace
34 34 
@@ -71,7 +71,7 @@ HostCpuConstFoldingMemAllocator &GetHostCpuConstFoldingMemAllocator() {
71 71 
72ge::graphStatus HostCpuMemBlockManager(void *block, gert::TensorOperateType operate_type, void **out) {72ge::graphStatus HostCpuMemBlockManager(void *block, gert::TensorOperateType operate_type, void **out) {
73 GE_ASSERT_NOTNULL(block);73 GE_ASSERT_NOTNULL(block);
74- auto *mem_block = reinterpret_cast<ge::MemBlock *>(block);74+ auto *mem_block = static_cast<ge::MemBlock *>(block);
75 GE_ASSERT((operate_type == gert::kGetTensorAddress || operate_type == gert::kFreeTensor ||75 GE_ASSERT((operate_type == gert::kGetTensorAddress || operate_type == gert::kFreeTensor ||
76 operate_type == gert::kPlusShareCount),76 operate_type == gert::kPlusShareCount),
77 "Unexpected operate type %d", static_cast<int32_t>(operate_type));77 "Unexpected operate type %d", static_cast<int32_t>(operate_type));
@@ -20,7 +20,7 @@ namespace ge {
20CustomOpCreatorRegister::CustomOpCreatorRegister(const AscendString &operator_type, const CustomOpCreateFunc op_creator)20CustomOpCreatorRegister::CustomOpCreatorRegister(const AscendString &operator_type, const CustomOpCreateFunc op_creator)
21 : CustomOpCreatorRegister(operator_type, OpBackend::kDevice, op_creator) {}21 : CustomOpCreatorRegister(operator_type, OpBackend::kDevice, op_creator) {}
22 22 
23-CustomOpCreatorRegister::CustomOpCreatorRegister(const AscendString &operator_type, const OpBackend backend,23+CustomOpCreatorRegister::CustomOpCreatorRegister(const AscendString &operator_type, OpBackend backend,
24 const CustomOpCreateFunc op_creator) {24 const CustomOpCreateFunc op_creator) {
25 RegisterCustomOpLocalCreator(operator_type.GetString(), backend, op_creator);25 RegisterCustomOpLocalCreator(operator_type.GetString(), backend, op_creator);
26 if ((op_creator == nullptr) || IsOfflineCustomOpSoLoading()) {26 if ((op_creator == nullptr) || IsOfflineCustomOpSoLoading()) {
@@ -32,12 +32,12 @@ graphStatus CustomOpFactory::RegisterCustomOpCreator(const AscendString &op_type
32 return GetGlobalRegistry().RegisterCreator(op_type, OpBackend::kDevice, op_creator);32 return GetGlobalRegistry().RegisterCreator(op_type, OpBackend::kDevice, op_creator);
33}33}
34 34 
35-graphStatus CustomOpFactory::RegisterCustomOpCreator(const AscendString &op_type, const OpBackend backend,35+graphStatus CustomOpFactory::RegisterCustomOpCreator(const AscendString &op_type, OpBackend backend,
36 const BaseOpCreator &op_creator) {36 const BaseOpCreator &op_creator) {
37 return GetGlobalRegistry().RegisterCreator(op_type, backend, op_creator);37 return GetGlobalRegistry().RegisterCreator(op_type, backend, op_creator);
38}38}
39 39 
40-BaseCustomOp *CustomOpFactory::CreateOrGetCustomOp(const AscendString &op_type, const OpBackend backend) {40+BaseCustomOp *CustomOpFactory::CreateOrGetCustomOp(const AscendString &op_type, OpBackend backend) {
41 return GetGlobalRegistry().CreateOrGetCustomOp(op_type, backend);41 return GetGlobalRegistry().CreateOrGetCustomOp(op_type, backend);
42}42}
43 43 
@@ -59,7 +59,7 @@ bool CustomOpFactory::IsExistOp(const AscendString &op_type) {
59 return IsExistOp(op_type, OpBackend::kDevice);59 return IsExistOp(op_type, OpBackend::kDevice);
60}60}
61 61 
62-bool CustomOpFactory::IsExistOp(const AscendString &op_type, const OpBackend backend) {62+bool CustomOpFactory::IsExistOp(const AscendString &op_type, OpBackend backend) {
63 return GetGlobalRegistry().HasCreator(op_type, backend);63 return GetGlobalRegistry().HasCreator(op_type, backend);
64}64}
65 65 
@@ -78,7 +78,7 @@ graphStatus CustomOpFactory::LoadCustomOpsPartition(const uint8_t *data, size_t
78CustomOpCreatorRegister::CustomOpCreatorRegister(const AscendString &operator_type, BaseOpCreator const &op_creator)78CustomOpCreatorRegister::CustomOpCreatorRegister(const AscendString &operator_type, BaseOpCreator const &op_creator)
79 : CustomOpCreatorRegister(operator_type, OpBackend::kDevice, op_creator) {}79 : CustomOpCreatorRegister(operator_type, OpBackend::kDevice, op_creator) {}
80 80 
81-CustomOpCreatorRegister::CustomOpCreatorRegister(const AscendString &operator_type, const OpBackend backend,81+CustomOpCreatorRegister::CustomOpCreatorRegister(const AscendString &operator_type, OpBackend backend,
82 BaseOpCreator const &op_creator) {82 BaseOpCreator const &op_creator) {
83 if (IsOfflineCustomOpSoLoading()) {83 if (IsOfflineCustomOpSoLoading()) {
84 return;84 return;
@@ -50,8 +50,7 @@ std::vector<LocalCreator> &GetCustomOpLocalCreators() {
50}50}
51} // namespace51} // namespace
52 52 
53-void RegisterCustomOpLocalCreator(const char *const op_type, const OpBackend backend,53+void RegisterCustomOpLocalCreator(const char *const op_type, OpBackend backend, const CustomOpCreateFunc creator) {
54- const CustomOpCreateFunc creator) {
55 if ((op_type == nullptr) || (op_type[0] == '\0') || (creator == nullptr)) {54 if ((op_type == nullptr) || (op_type[0] == '\0') || (creator == nullptr)) {
56 return;55 return;
57 }56 }
@@ -148,7 +148,7 @@ CustomOpRegistry::~CustomOpRegistry() {
148 }148 }
149}149}
150 150 
151-graphStatus CustomOpRegistry::RegisterCreator(const AscendString &op_type, const OpBackend backend,151+graphStatus CustomOpRegistry::RegisterCreator(const AscendString &op_type, OpBackend backend,
152 const BaseOpCreator &creator) {152 const BaseOpCreator &creator) {
153 const std::lock_guard<std::mutex> lock(mu_);153 const std::lock_guard<std::mutex> lock(mu_);
154 if (!IsValidOpBackend(backend)) {154 if (!IsValidOpBackend(backend)) {
@@ -182,12 +182,37 @@ void CustomOpRegistry::AddSoHandles(const std::vector<CustomOpSoHandlePtr> &so_h
182 so_handles_.insert(so_handles_.end(), so_handles.begin(), so_handles.end());182 so_handles_.insert(so_handles_.end(), so_handles.begin(), so_handles.end());
183}183}
184 184 
185-BaseCustomOp *CustomOpRegistry::CreateOrGetCustomOp(const AscendString &op_type, const OpBackend backend) {185+BaseCustomOp *CustomOpRegistry::CreateOrGetCustomOp(const AscendString &op_type, OpBackend backend) {
186 const std::lock_guard<std::mutex> lock(mu_);186 const std::lock_guard<std::mutex> lock(mu_);
187 return CreateOrGetCustomOpLocked(op_type, backend);187 return CreateOrGetCustomOpLocked(op_type, backend);
188}188}
189 189 
190-BaseCustomOp *CustomOpRegistry::CreateOrGetCustomOpLocked(const AscendString &op_type, const OpBackend backend) {190+BaseCustomOp *CustomOpRegistry::CacheCustomOpLocked(const AscendString &op_type, OpBackend backend,
191+ std::unique_ptr<BaseCustomOp> base_custom_op) {
192+ auto &backend_custom_ops = custom_ops_[op_type];
193+ for (const auto &backend_custom_op : backend_custom_ops) {
194+ if ((backend_custom_op.second != nullptr) && (typeid(*backend_custom_op.second) == typeid(*base_custom_op))) {
195+ auto [ops_it, success] = backend_custom_ops.emplace(backend, backend_custom_op.second);
196+ if (success) {
197+ GELOGI("[CUSTOM OP] share custom op instance for %s:%s with existing %s backend.", op_type.GetString(),
198+ OpBackendToString(backend), OpBackendToString(backend_custom_op.first));
199+ return ops_it->second.get();
200+ }
201+ GELOGW("[CUSTOM OP] custom op instance found, get failed for %s:%s.", op_type.GetString(),
202+ OpBackendToString(backend));
203+ return nullptr;
204+ }
205+ }
206+ auto [ops_it, success] = backend_custom_ops.emplace(backend, std::move(base_custom_op));
207+ if (success) {
208+ return ops_it->second.get();
209+ }
210+ GELOGW("[CUSTOM OP] custom op instance found, get failed for %s:%s.", op_type.GetString(),
211+ OpBackendToString(backend));
212+ return nullptr;
213+}
214+ 
215+BaseCustomOp *CustomOpRegistry::CreateOrGetCustomOpLocked(const AscendString &op_type, OpBackend backend) {
191 if (!IsValidOpBackend(backend)) {216 if (!IsValidOpBackend(backend)) {
192 GELOGE(GRAPH_PARAM_INVALID, "[Check][Param] custom op backend for %s is invalid:%u.", op_type.GetString(),217 GELOGE(GRAPH_PARAM_INVALID, "[Check][Param] custom op backend for %s is invalid:%u.", op_type.GetString(),
193 static_cast<uint32_t>(backend));218 static_cast<uint32_t>(backend));
@@ -217,34 +242,14 @@ BaseCustomOp *CustomOpRegistry::CreateOrGetCustomOpLocked(const AscendString &op
217 OpBackendToString(backend));242 OpBackendToString(backend));
218 return nullptr;243 return nullptr;
219 }244 }
220- auto &backend_custom_ops = custom_ops_[op_type];245+ return CacheCustomOpLocked(op_type, backend, std::move(base_custom_op));
221- for (const auto &backend_custom_op : backend_custom_ops) {
222- if ((backend_custom_op.second != nullptr) && (typeid(*backend_custom_op.second) == typeid(*base_custom_op))) {
223- auto [ops_it, success] = backend_custom_ops.emplace(backend, backend_custom_op.second);
224- if (success) {
225- GELOGI("[CUSTOM OP] share custom op instance for %s:%s with existing %s backend.", op_type.GetString(),
226- OpBackendToString(backend), OpBackendToString(backend_custom_op.first));
227- return ops_it->second.get();
228- }
229- GELOGW("[CUSTOM OP] custom op instance found, get failed for %s:%s.", op_type.GetString(),
230- OpBackendToString(backend));
231- return nullptr;
232- }
233- }
234- auto [ops_it, success] =
235- backend_custom_ops.emplace(backend, std::shared_ptr<BaseCustomOp>(std::move(base_custom_op)));
236- if (success) {
237- return ops_it->second.get();
238- }
239- GELOGW("[CUSTOM OP] custom op instance found, get failed for %s:%s.", op_type.GetString(),
240- OpBackendToString(backend));
241 }246 }
242 GELOGW("[CUSTOM OP] get custom operator creator failed for %s:%s.", op_type.GetString(), OpBackendToString(backend));247 GELOGW("[CUSTOM OP] get custom operator creator failed for %s:%s.", op_type.GetString(), OpBackendToString(backend));
243 return nullptr;248 return nullptr;
244}249}
245 250 
246BaseCustomOp *CustomOpRegistry::GetCustomOpCommonCapability(const AscendString &op_type,251BaseCustomOp *CustomOpRegistry::GetCustomOpCommonCapability(const AscendString &op_type,
247- const CustomOpCapability capability) {252+ CustomOpCapability capability) {
248 if (!IsCommonCapability(capability)) {253 if (!IsCommonCapability(capability)) {
249 GELOGE(GRAPH_FAILED, "[CUSTOM OP] capability %u for %s is not a common capability.",254 GELOGE(GRAPH_FAILED, "[CUSTOM OP] capability %u for %s is not a common capability.",
250 static_cast<uint32_t>(capability), op_type.GetString());255 static_cast<uint32_t>(capability), op_type.GetString());
@@ -333,7 +338,7 @@ bool CustomOpRegistry::HasCreator(const AscendString &op_type) const {
333 return (it != creators_.cend()) && (!it->second.empty());338 return (it != creators_.cend()) && (!it->second.empty());
334}339}
335 340 
336-bool CustomOpRegistry::HasCreator(const AscendString &op_type, const OpBackend backend) const {341+bool CustomOpRegistry::HasCreator(const AscendString &op_type, OpBackend backend) const {
337 const std::lock_guard<std::mutex> lock(mu_);342 const std::lock_guard<std::mutex> lock(mu_);
338 const auto it = creators_.find(op_type);343 const auto it = creators_.find(op_type);
339 return (it != creators_.cend()) && (it->second.find(backend) != it->second.cend());344 return (it != creators_.cend()) && (it->second.find(backend) != it->second.cend());
@@ -20,6 +20,7 @@ CompileInfoManager &CompileInfoManager::Instance() {
20}20}
21 21 
22bool CompileInfoManager::HasCompileInfo(const std::string &key) {22bool CompileInfoManager::HasCompileInfo(const std::string &key) {
23+ const std::lock_guard<std::mutex> lock_guard(compile_info_mutex_);
23 return this->compile_info_map_.find(key) != this->compile_info_map_.end();24 return this->compile_info_map_.find(key) != this->compile_info_map_.end();
24}25}
25 26 
@@ -46,6 +47,7 @@ CompileInfoCache &CompileInfoCache::Instance() {
46}47}
47 48 
48bool CompileInfoCache::HasCompileInfo(const std::string &key) {49bool CompileInfoCache::HasCompileInfo(const std::string &key) {
50+ const std::lock_guard<std::mutex> lock_guard(compile_info_mutex_);
49 return this->compile_info_map_.find(key) != this->compile_info_map_.end();51 return this->compile_info_map_.find(key) != this->compile_info_map_.end();
50}52}
51 53 
@@ -14,6 +14,10 @@
14#include <type_traits>14#include <type_traits>
15 15 
16#include "exe_graph/runtime/extended_kernel_context.h"16#include "exe_graph/runtime/extended_kernel_context.h"
17+#include "exe_graph/runtime/runtime_tensor.h"
18+#include "exe_graph/runtime/storage_format.h"
19+#include "exe_graph/runtime/storage_shape.h"
20+#include "graph/types.h"
17 21 
18namespace gert {22namespace gert {
19class HostCpuOpExecutionContext : public ExtendedKernelContext {23class HostCpuOpExecutionContext : public ExtendedKernelContext {
@@ -52,6 +52,8 @@ class CustomOpRegistry {
52 52 
53 private:53 private:
54 BaseCustomOp *CreateOrGetCustomOpLocked(const AscendString &op_type, OpBackend backend);54 BaseCustomOp *CreateOrGetCustomOpLocked(const AscendString &op_type, OpBackend backend);
55+ BaseCustomOp *CacheCustomOpLocked(const AscendString &op_type, OpBackend backend,
56+ std::unique_ptr<BaseCustomOp> base_custom_op);
55 57 
56 mutable std::mutex mu_;58 mutable std::mutex mu_;
57 std::vector<CustomOpSoHandlePtr> so_handles_;59 std::vector<CustomOpSoHandlePtr> so_handles_;
@@ -99,25 +99,24 @@ bg::ValueHolderPtr FindHostCpuCustomExecutorFunc(const ge::NodePtr &node, const
99 99 
100ge::graphStatus BuildInputTensors(const ge::NodePtr &node, const LowerInput &lower_input,100ge::graphStatus BuildInputTensors(const ge::NodePtr &node, const LowerInput &lower_input,
101 std::vector<bg::ValueHolderPtr> &input_tensor_holders,101 std::vector<bg::ValueHolderPtr> &input_tensor_holders,
102- std::vector<bg::ValueHolderPtr> &input_addr_holders) {102+ std::vector<bg::ValueHolderPtr> &input_addr_holders, const bool host_lowering) {
103 const ge::OpDescPtr op_desc = node->GetOpDesc();103 const ge::OpDescPtr op_desc = node->GetOpDesc();
104 gert::DataDependentInterpreter ddi(op_desc, lower_input.global_data->GetSpaceRegistriesV2());104 gert::DataDependentInterpreter ddi(op_desc, lower_input.global_data->GetSpaceRegistriesV2());
105 size_t instance_index = 0U;105 size_t instance_index = 0U;
106- for (const ge::InDataAnchorPtr &in_data_anchor : node->GetAllInDataAnchors()) {106+ for (const auto *in_data_anchor : node->GetAllInDataAnchorsPtr()) {
107 GE_ASSERT_NOTNULL(in_data_anchor);107 GE_ASSERT_NOTNULL(in_data_anchor);
108 // optional场景108 // optional场景
109 ge::OutDataAnchorPtr out_data_anchor = in_data_anchor->GetPeerOutAnchor();109 ge::OutDataAnchorPtr out_data_anchor = in_data_anchor->GetPeerOutAnchor();
110 if (out_data_anchor == nullptr) {110 if (out_data_anchor == nullptr) {
111 continue;111 continue;
112 }112 }
113- ge::NodePtr peer_node = out_data_anchor->GetOwnerNode();113+ ge::Node *peer_node = out_data_anchor->GetOwnerNodeBarePtr();
114 GE_ASSERT_NOTNULL(peer_node);114 GE_ASSERT_NOTNULL(peer_node);
115- const auto *const_lower_result = peer_node->GetOpDesc()->GetExtAttr<PlacedLoweringResult>(kLoweringResult);115+ auto *lower_result = peer_node->GetOpDesc()->GetExtAttr<PlacedLoweringResult>(kLoweringResult);
116- GE_ASSERT_NOTNULL(const_lower_result, "Lowering result of node [%s, %s] is not found.", peer_node->GetNamePtr(),116+ GE_ASSERT_NOTNULL(lower_result, "Lowering result of node [%s, %s] is not found.", peer_node->GetNamePtr(),
117 peer_node->GetTypePtr());117 peer_node->GetTypePtr());
118- auto *lower_result = const_cast<PlacedLoweringResult *>(const_lower_result);118+ const int32_t input_placement =
119- GE_ASSERT_NOTNULL(lower_result);119+ host_lowering ? kOnHost : (NeedHostInput(op_desc, instance_index, ddi) ? kOnHost : kOnDeviceHbm);
120- const int32_t input_placement = NeedHostInput(op_desc, instance_index, ddi) ? kOnHost : kOnDeviceHbm;
121 const OutputLowerResult *result = lower_result->GetOutputTensorResult(120 const OutputLowerResult *result = lower_result->GetOutputTensorResult(
122 *lower_input.global_data, out_data_anchor->GetIdx(), {input_placement, node->GetOpDesc()->GetStreamId()});121 *lower_input.global_data, out_data_anchor->GetIdx(), {input_placement, node->GetOpDesc()->GetStreamId()});
123 GE_ASSERT_NOTNULL(result, "Lowering result of node [%s, %s] output[%d] is nullptr.", peer_node->GetNamePtr(),122 GE_ASSERT_NOTNULL(result, "Lowering result of node [%s, %s] output[%d] is nullptr.", peer_node->GetNamePtr(),
@@ -132,44 +131,13 @@ ge::graphStatus BuildInputTensors(const ge::NodePtr &node, const LowerInput &low
132 lower_input.input_shapes.size(), input_tensor_holders.size());131 lower_input.input_shapes.size(), input_tensor_holders.size());
133 return ge::SUCCESS;132 return ge::SUCCESS;
134}133}
135- 
136-ge::graphStatus BuildHostInputTensors(const ge::NodePtr &node, const LowerInput &lower_input,
137- std::vector<bg::ValueHolderPtr> &input_tensor_holders,
138- std::vector<bg::ValueHolderPtr> &input_addr_holders) {
139- for (const ge::InDataAnchorPtr &in_data_anchor : node->GetAllInDataAnchors()) {
140- GE_ASSERT_NOTNULL(in_data_anchor);
141- // optional场景
142- ge::OutDataAnchorPtr out_data_anchor = in_data_anchor->GetPeerOutAnchor();
143- if (out_data_anchor == nullptr) {
144- continue;
145- }
146- ge::NodePtr peer_node = out_data_anchor->GetOwnerNode();
147- GE_ASSERT_NOTNULL(peer_node);
148- const auto *const_lower_result = peer_node->GetOpDesc()->GetExtAttr<PlacedLoweringResult>(kLoweringResult);
149- GE_ASSERT_NOTNULL(const_lower_result, "Lowering result of node [%s, %s] is not found.", peer_node->GetNamePtr(),
150- peer_node->GetTypePtr());
151- auto *lower_result = const_cast<PlacedLoweringResult *>(const_lower_result);
152- GE_ASSERT_NOTNULL(lower_result);
153- const OutputLowerResult *result = lower_result->GetOutputTensorResult(
154- *lower_input.global_data, out_data_anchor->GetIdx(), {kOnHost, node->GetOpDesc()->GetStreamId()});
155- GE_ASSERT_NOTNULL(result, "Lowering result of node [%s, %s] output[%d] is nullptr.", peer_node->GetNamePtr(),
156- peer_node->GetTypePtr(), out_data_anchor->GetIdx());
157- GE_ASSERT_NOTNULL(result->shape);
158- input_tensor_holders.emplace_back(result->shape);
159- input_addr_holders.emplace_back(result->address);
160- }
161- GE_ASSERT_TRUE(lower_input.input_shapes.size() == input_tensor_holders.size(),
162- "Size[%zu] of input shapes and size[%zu] of input tensor is not same.",
163- lower_input.input_shapes.size(), input_tensor_holders.size());
164- return ge::SUCCESS;
165-}
166} // namespace134} // namespace
167 135 
168LowerResult LoweringCustomNode(const ge::NodePtr &node, const LowerInput &lower_input) {136LowerResult LoweringCustomNode(const ge::NodePtr &node, const LowerInput &lower_input) {
169 LOWER_REQUIRE_HYPER_SUCCESS(CheckLowerInput(lower_input));137 LOWER_REQUIRE_HYPER_SUCCESS(CheckLowerInput(lower_input));
170 std::vector<bg::ValueHolderPtr> input_holders;138 std::vector<bg::ValueHolderPtr> input_holders;
171 std::vector<bg::ValueHolderPtr> input_addr_holders;139 std::vector<bg::ValueHolderPtr> input_addr_holders;
172- LOWER_REQUIRE_SUCCESS(BuildInputTensors(node, lower_input, input_holders, input_addr_holders));140+ LOWER_REQUIRE_SUCCESS(BuildInputTensors(node, lower_input, input_holders, input_addr_holders, false));
173 // Allocate141 // Allocate
174 auto allocator_holder =142 auto allocator_holder =
175 lower_input.global_data->GetOrCreateAllocator({kOnDeviceHbm, AllocatorUsage::kAllocNodeOutput});143 lower_input.global_data->GetOrCreateAllocator({kOnDeviceHbm, AllocatorUsage::kAllocNodeOutput});
@@ -236,7 +204,7 @@ LowerResult LoweringHostCustomNode(const ge::NodePtr &node, const LowerInput &lo
236 LOWER_REQUIRE_HYPER_SUCCESS(CheckLowerInput(lower_input));204 LOWER_REQUIRE_HYPER_SUCCESS(CheckLowerInput(lower_input));
237 std::vector<bg::ValueHolderPtr> input_holders;205 std::vector<bg::ValueHolderPtr> input_holders;
238 std::vector<bg::ValueHolderPtr> input_addr_holders;206 std::vector<bg::ValueHolderPtr> input_addr_holders;
239- LOWER_REQUIRE_SUCCESS(BuildHostInputTensors(node, lower_input, input_holders, input_addr_holders));207+ LOWER_REQUIRE_SUCCESS(BuildInputTensors(node, lower_input, input_holders, input_addr_holders, true));
240 // Allocate208 // Allocate
241 auto allocator_holder = lower_input.global_data->GetOrCreateAllocator({kOnHost, AllocatorUsage::kAllocNodeOutput});209 auto allocator_holder = lower_input.global_data->GetOrCreateAllocator({kOnHost, AllocatorUsage::kAllocNodeOutput});
242 // Create op executeFunc210 // Create op executeFunc
@@ -305,7 +305,9 @@ TEST_F(LowerCompatibleUnitTest, Lowering_Execute_Model_On_Compatible_infer_tilin
305 auto graph = ShareGraph::BuildSingleNodeGraph(node_type);305 auto graph = ShareGraph::BuildSingleNodeGraph(node_type);
306 graph->TopologicalSorting();306 graph->TopologicalSorting();
307 auto add_node = graph->FindFirstNodeMatchType(node_type);307 auto add_node = graph->FindFirstNodeMatchType(node_type);
308- ge::AttrUtils::SetStr(add_node->GetOpDesc(), optiling::COMPILE_INFO_KEY, "{}"); // mock for tiling parse308+ const std::string compile_info_key = "lower_compatible_v4_compile_info";
309+ ge::AttrUtils::SetStr(add_node->GetOpDesc(), optiling::COMPILE_INFO_KEY, compile_info_key);
310+ EXPECT_FALSE(optiling::CompileInfoManager::Instance().HasCompileInfo(compile_info_key));
309 311 
310 GeModelBuilder builder(graph);312 GeModelBuilder builder(graph);
311 auto ge_root_model = builder.AddTaskDef(node_type, AiCoreTaskDefFaker(AddStubName).WithHandle()).BuildGeRootModel();313 auto ge_root_model = builder.AddTaskDef(node_type, AiCoreTaskDefFaker(AddStubName).WithHandle()).BuildGeRootModel();
@@ -335,6 +337,7 @@ TEST_F(LowerCompatibleUnitTest, Lowering_Execute_Model_On_Compatible_infer_tilin
335 ASSERT_EQ(model_executor->Execute({i3.value}, std::vector<Tensor *>({i0.holder.get(), i1.holder.get()}).data(), 2,337 ASSERT_EQ(model_executor->Execute({i3.value}, std::vector<Tensor *>({i0.holder.get(), i1.holder.get()}).data(), 2,
336 reinterpret_cast<Tensor **>(outputs.GetAddrList()), outputs.size()),338 reinterpret_cast<Tensor **>(outputs.GetAddrList()), outputs.size()),
337 ge::GRAPH_SUCCESS);339 ge::GRAPH_SUCCESS);
340+ EXPECT_TRUE(optiling::CompileInfoManager::Instance().HasCompileInfo(compile_info_key));
338 341 
339 ASSERT_EQ(model_executor->Execute({i3.value}, std::vector<Tensor *>({i0.holder.get(), i1.holder.get()}).data(), 2,342 ASSERT_EQ(model_executor->Execute({i3.value}, std::vector<Tensor *>({i0.holder.get(), i1.holder.get()}).data(), 2,
340 reinterpret_cast<Tensor **>(outputs.GetAddrList()), outputs.size()),343 reinterpret_cast<Tensor **>(outputs.GetAddrList()), outputs.size()),
@@ -359,7 +362,9 @@ TEST_F(LowerCompatibleUnitTest, Lowering_Execute_Model_On_Compatible_infer_tilin
359 auto graph = ShareGraph::BuildSingleNodeGraph(node_type);362 auto graph = ShareGraph::BuildSingleNodeGraph(node_type);
360 graph->TopologicalSorting();363 graph->TopologicalSorting();
361 auto add_node = graph->FindFirstNodeMatchType(node_type);364 auto add_node = graph->FindFirstNodeMatchType(node_type);
362- ge::AttrUtils::SetStr(add_node->GetOpDesc(), optiling::COMPILE_INFO_KEY, "{}"); // mock for tiling parse365+ const std::string compile_info_key = "lower_compatible_v3_compile_info";
366+ ge::AttrUtils::SetStr(add_node->GetOpDesc(), optiling::COMPILE_INFO_KEY, compile_info_key);
367+ EXPECT_FALSE(optiling::CompileInfoCache::Instance().HasCompileInfo(compile_info_key));
363 368 
364 GeModelBuilder builder(graph);369 GeModelBuilder builder(graph);
365 auto ge_root_model = builder.AddTaskDef(node_type, AiCoreTaskDefFaker(AddStubName).WithHandle()).BuildGeRootModel();370 auto ge_root_model = builder.AddTaskDef(node_type, AiCoreTaskDefFaker(AddStubName).WithHandle()).BuildGeRootModel();
@@ -388,6 +393,7 @@ TEST_F(LowerCompatibleUnitTest, Lowering_Execute_Model_On_Compatible_infer_tilin
388 ASSERT_EQ(model_executor->Execute({i3.value}, std::vector<Tensor *>({i0.holder.get(), i1.holder.get()}).data(), 2,393 ASSERT_EQ(model_executor->Execute({i3.value}, std::vector<Tensor *>({i0.holder.get(), i1.holder.get()}).data(), 2,
389 reinterpret_cast<Tensor **>(outputs.GetAddrList()), outputs.size()),394 reinterpret_cast<Tensor **>(outputs.GetAddrList()), outputs.size()),
390 ge::GRAPH_SUCCESS);395 ge::GRAPH_SUCCESS);
396+ EXPECT_TRUE(optiling::CompileInfoCache::Instance().HasCompileInfo(compile_info_key));
391 ASSERT_EQ(model_executor->Execute({i3.value}, std::vector<Tensor *>({i0.holder.get(), i1.holder.get()}).data(), 2,397 ASSERT_EQ(model_executor->Execute({i3.value}, std::vector<Tensor *>({i0.holder.get(), i1.holder.get()}).data(), 2,
392 reinterpret_cast<Tensor **>(outputs.GetAddrList()), outputs.size()),398 reinterpret_cast<Tensor **>(outputs.GetAddrList()), outputs.size()),
393 ge::GRAPH_SUCCESS);399 ge::GRAPH_SUCCESS);
@@ -425,6 +425,7 @@ SKIP_METHODS = [
425 "CallInferFormatFuncV2",425 "CallInferFormatFuncV2",
426 "InferCustomOpShape",426 "InferCustomOpShape",
427 "GetRealInNodesAndIndex",427 "GetRealInNodesAndIndex",
428+ "CacheCustomOpLocked",
428]429]
429 430 
430"""431"""