已合并
【fix】: 修复Rand构图问题 #1964
【fix】: 修复Rand构图问题 #1964
已合并
liyuewei创建于 9月4日
共 4 个文件变更+17-11
@@ -1028,7 +1028,8 @@ af::Status DefaultMTE3Api([[maybe_unused]] const std::vector<TensorShapeInfo> &i
1028af::Status DefaultVECApi([[maybe_unused]] const std::vector<TensorShapeInfo> &input_shapes,1028af::Status DefaultVECApi([[maybe_unused]] const std::vector<TensorShapeInfo> &input_shapes,
1029 [[maybe_unused]] const std::vector<TensorShapeInfo> &output_shapes,1029 [[maybe_unused]] const std::vector<TensorShapeInfo> &output_shapes,
1030 [[maybe_unused]] const NodeInfo &node, PerfOutputInfo &perf_res) {1030 [[maybe_unused]] const NodeInfo &node, PerfOutputInfo &perf_res) {
1031- GE_ASSERT_TRUE(!input_shapes.empty() && !output_shapes.empty());1031+ // rand/randn have no input shape, so check output shape only
1032+ GE_ASSERT_TRUE(!output_shapes.empty());
1032 perf_res.pipe_res[PipeType::AIV_VEC] = af::sym::kSymbolOne;1033 perf_res.pipe_res[PipeType::AIV_VEC] = af::sym::kSymbolOne;
1033 return af::SUCCESS;1034 return af::SUCCESS;
1034}1035}
@@ -133,8 +133,8 @@ static const std::map<std::string, af::ComputeType> kOpTypeToComputeType = {
133 {Scalar::Type, af::ComputeType::kComputeInvalid},133 {Scalar::Type, af::ComputeType::kComputeInvalid},
134 {Output::Type, af::ComputeType::kComputeInvalid},134 {Output::Type, af::ComputeType::kComputeInvalid},
135 {IndexExpr::Type, af::ComputeType::kComputeInvalid},135 {IndexExpr::Type, af::ComputeType::kComputeInvalid},
136- {"Rand", af::ComputeType::kComputeInvalid},136+ {Rand::Type, af::ComputeType::kComputeElewise},
137- {"Randn", af::ComputeType::kComputeInvalid},137+ {Randn::Type, af::ComputeType::kComputeElewise},
138 138 
139 {Load::Type, af::ComputeType::kComputeLoad},139 {Load::Type, af::ComputeType::kComputeLoad},
140 {Store::Type, af::ComputeType::kComputeStore},140 {Store::Type, af::ComputeType::kComputeStore},
@@ -13346,13 +13346,22 @@ static void CreateRandStoreAscGraph(af::AscGraph &graph, size_t dims_size) {
13346 *rand_op.y.repeats = {s0};13346 *rand_op.y.repeats = {s0};
13347 *rand_op.y.strides = {One};13347 *rand_op.y.strides = {One};
13348 13348 
13349- rand_op.attr.api.compute_type = af::ComputeType::kComputeElewise;
13350- rand_op.attr.api.type = af::ApiType::kAPITypeCompute;
13351- rand_op.attr.api.unit = af::ComputeUnit::kUnitVector;
13352 rand_op.attr.sched.axis = {z0.id};13349 rand_op.attr.sched.axis = {z0.id};
13353 13350 
13351+ af::ascir_op::Abs abs_op("abs");
13352+ graph.AddNode(abs_op);
13353+ abs_op.x = rand_op.y;
13354+ *abs_op.y.axis = {z0.id};
13355+ *abs_op.y.repeats = {s0};
13356+ *abs_op.y.strides = {One};
13357+ 
13358+ abs_op.attr.api.compute_type = af::ComputeType::kComputeElewise;
13359+ abs_op.attr.api.type = af::ApiType::kAPITypeCompute;
13360+ abs_op.attr.api.unit = af::ComputeUnit::kUnitVector;
13361+ abs_op.attr.sched.axis = {z0.id};
13362+ 
13354 af::ascir_op::Store store("store");13363 af::ascir_op::Store store("store");
13355- store.x = rand_op.y;13364+ store.x = abs_op.y;
13356 store.attr.api.compute_type = ComputeType::kComputeStore;13365 store.attr.api.compute_type = ComputeType::kComputeStore;
13357 store.attr.api.type = af::ApiType::kAPITypeCompute;13366 store.attr.api.type = af::ApiType::kAPITypeCompute;
13358 store.attr.api.unit = ComputeUnit::kUnitMTE3;13367 store.attr.api.unit = ComputeUnit::kUnitMTE3;
@@ -56,10 +56,6 @@ TEST_P(E2E_FusedBackendElewise_Code, CalculateCorrect) {
56 // Launch56 // Launch
57 uint32_t ws_size = 0;57 uint32_t ws_size = 0;
58 AutofuseTiling(test_shape[0], test_shape[1], &tiling_data, &ws_size, &block_dim, 48, 192 * 1024);58 AutofuseTiling(test_shape[0], test_shape[1], &tiling_data, &ws_size, &block_dim, 48, 192 * 1024);
59- printf("g0_tiling_key: %d\n", tiling_data.graph0_tiling_key);
60- printf("g1_tiling_key: %d\n", tiling_data.graph1_tiling_key);
61- printf("g2_tiling_key: %d\n", tiling_data.graph2_tiling_key);
62- printf("ws_size: %d, ws3_size: %d, ws5_size: %d\n", ws_size, tiling_data.workspace3, tiling_data.workspace5);
63 float *workspace = (float *)AscendC::GmAlloc(ws_size + 32);59 float *workspace = (float *)AscendC::GmAlloc(ws_size + 32);
64 60 
65 AscendC::SetKernelMode(KernelMode::AIV_MODE);61 AscendC::SetKernelMode(KernelMode::AIV_MODE);