已合并
feat: broadcast tiling 模板支持 PcieThrough 场景识别与 UB BRC 强制调度 #788
hahaha22创建于 25 天前
feat: broadcast tiling 模板支持 PcieThrough 场景识别与 UB BRC 强制调度 #788
已合并
hahaha22创建于 25 天前
2 个文件变更+41-4
@@ -131,6 +131,7 @@ if(BUILD_WITH_INSTALLED_DEPENDENCY_CANN_PKG)
131 $<BUILD_INTERFACE:error_manager_headers>131 $<BUILD_INTERFACE:error_manager_headers>
132 $<BUILD_INTERFACE:c_sec_headers>132 $<BUILD_INTERFACE:c_sec_headers>
133 $<BUILD_INTERFACE:asc_host_headers>133 $<BUILD_INTERFACE:asc_host_headers>
134+ $<BUILD_INTERFACE:cann_version_headers>
134 unified_dlog135 unified_dlog
135 )136 )
136 137 
@@ -17,6 +17,7 @@
17 17 
18#include "broadcast_tiling_base.h"18#include "broadcast_tiling_base.h"
19#include "broadcast_tiling_noncontiguous.h"19#include "broadcast_tiling_noncontiguous.h"
20+#include "version/metadef_version.h"
20 21 
21namespace Ops {22namespace Ops {
22namespace Base {23namespace Base {
@@ -107,6 +108,13 @@ public:
107 return ge::GRAPH_FAILED;108 return ge::GRAPH_FAILED;
108 }109 }
109 110 
111+ // 3. 获取PcieThrough信息
112+ status = GetPcieThroughInfo();
113+ if (status != ge::GRAPH_SUCCESS) {
114+ OP_LOGE(context_, "Get PcieThrough info failed.");
115+ return ge::GRAPH_FAILED;
116+ }
117+ 
110 BrcPrintShapes(inShapes, "inShapes");118 BrcPrintShapes(inShapes, "inShapes");
111 BrcPrintShape(outShape, "outShape");119 BrcPrintShape(outShape, "outShape");
112 BrcPrintStrides(inStrides, "inStrides");120 BrcPrintStrides(inStrides, "inStrides");
@@ -122,7 +130,7 @@ public:
122 OP_LOGI(context_->GetNodeName(), "coreNum: %llu, ubSize: %llu, inputAllContiguous:%d", coreNum, ubSize,130 OP_LOGI(context_->GetNodeName(), "coreNum: %llu, ubSize: %llu, inputAllContiguous:%d", coreNum, ubSize,
123 inputAllContiguous);131 inputAllContiguous);
124 132 
125- // 3. 合轴133+ // 4. 合轴
126 status = DoDimensionCollapse(broadcastTilingParams, tilingData);134 status = DoDimensionCollapse(broadcastTilingParams, tilingData);
127 if (status != ge::GRAPH_SUCCESS) {135 if (status != ge::GRAPH_SUCCESS) {
128 OP_LOGE(context_, "dimension collapse failed.");136 OP_LOGE(context_, "dimension collapse failed.");
@@ -132,10 +140,10 @@ public:
132 BrcPrintVectors(tilingData.dims, "after DoDimensionCollapse in&out dims");140 BrcPrintVectors(tilingData.dims, "after DoDimensionCollapse in&out dims");
133 BrcPrintVectors(tilingData.strides, "after DoDimensionCollapse in&out strides");141 BrcPrintVectors(tilingData.strides, "after DoDimensionCollapse in&out strides");
134 142 
135- // 4. 根据轴信息判断是否走onedim分支143+ // 5. 根据轴信息判断是否走onedim分支
136 OP_CHECK_IF((tilingData.dims.back().size() == 0),144 OP_CHECK_IF((tilingData.dims.back().size() == 0),
137 OP_LOGE(context_->GetNodeName(), "tensor check is empty, check failed"), return ge::GRAPH_FAILED);145 OP_LOGE(context_->GetNodeName(), "tensor check is empty, check failed"), return ge::GRAPH_FAILED);
138- if (tilingData.dims.back().size() == 1 && broadcastTilingParams.inputAllContiguous) {146+ if (tilingData.dims.back().size() == 1 && broadcastTilingParams.inputAllContiguous && !isPcieThrough) {
139 if constexpr ((OpDag::InputSize + OpDag::OutputSize <= MAX_IN_OUT_ARGS_NUMBER) && OpDag::VarSize <= 0) {147 if constexpr ((OpDag::InputSize + OpDag::OutputSize <= MAX_IN_OUT_ARGS_NUMBER) && OpDag::VarSize <= 0) {
140 status = DoOneDimOpTilingAdvance();148 status = DoOneDimOpTilingAdvance();
141 } else {149 } else {
@@ -247,6 +255,27 @@ private:
247 return ge::GRAPH_SUCCESS;255 return ge::GRAPH_SUCCESS;
248 }256 }
249 257 
258+ /**
259+ * 判断是否PcieThrough
260+ * @return
261+ */
262+ ge::graphStatus GetPcieThroughInfo()
263+ {
264+#if defined(METADEF_VERSION_NUM) && METADEF_VERSION_NUM >= 90200000
265+ isPcieThrough = context_->GetPcieThroughFlag();
266+ OP_LOGD(context_->GetNodeName(), "IsPcieThrough: %s", (isPcieThrough ? "true" : "false"));
267+#else
268+ isPcieThrough = false;
269+ OP_LOGD(context_->GetNodeName(), "IsPcieThrough: false");
270+#endif
271+ // 非连续模板不支持PCIE Through场景
272+ if (isPcieThrough && !inputAllContiguous) {
273+ OP_LOGE(context_, "PcieThrough not support noncontiguous.");
274+ return ge::GRAPH_FAILED;
275+ }
276+ return ge::GRAPH_SUCCESS;
277+ }
278+ 
250 /**279 /**
251 * 获取输入输出shape280 * 获取输入输出shape
252 * @return281 * @return
@@ -536,7 +565,13 @@ private:
536 // 1、判断ubbrc用到 2、设置copyIn参数用到565 // 1、判断ubbrc用到 2、设置copyIn参数用到
537 GetCopyInBrcPosList();566 GetCopyInBrcPosList();
538 567 
539- bool isUbBroadcast = IsUbBroadcast();568+ bool isUbBroadcast;
569+ if (isPcieThrough) {
570+ isUbBroadcast = true;
571+ } else {
572+ isUbBroadcast = IsUbBroadcast();
573+ }
574+ 
540 int64_t bufferNum = GetBufferNum(isUbBroadcast);575 int64_t bufferNum = GetBufferNum(isUbBroadcast);
541 OP_LOGI(context_->GetNodeName(), "Broadcast DoBroadcastOpTiling. isUbBroadcast: %d bufferNum: %ld ",576 OP_LOGI(context_->GetNodeName(), "Broadcast DoBroadcastOpTiling. isUbBroadcast: %d bufferNum: %ld ",
542 isUbBroadcast, bufferNum);577 isUbBroadcast, bufferNum);
@@ -1103,6 +1138,7 @@ private:
1103 std::vector<gert::Shape> inShapes;1138 std::vector<gert::Shape> inShapes;
1104 std::vector<bool> inputIsContiguous;1139 std::vector<bool> inputIsContiguous;
1105 std::vector<gert::Stride> inStrides;1140 std::vector<gert::Stride> inStrides;
1141+ bool isPcieThrough = false;
1106 bool inputAllContiguous = true;1142 bool inputAllContiguous = true;
1107 gert::Shape outShape;1143 gert::Shape outShape;
1108 gert::Stride outStride;1144 gert::Stride outStride;