Merged
【feat】: Support PCIe Through #430
kantao1Add on Aug 14
【feat】: Support PCIe Through #430
Merged
kantao1Add on Aug 14
Total: 18 files changed+265-10
@@ -28,6 +28,7 @@ struct TilingInfo {
28 std::pair<const void *, gert::Chain::Deleter> tiling_data_ = {nullptr, nullptr};28 std::pair<const void *, gert::Chain::Deleter> tiling_data_ = {nullptr, nullptr};
29 int32_t deterministic_ = 0;29 int32_t deterministic_ = 0;
30 int32_t deterministic_level_ = 0;30 int32_t deterministic_level_ = 0;
31+ bool pcie_through_flag_ = false;
31 const gert::ContinuousVector *workspace_ = nullptr;32 const gert::ContinuousVector *workspace_ = nullptr;
32 const gert::Dim3 *simt_block_dim = nullptr;33 const gert::Dim3 *simt_block_dim = nullptr;
33 const gert::Dim3 *simt_grid_dim = nullptr;34 const gert::Dim3 *simt_grid_dim = nullptr;
@@ -98,6 +99,10 @@ class ContextBuilderImpl {
98 tiling_info_.deterministic_level_ = deterministic_level;99 tiling_info_.deterministic_level_ = deterministic_level;
99 }100 }
100 101 
102+ void SetPcieThroughFlag(bool flag) {
103+ tiling_info_.pcie_through_flag_ = flag;
104+ }
105+ 
101 void SetCompiledJson(const ge::char_t *compiled_json) {106 void SetCompiledJson(const ge::char_t *compiled_json) {
102 tiling_parse_info_.compiled_json_ = compiled_json;107 tiling_parse_info_.compiled_json_ = compiled_json;
103 }108 }
@@ -154,4 +159,4 @@ class ContextBuilderImpl {
154};159};
155} // namespace gert160} // namespace gert
156 161 
157-#endif // METADEF_EXE_BASE_CONTEXT_BUILDER_OP_CONTEXT_BUILDER_IMPL_H_162+#endif // METADEF_EXE_BASE_CONTEXT_BUILDER_OP_CONTEXT_BUILDER_IMPL_H_
@@ -36,6 +36,8 @@ class OpTilingContextBuilderImpl : public ContextBuilderImpl {
36 (void)input_values_.emplace_back(reinterpret_cast<void *>(tiling_info_.deterministic_), nullptr); // Deterministic36 (void)input_values_.emplace_back(reinterpret_cast<void *>(tiling_info_.deterministic_), nullptr); // Deterministic
37 (void)input_values_.emplace_back(reinterpret_cast<void *>(tiling_info_.deterministic_level_),37 (void)input_values_.emplace_back(reinterpret_cast<void *>(tiling_info_.deterministic_level_),
38 nullptr); // DeterministicLevel38 nullptr); // DeterministicLevel
39+ (void)input_values_.emplace_back(reinterpret_cast<void *>(static_cast<uintptr_t>(tiling_info_.pcie_through_flag_)),
40+ nullptr); // PcieThroughFlag
39 output_values_.resize(TilingContext::kOutputNum);41 output_values_.resize(TilingContext::kOutputNum);
40 output_values_[TilingContext::kOutputTilingData] =42 output_values_[TilingContext::kOutputTilingData] =
41 std::make_pair(tiling_info_.tiling_data_.first, tiling_info_.tiling_data_.second);43 std::make_pair(tiling_info_.tiling_data_.first, tiling_info_.tiling_data_.second);
@@ -87,6 +89,12 @@ OpTilingContextBuilder &OpTilingContextBuilder::DeterministicLevel(int32_t deter
87 return *this;89 return *this;
88}90}
89 91 
92+OpTilingContextBuilder &OpTilingContextBuilder::SetPcieThroughFlag(bool flag) {
93+ GE_CHECK_NOTNULL_EXEC(impl_, return *this);
94+ impl_->SetPcieThroughFlag(flag);
95+ return *this;
96+}
97+ 
90OpTilingContextBuilder &OpTilingContextBuilder::TilingData(const gert::TilingData *tiling_data,98OpTilingContextBuilder &OpTilingContextBuilder::TilingData(const gert::TilingData *tiling_data,
91 gert::Chain::Deleter deleter) {99 gert::Chain::Deleter deleter) {
92 GE_CHECK_NOTNULL_EXEC(impl_, return *this);100 GE_CHECK_NOTNULL_EXEC(impl_, return *this);
@@ -174,6 +174,10 @@ void RegisterOpImplToRegistry(const OpImplRegisterV2Impl *rd) {
174 RegisterBitmask(funcs.nullable_outputs_, rd->functions.nullable_outputs_, rd->op_type.GetString(),174 RegisterBitmask(funcs.nullable_outputs_, rd->functions.nullable_outputs_, rd->op_type.GetString(),
175 "NullableOutputs");175 "NullableOutputs");
176 }176 }
177+ if (rd->functions.IsSupportPcieThrough()) {
178+ ss << "[SetSupportPcieThrough]";
179+ funcs.SetSupportPcieThrough();
180+ }
177 181 
178 GELOGI("LocalRegistry[%zu] Op type[%s] register OP_IMPL : %s",182 GELOGI("LocalRegistry[%zu] Op type[%s] register OP_IMPL : %s",
179 std::hash<std::string>()(metadef::GetModelPathByAddr(&OpImplRegistry::GetInstance())), rd->op_type.GetString(),183 std::hash<std::string>()(metadef::GetModelPathByAddr(&OpImplRegistry::GetInstance())), rd->op_type.GetString(),
@@ -297,6 +301,7 @@ OpImplRegisterV2::OpImplRegisterV2(const ge::char_t *op_type) : impl_(new (std::
297 impl_->functions.output_shape_depend_compute = 0U;301 impl_->functions.output_shape_depend_compute = 0U;
298 impl_->functions.infer_format_func = nullptr;302 impl_->functions.infer_format_func = nullptr;
299 impl_->functions.nullable_outputs_ = 0UL;303 impl_->functions.nullable_outputs_ = 0UL;
304+ impl_->functions.reserved_[kPcieThroughFlagIdx] = 0UL;
300 305 
301 // private attr controlled by is_private_attr_registered306 // private attr controlled by is_private_attr_registered
302 (void)OpImplRegistry::GetInstance().CreateOrGetOpImpl(op_type);307 (void)OpImplRegistry::GetInstance().CreateOrGetOpImpl(op_type);
@@ -540,4 +545,11 @@ OpImplRegisterV2 &OpImplRegisterV2::InferFormat(InferFormatFunc infer_format_fun
540 }545 }
541 return *this;546 return *this;
542}547}
548+ 
549+OpImplRegisterV2 &OpImplRegisterV2::SetSupportPcieThrough() {
550+ if (impl_ != nullptr) {
551+ impl_->functions.SetSupportPcieThrough();
552+ }
553+ return *this;
554+}
543} // namespace gert555} // namespace gert
@@ -29,7 +29,7 @@
29 } else if (((merged_funcs).func_name) != nullptr and ((src_funcs).func_name != nullptr)) { \29 } else if (((merged_funcs).func_name) != nullptr and ((src_funcs).func_name != nullptr)) { \
30 GELOGW("op type %s %s func has been registered.", (op_type), #func_name); \30 GELOGW("op type %s %s func has been registered.", (op_type), #func_name); \
31 } else { \31 } else { \
32- /* 空分支,无需操作 */ \32+ /* 空分支,无需操作 */ \
33 }33 }
34 34 
35#define MERGE_SCALAR(merged, src, member) \35#define MERGE_SCALAR(merged, src, member) \
@@ -39,7 +39,7 @@
39 } else if ((merged).member != 0 && (src).member != 0) { \39 } else if ((merged).member != 0 && (src).member != 0) { \
40 GELOGW("op type %s " #member " has been registered", op_type.c_str()); \40 GELOGW("op type %s " #member " has been registered", op_type.c_str()); \
41 } else { \41 } else { \
42- /* 已经注册且没有重复注册 */ \42+ /* 已经注册且没有重复注册 */ \
43 } \43 } \
44 } while (0)44 } while (0)
45 45 
@@ -202,6 +202,11 @@ void OpImplSpaceRegistryImpl::MergeFunctions(OpImplKernelRegistry::OpImplFunctio
202 MERGE_SCALAR(merged_funcs, src_funcs, tiling_dependency);202 MERGE_SCALAR(merged_funcs, src_funcs, tiling_dependency);
203 MERGE_SCALAR(merged_funcs, src_funcs, tiling_dependency_placements);203 MERGE_SCALAR(merged_funcs, src_funcs, tiling_dependency_placements);
204 204 
205+ if (src_funcs.IsSupportPcieThrough() && !merged_funcs.IsSupportPcieThrough()) {
206+ merged_funcs.SetSupportPcieThrough();
207+ GELOGD("op type %s pcie_through_flag registered.", op_type.c_str());
208+ }
209+ 
205 if (merged_funcs.private_attrs.size() == 0U) {210 if (merged_funcs.private_attrs.size() == 0U) {
206 merged_funcs.private_attrs = src_funcs.private_attrs;211 merged_funcs.private_attrs = src_funcs.private_attrs;
207 } else if (src_funcs.private_attrs.size() != 0U) {212 } else if (src_funcs.private_attrs.size() != 0U) {
@@ -209,6 +209,7 @@
209 - [OutputShapeDependOnCompute](gert_namespace/opimplregisterv2/OutputShapeDependOnCompute.md)209 - [OutputShapeDependOnCompute](gert_namespace/opimplregisterv2/OutputShapeDependOnCompute.md)
210 - [ExceptionDumpParseFunc](gert_namespace/opimplregisterv2/ExceptionDumpParseFunc.md)210 - [ExceptionDumpParseFunc](gert_namespace/opimplregisterv2/ExceptionDumpParseFunc.md)
211 - [NullableOutputs](gert_namespace/opimplregisterv2/NullableOutputs.md)211 - [NullableOutputs](gert_namespace/opimplregisterv2/NullableOutputs.md)
212+ - [SetSupportPcieThrough](gert_namespace/opimplregisterv2/SetSupportPcieThrough.md)
212 213 
213 - [OpInferDataTypeContextBuilder](gert_namespace/opinferdatatypecontextbuilder/OpInferDataTypeContextBuilder.md)214 - [OpInferDataTypeContextBuilder](gert_namespace/opinferdatatypecontextbuilder/OpInferDataTypeContextBuilder.md)
214 - [简介](gert_namespace/opinferdatatypecontextbuilder/introduction.md)215 - [简介](gert_namespace/opinferdatatypecontextbuilder/introduction.md)
@@ -246,6 +247,7 @@
246 - [PlatformInfo](gert_namespace/optilingcontextbuilder/PlatformInfo.md)247 - [PlatformInfo](gert_namespace/optilingcontextbuilder/PlatformInfo.md)
247 - [Deterministic](gert_namespace/optilingcontextbuilder/Deterministic.md)248 - [Deterministic](gert_namespace/optilingcontextbuilder/Deterministic.md)
248 - [DeterministicLevel](gert_namespace/optilingcontextbuilder/DeterministicLevel.md)249 - [DeterministicLevel](gert_namespace/optilingcontextbuilder/DeterministicLevel.md)
250+ - [SetPcieThroughFlag](gert_namespace/optilingcontextbuilder/SetPcieThroughFlag.md)
249 - [TilingData](gert_namespace/optilingcontextbuilder/TilingData.md)251 - [TilingData](gert_namespace/optilingcontextbuilder/TilingData.md)
250 - [TilingDataSize](gert_namespace/optilingcontextbuilder/TilingDataSize.md)252 - [TilingDataSize](gert_namespace/optilingcontextbuilder/TilingDataSize.md)
251 - [Workspace](gert_namespace/optilingcontextbuilder/Workspace.md)253 - [Workspace](gert_namespace/optilingcontextbuilder/Workspace.md)
@@ -460,6 +462,7 @@
460 - [GetDynUBufSize](gert_namespace/tilingcontext/GetDynUBufSize.md)462 - [GetDynUBufSize](gert_namespace/tilingcontext/GetDynUBufSize.md)
461 - [GetDeterministic](gert_namespace/tilingcontext/GetDeterministic.md)463 - [GetDeterministic](gert_namespace/tilingcontext/GetDeterministic.md)
462 - [GetDeterministicLevel](gert_namespace/tilingcontext/GetDeterministicLevel.md)464 - [GetDeterministicLevel](gert_namespace/tilingcontext/GetDeterministicLevel.md)
465+ - [GetPcieThroughFlag](gert_namespace/tilingcontext/GetPcieThroughFlag.md)
463 - [InputIsView](gert_namespace/tilingcontext/InputIsView.md)466 - [InputIsView](gert_namespace/tilingcontext/InputIsView.md)
464 - [GetInputStride](gert_namespace/tilingcontext/GetInputStride.md)467 - [GetInputStride](gert_namespace/tilingcontext/GetInputStride.md)
465 - [GetInputOffset](gert_namespace/tilingcontext/GetInputOffset.md)468 - [GetInputOffset](gert_namespace/tilingcontext/GetInputOffset.md)
@@ -273,9 +273,11 @@ OpImplFunctions的子类,可扩展,本类用于保存算子注册的Generate
273 273 
274**表 16** OpImplFunctionsV2类成员函数274**表 16** OpImplFunctionsV2类成员函数
275 275 
276-|函数名称含义|含义|276+|函数名称含义| 含义 |
277-|--|--|277+|--|----------------------|
278-|OpImplFunctionsV2|默认构造函数|278+|OpImplFunctionsV2| 默认构造函数 |
279-|operator=|拷贝赋值函数|279+|operator=| 拷贝赋值函数 |
280-|NullableOutput|设置算子的第index个输出可以为空|280+|NullableOutput| 设置算子的第index个输出可以为空 |
281-|IsNullableOutput|获取算子的第index输出是否可以为空|281+|IsNullableOutput| 获取算子的第index输出是否可以为空 |
282+|SetSupportPcieThrough| 声明算子是支持PCIE Through的 |
283+|IsSupportPcieThrough| 获取算子是否支持PCIE Through |
@@ -45,3 +45,5 @@
45- [ExceptionDumpParseFunc](ExceptionDumpParseFunc.md)45- [ExceptionDumpParseFunc](ExceptionDumpParseFunc.md)
46 46 
47- [NullableOutputs](NullableOutputs.md)47- [NullableOutputs](NullableOutputs.md)
48+ 
49+- [SetSupportPcieThrough](SetSupportPcieThrough.md)
@@ -0,0 +1,19 @@
1+# SetSupportPcieThrough
2+ 
3+## 函数功能
4+ 
5+该接口用于声明算子支持PCIE Through。
6+ 
7+## 函数原型
8+ 
9+```cpp
10+OpImplRegisterV2 &SetSupportPcieThrough();
11+```
12+ 
13+## 参数说明
14+ 
15+无。
16+ 
17+## 返回值说明
18+ 
19+返回算子的OpImplRegisterV2对象,该对象新增注册SetSupportPcieThrough函数。
@@ -12,6 +12,8 @@
12 12 
13- [DeterministicLevel](DeterministicLevel.md)13- [DeterministicLevel](DeterministicLevel.md)
14 14 
15+- [SetPcieThroughFlag](SetPcieThroughFlag.md)
16+ 
15- [TilingData](TilingData.md)17- [TilingData](TilingData.md)
16 18 
17- [TilingDataSize](TilingDataSize.md)19- [TilingDataSize](TilingDataSize.md)
@@ -0,0 +1,21 @@
1+# SetPcieThroughFlag
2+ 
3+## 函数功能
4+ 
5+设置是否支持PCIE Through。
6+ 
7+## 函数原型
8+ 
9+```cpp
10+OpTilingContextBuilder &SetPcieThroughFlag(bool flag);
11+```
12+ 
13+## 参数说明
14+ 
15+|参数|输入/输出| 说明 |
16+|--|--|----------------------------------------------------------------|
17+|flag|输入| 设置是否支持PCIE Through(true为支持PCIE Through,false为不支持PCIE Through)。 |
18+ 
19+## 返回值说明
20+ 
21+OpTilingContextBuilder对象本身,用于链式调用。
@@ -0,0 +1,30 @@
1+# GetPcieThroughFlag
2+ 
3+## 函数功能
4+ 
5+查询当前上下文是否启用PCIE Through。
6+ 
7+## 函数原型
8+ 
9+```cpp
10+bool GetPcieThroughFlag() const
11+```
12+ 
13+## 参数说明
14+ 
15+无
16+ 
17+## 返回值说明
18+ 
19+true:当前上下文已启用PCIE Through
20+ 
21+false:当前上下文未启用PCIE Through
22+ 
23+## 调用示例
24+ 
25+```cpp
26+ge::graphStatus Tiling4XXX(TilingContext* context) {
27+ bool ret = context->GetPcieThroughFlag();
28+ // ...
29+}
30+```
@@ -63,6 +63,15 @@ class OpTilingContextBuilder : public OpContextBuilderBase<OpTilingContextBuilde
63 */63 */
64 OpTilingContextBuilder &DeterministicLevel(int32_t deterministic_level);64 OpTilingContextBuilder &DeterministicLevel(int32_t deterministic_level);
65 65 
66+ /**
67+ * @brief 设置Op的PcieThroughFlag标志
68+ * @note
69+ * 该标志用于告知Tiling算子当前是否启用PCIE Through,不调用此接口时默认为false
70+ * @param flag 是否启用pcie through
71+ * @return TilingContextBuilder对象用于链式调用
hugo111
hugo111hugo111Aug 29
likedislike
kantao1
kantao1
Aug 29 Comments:
likedislike
72+ */
73+ OpTilingContextBuilder &SetPcieThroughFlag(bool flag);
74+ 
66 /**75 /**
67 * @brief 设置Op的tilingData指针, 用于构造TilingContext的中的TilingData字段76 * @brief 设置Op的tilingData指针, 用于构造TilingContext的中的TilingData字段
68 * @note77 * @note
@@ -492,6 +492,25 @@ class TilingContext : public ExtendedKernelContext {
492 return av->GetValue<int32_t>();492 return av->GetValue<int32_t>();
493 }493 }
494 494 
495+ /**
496+ * 查询当前上下文是否启用PCIE Through
497+ * @return 任意一个输入为pcie,该接口返回true
498+ */
499+ bool GetPcieThroughFlag() const {
500+ const auto compute_node_info = GetComputeNodeInfo();
501+ if (compute_node_info == nullptr) {
502+ return false;
503+ }
504+ const size_t index = compute_node_info->GetInputsNum() + compute_node_info->GetOutputsNum();
505+ // 此处按照tiling内存排布,将PCIE Through的字段添加在
506+ // inputshape outputshape compileinfo platform tiling_func deterministic pcie_through之后
507+ const auto av = GetInput(index + 5U);
GengChao
GengChaoGengChaoAug 29

5有点魔鬼数字,加个注释 说明tilingcontext的排布

likedislike
kantao1
kantao1
Aug 29 Comments:
likedislike
508+ if (av == nullptr) {
509+ return false;
510+ }
511+ return av->GetValue<bool>();
512+ }
513+ 
495 /**514 /**
496 * 设置 local memory size, 默认值为0515 * 设置 local memory size, 默认值为0
497 * @param local_memory_size516 * @param local_memory_size
@@ -28,6 +28,7 @@ class InferSymbolShapeContext;
28class ExeResGenerationContext;28class ExeResGenerationContext;
29class OpCheckContext;29class OpCheckContext;
30#define OP_IMPL_MAIN_VERSION 230#define OP_IMPL_MAIN_VERSION 2
31+constexpr size_t kPcieThroughFlagIdx = 0U;
31struct OpImplKernelRegistry {32struct OpImplKernelRegistry {
32 // for other code repo, they use those alias, but will delete later33 // for other code repo, they use those alias, but will delete later
33 using InferShapeKernelFunc = UINT32 (*)(InferShapeContext *);34 using InferShapeKernelFunc = UINT32 (*)(InferShapeContext *);
@@ -201,6 +202,14 @@ struct OpImplKernelRegistry {
201 return ge::GRAPH_SUCCESS;202 return ge::GRAPH_SUCCESS;
202 }203 }
203 204 
205+ bool IsSupportPcieThrough() const {
206+ return reserved_[kPcieThroughFlagIdx] != 0U;
207+ }
208+ 
209+ void SetSupportPcieThrough() {
210+ reserved_[kPcieThroughFlagIdx] = 1U;
211+ }
212+ 
204 uint32_t st_size = sizeof(OpImplFunctionsV2);213 uint32_t st_size = sizeof(OpImplFunctionsV2);
205 uint32_t version = OP_IMPL_MAIN_VERSION;214 uint32_t version = OP_IMPL_MAIN_VERSION;
206 OpImplRegisterV2::OpCalcParamKernelFunc calc_op_param = nullptr;215 OpImplRegisterV2::OpCalcParamKernelFunc calc_op_param = nullptr;
@@ -32,7 +32,7 @@ namespace ge {
32class AnyValue;32class AnyValue;
33} // namespace ge33} // namespace ge
34 34 
35-//直接引入rts的头文件会引入额外的include path,导致用户侧代码编译失败,因此重新定义了rts头文件中的结构体35+// 直接引入rts的头文件会引入额外的include path,导致用户侧代码编译失败,因此重新定义了rts头文件中的结构体
36#ifdef __cplusplus36#ifdef __cplusplus
37extern "C" {37extern "C" {
38#endif38#endif
@@ -125,6 +125,7 @@ class OpImplRegisterV2 {
125 OpImplRegisterV2 &OpSelectFormat(OP_CHECK_FUNC_V2 op_select_format_func);125 OpImplRegisterV2 &OpSelectFormat(OP_CHECK_FUNC_V2 op_select_format_func);
126 OpImplRegisterV2 &ExceptionDumpParseFunc(ExceptionDumpFunc exception_func);126 OpImplRegisterV2 &ExceptionDumpParseFunc(ExceptionDumpFunc exception_func);
127 OpImplRegisterV2 &NullableOutputs(std::initializer_list<int32_t> outputs);127 OpImplRegisterV2 &NullableOutputs(std::initializer_list<int32_t> outputs);
128+ OpImplRegisterV2 &SetSupportPcieThrough();
128 129 
129 private:130 private:
130 OpImplRegisterV2 &TilingParse(KernelFunc tiling_parse_func, CompileInfoCreatorFunc creator_func,131 OpImplRegisterV2 &TilingParse(KernelFunc tiling_parse_func, CompileInfoCreatorFunc creator_func,
@@ -1040,3 +1040,61 @@ TEST_F(UtestContextBuilder, OpTilingContextBuilderCStyleApiTest) {
1040 EXPECT_EQ(ctx4->GetSimtGridDim()->y, grid_dim.y);1040 EXPECT_EQ(ctx4->GetSimtGridDim()->y, grid_dim.y);
1041 EXPECT_EQ(ctx4->GetSimtGridDim()->z, grid_dim.z);1041 EXPECT_EQ(ctx4->GetSimtGridDim()->z, grid_dim.z);
1042}1042}
1043+ 
1044+TEST_F(UtestContextBuilder, CreateTilingContext_GetPcieThroughFlag_true) {
1045+ auto workspace_size_holder = gert::ContinuousVector::Create<size_t>(4096);
1046+ auto ws_ptr = reinterpret_cast<gert::ContinuousVector *>(workspace_size_holder.get());
1047+ 
1048+ gert::StorageShape x({1, 1, 1, 1, 1}, {1, 1, 1, 1, 1});
1049+ gert::StorageShape result({10, 10, 10, 10, 20}, {10, 10, 10, 10, 20});
1050+ gert::Tensor x_tensor(x, {ge::FORMAT_NCDHW, ge::FORMAT_RESERVED, ExpandDimsType()}, TensorPlacement::kOnHost,
1051+ ge::DT_FLOAT, nullptr);
1052+ gert::Tensor result_tensor(result, {ge::FORMAT_NCDHW, ge::FORMAT_RESERVED, ExpandDimsType()},
1053+ TensorPlacement::kOnHost, ge::DT_FLOAT, nullptr);
1054+ 
1055+ auto tmp_tiling_data = gert::TilingData::CreateCap(100);
1056+ uint8_t tmp_compile_info[] = {1, 2, 3, 4, 5, 6, 7};
1057+ uint8_t tmp_platform_info[] = {1, 2, 3, 4, 5, 6, 7};
1058+ int32_t deterministic = 1;
1059+ 
1060+ OpTilingContextBuilder ctx_builder;
1061+ auto holder = ctx_builder.OpName("tmp")
1062+ .OpType("DIY")
1063+ .IONum(1, 1)
1064+ .TilingData(reinterpret_cast<gert::TilingData *>(tmp_tiling_data.get()))
1065+ .Workspace(ws_ptr)
1066+ .CompileInfo(tmp_compile_info)
1067+ .Deterministic(deterministic)
1068+ .PlatformInfo(tmp_platform_info)
1069+ .SetPcieThroughFlag(true)
1070+ .InputTensors({&x_tensor})
1071+ .OutputTensors({&result_tensor})
1072+ .Build();
1073+ 
1074+ auto ctx = holder.GetContext();
1075+ EXPECT_NE(ctx, nullptr);
1076+ EXPECT_TRUE(ctx->GetPcieThroughFlag());
1077+}
1078+ 
1079+TEST_F(UtestContextBuilder, GetPcieThroughFlag_NullComputeNodeInfo) {
1080+ KernelRunContext raw_ctx = {};
1081+ auto *ctx = reinterpret_cast<TilingContext *>(&raw_ctx);
1082+ EXPECT_FALSE(ctx->GetPcieThroughFlag());
1083+}
1084+ 
1085+TEST_F(UtestContextBuilder, GetPcieThroughFlag_InputOutOfRange) {
1086+ OpKernelContextBuilder ctx_builder;
1087+ gert::StorageShape shape0({1, 1}, {1, 1});
1088+ auto holder = ctx_builder.OpType("Add")
1089+ .OpName("add_1")
1090+ .IONum(2, 1)
1091+ .InputTensorDesc(0, ge::DT_FLOAT16, ge::FORMAT_ND, ge::FORMAT_ND)
1092+ .InputTensorDesc(1, ge::DT_FLOAT16, ge::FORMAT_ND, ge::FORMAT_ND)
1093+ .OutputTensorDesc(0, ge::DT_FLOAT16, ge::FORMAT_ND, ge::FORMAT_ND)
1094+ .Inputs({&shape0, &shape0})
1095+ .Outputs({&shape0})
1096+ .Build();
1097+ auto *ctx = reinterpret_cast<TilingContext *>(holder.GetContext());
1098+ ASSERT_NE(ctx, nullptr);
1099+ EXPECT_FALSE(ctx->GetPcieThroughFlag());
1100+}
@@ -179,6 +179,8 @@ TEST_F(OpImplRegistryUT, Register_Success_RegisterAll) {
179 179 
180 IMPL_OP(TestFoo_nullableOutputs).NullableOutputs({0, 1, 4, 128, 3});180 IMPL_OP(TestFoo_nullableOutputs).NullableOutputs({0, 1, 4, 128, 3});
181 181 
182+ IMPL_OP(TestFoo_SupportPcieThrough).SetSupportPcieThrough();
183+ 
182 funcs = gert::OpImplRegistry::GetInstance().GetOpImpl("TestFoo_tilingDepend");184 funcs = gert::OpImplRegistry::GetInstance().GetOpImpl("TestFoo_tilingDepend");
183 EXPECT_TRUE(funcs->IsTilingInputDataDependency(0U));185 EXPECT_TRUE(funcs->IsTilingInputDataDependency(0U));
184 EXPECT_TRUE(funcs->IsTilingInputDataDependency(1U));186 EXPECT_TRUE(funcs->IsTilingInputDataDependency(1U));
@@ -1003,4 +1005,34 @@ TEST_F(OpImplRegistryUT, GetOpImplFunctionsWithExceptionFuncTest) {
1003 }1005 }
1004 EXPECT_TRUE(found);1006 EXPECT_TRUE(found);
1005}1007}
1008+ 
1009+TEST_F(OpImplRegistryUT, Register_SetSupportPcieThrough_success) {
1010+ auto funcs = gert::OpImplRegistry::GetInstance().GetOpImpl("TestFooPcieThrough");
1011+ ASSERT_EQ(funcs, nullptr);
1012+ 
1013+ IMPL_OP(TestFooPcieThrough).InferShape(TestInferShapeFunc1).SetSupportPcieThrough();
1014+ 
1015+ funcs = gert::OpImplRegistry::GetInstance().GetOpImpl("TestFooPcieThrough");
1016+ ASSERT_NE(funcs, nullptr);
1017+ EXPECT_TRUE(funcs->IsSupportPcieThrough());
1018+}
1019+ 
1020+TEST_F(OpImplRegistryUT, Register_NotSetSupportPcieThrough_default_false) {
1021+ auto funcs = gert::OpImplRegistry::GetInstance().GetOpImpl("TestFooNoPcieThrough");
1022+ ASSERT_EQ(funcs, nullptr);
1023+ 
1024+ IMPL_OP(TestFooNoPcieThrough).InferShape(TestInferShapeFunc1);
1025+ 
1026+ funcs = gert::OpImplRegistry::GetInstance().GetOpImpl("TestFooNoPcieThrough");
1027+ ASSERT_NE(funcs, nullptr);
1028+ EXPECT_FALSE(funcs->IsSupportPcieThrough());
1029+}
1030+ 
1031+TEST_F(OpImplRegistryUT, OpImplFunctionsV2_PcieThroughFlag_UnitTest) {
1032+ gert::OpImplKernelRegistry::OpImplFunctionsV2 funcs;
1033+ EXPECT_FALSE(funcs.IsSupportPcieThrough());
1034+ funcs.SetSupportPcieThrough();
1035+ EXPECT_TRUE(funcs.IsSupportPcieThrough());
1036+ EXPECT_NE(funcs.reserved_[gert::kPcieThroughFlagIdx], 0U);
1037+}
1006} // namespace gert_test1038} // namespace gert_test
@@ -192,4 +192,22 @@ TEST_F(OpImplSpaceRegistryV2UT, DefaultOpImplSpaceRegistry_SetSpaceRegistry_Succ
192 EXPECT_NE(gert::DefaultOpImplSpaceRegistryV2::GetInstance().GetSpaceRegistry(), nullptr);192 EXPECT_NE(gert::DefaultOpImplSpaceRegistryV2::GetInstance().GetSpaceRegistry(), nullptr);
193 gert::DefaultOpImplSpaceRegistryV2::GetInstance().ClearSpaceRegistry();193 gert::DefaultOpImplSpaceRegistryV2::GetInstance().ClearSpaceRegistry();
194}194}
195+ 
196+TEST_F(OpImplSpaceRegistryV2UT, MergeFunctions_PcieThroughFlag_Succeed) {
197+ gert::OpImplSpaceRegistry space_registry;
198+ auto holder_a = std::make_shared<gert::OmOpImplRegistryHolder>();
199+ gert::OpImplKernelRegistry::OpImplFunctionsV2 funcs_a;
200+ holder_a->AddTypesToImpl("PcieThrough_merge", funcs_a);
201+ EXPECT_EQ(space_registry.AddRegistry(holder_a), ge::GRAPH_SUCCESS);
202+ 
203+ auto holder_b = std::make_shared<gert::OmOpImplRegistryHolder>();
204+ gert::OpImplKernelRegistry::OpImplFunctionsV2 funcs_b;
205+ funcs_b.SetSupportPcieThrough();
206+ holder_b->AddTypesToImpl("PcieThrough_merge", funcs_b);
207+ EXPECT_EQ(space_registry.AddRegistry(holder_b), ge::GRAPH_SUCCESS);
208+ 
209+ const auto *impl = space_registry.GetOpImpl("PcieThrough_merge");
210+ ASSERT_NE(impl, nullptr);
211+ EXPECT_TRUE(impl->IsSupportPcieThrough());
212+}
195} // namespace gert_test213} // namespace gert_test