已合并
range等算子资料更新 #697
蒋雨龙创建于 1月8日
range等算子资料更新 #697
已合并
蒋雨龙创建于 1月8日
22 个文件变更+450-1159
Dmath/adjacent_difference/op_graph/fusion_pass/.gitkeep+0-0
The file is empty
Mmath/adjacent_difference/tests/ut/op_host/test_adjacent_difference_infershape.cpp+101-92
@@ -18,8 +18,7 @@
18#include "infershape_context_faker.h"18#include "infershape_context_faker.h"
19#include "infershape_case_executor.h"19#include "infershape_case_executor.h"
20 20 
21-class AdjacentDifferenceInfershape : public testing::Test21+class AdjacentDifferenceInfershape : public testing::Test {
22-{
23protected:22protected:
24 static void SetUpTestCase()23 static void SetUpTestCase()
25 {24 {
@@ -33,141 +32,151 @@ protected:
33};32};
34 33 
35// Test: adjacent_difference infershape with float3234// Test: adjacent_difference infershape with float32
36-TEST_F(AdjacentDifferenceInfershape, adjacent_difference_infershape_float32) {35+TEST_F(AdjacentDifferenceInfershape, adjacent_difference_infershape_float32)
37- gert::InfershapeContextPara infershapeContextPara("AdjacentDifference",36+{
38- {37+ gert::InfershapeContextPara infershapeContextPara(
39- {{{4, 3, 4}, {4, 3, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},38+ "AdjacentDifference",
40- },39+ {
41- {40+ {{{4, 3, 4}, {4, 3, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},
42- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},41+ },
43- }42+ {
44- );43+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},
44+ });
45 std::vector<std::vector<int64_t>> expectOutputShape = {{4, 3, 4}};45 std::vector<std::vector<int64_t>> expectOutputShape = {{4, 3, 4}};
46 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);46 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
47}47}
48 48 
49// Test: adjacent_difference infershape with float1649// Test: adjacent_difference infershape with float16
50-TEST_F(AdjacentDifferenceInfershape, adjacent_difference_infershape_float16) {50+TEST_F(AdjacentDifferenceInfershape, adjacent_difference_infershape_float16)
51- gert::InfershapeContextPara infershapeContextPara("AdjacentDifference",51+{
52- {52+ gert::InfershapeContextPara infershapeContextPara(
53- {{{10, 20}, {10, 20}}, ge::DT_FLOAT16, ge::FORMAT_ND},53+ "AdjacentDifference",
54- },54+ {
55- {55+ {{{10, 20}, {10, 20}}, ge::DT_FLOAT16, ge::FORMAT_ND},
56- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},56+ },
57- }57+ {
58- );58+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
59+ });
59 std::vector<std::vector<int64_t>> expectOutputShape = {{10, 20}};60 std::vector<std::vector<int64_t>> expectOutputShape = {{10, 20}};
60 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);61 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
61}62}
62 63 
63// Test: adjacent_difference infershape with int3264// Test: adjacent_difference infershape with int32
64-TEST_F(AdjacentDifferenceInfershape, adjacent_difference_infershape_int32) {65+TEST_F(AdjacentDifferenceInfershape, adjacent_difference_infershape_int32)
65- gert::InfershapeContextPara infershapeContextPara("AdjacentDifference",66+{
66- {67+ gert::InfershapeContextPara infershapeContextPara(
67- {{{100}, {100}}, ge::DT_INT32, ge::FORMAT_ND},68+ "AdjacentDifference",
68- },69+ {
69- {70+ {{{100}, {100}}, ge::DT_INT32, ge::FORMAT_ND},
70- {{{}, {}}, ge::DT_INT32, ge::FORMAT_ND},71+ },
71- }72+ {
72- );73+ {{{}, {}}, ge::DT_INT32, ge::FORMAT_ND},
74+ });
73 std::vector<std::vector<int64_t>> expectOutputShape = {{100}};75 std::vector<std::vector<int64_t>> expectOutputShape = {{100}};
74 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);76 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
75}77}
76 78 
77// Test: adjacent_difference infershape with int6479// Test: adjacent_difference infershape with int64
78-TEST_F(AdjacentDifferenceInfershape, adjacent_difference_infershape_int64) {80+TEST_F(AdjacentDifferenceInfershape, adjacent_difference_infershape_int64)
79- gert::InfershapeContextPara infershapeContextPara("AdjacentDifference",81+{
80- {82+ gert::InfershapeContextPara infershapeContextPara(
81- {{{50, 50}, {50, 50}}, ge::DT_INT64, ge::FORMAT_ND},83+ "AdjacentDifference",
82- },84+ {
83- {85+ {{{50, 50}, {50, 50}}, ge::DT_INT64, ge::FORMAT_ND},
84- {{{}, {}}, ge::DT_INT64, ge::FORMAT_ND},86+ },
85- }87+ {
86- );88+ {{{}, {}}, ge::DT_INT64, ge::FORMAT_ND},
89+ });
87 std::vector<std::vector<int64_t>> expectOutputShape = {{50, 50}};90 std::vector<std::vector<int64_t>> expectOutputShape = {{50, 50}};
88 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);91 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
89}92}
90 93 
91// Test: adjacent_difference infershape with bfloat1694// Test: adjacent_difference infershape with bfloat16
92-TEST_F(AdjacentDifferenceInfershape, adjacent_difference_infershape_bfloat16) {95+TEST_F(AdjacentDifferenceInfershape, adjacent_difference_infershape_bfloat16)
93- gert::InfershapeContextPara infershapeContextPara("AdjacentDifference",96+{
94- {97+ gert::InfershapeContextPara infershapeContextPara(
95- {{{8, 16}, {8, 16}}, ge::DT_BF16, ge::FORMAT_ND},98+ "AdjacentDifference",
96- },99+ {
97- {100+ {{{8, 16}, {8, 16}}, ge::DT_BF16, ge::FORMAT_ND},
98- {{{}, {}}, ge::DT_BF16, ge::FORMAT_ND},101+ },
99- }102+ {
100- );103+ {{{}, {}}, ge::DT_BF16, ge::FORMAT_ND},
104+ });
101 std::vector<std::vector<int64_t>> expectOutputShape = {{8, 16}};105 std::vector<std::vector<int64_t>> expectOutputShape = {{8, 16}};
102 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);106 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
103}107}
104 108 
105// Test: adjacent_difference infershape with int8109// Test: adjacent_difference infershape with int8
106-TEST_F(AdjacentDifferenceInfershape, adjacent_difference_infershape_int8) {110+TEST_F(AdjacentDifferenceInfershape, adjacent_difference_infershape_int8)
107- gert::InfershapeContextPara infershapeContextPara("AdjacentDifference",111+{
108- {112+ gert::InfershapeContextPara infershapeContextPara(
109- {{{32, 64}, {32, 64}}, ge::DT_INT8, ge::FORMAT_ND},113+ "AdjacentDifference",
110- },114+ {
111- {115+ {{{32, 64}, {32, 64}}, ge::DT_INT8, ge::FORMAT_ND},
112- {{{}, {}}, ge::DT_INT8, ge::FORMAT_ND},116+ },
113- }117+ {
114- );118+ {{{}, {}}, ge::DT_INT8, ge::FORMAT_ND},
119+ });
115 std::vector<std::vector<int64_t>> expectOutputShape = {{32, 64}};120 std::vector<std::vector<int64_t>> expectOutputShape = {{32, 64}};
116 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);121 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
117}122}
118 123 
119// Test: adjacent_difference infershape with uint8124// Test: adjacent_difference infershape with uint8
120-TEST_F(AdjacentDifferenceInfershape, adjacent_difference_infershape_uint8) {125+TEST_F(AdjacentDifferenceInfershape, adjacent_difference_infershape_uint8)
121- gert::InfershapeContextPara infershapeContextPara("AdjacentDifference",126+{
122- {127+ gert::InfershapeContextPara infershapeContextPara(
123- {{{32, 64}, {32, 64}}, ge::DT_UINT8, ge::FORMAT_ND},128+ "AdjacentDifference",
124- },129+ {
125- {130+ {{{32, 64}, {32, 64}}, ge::DT_UINT8, ge::FORMAT_ND},
126- {{{}, {}}, ge::DT_UINT8, ge::FORMAT_ND},131+ },
127- }132+ {
128- );133+ {{{}, {}}, ge::DT_UINT8, ge::FORMAT_ND},
134+ });
129 std::vector<std::vector<int64_t>> expectOutputShape = {{32, 64}};135 std::vector<std::vector<int64_t>> expectOutputShape = {{32, 64}};
130 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);136 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
131}137}
132 138 
133// Test: adjacent_difference infershape with 3D tensor139// Test: adjacent_difference infershape with 3D tensor
134-TEST_F(AdjacentDifferenceInfershape, adjacent_difference_infershape_3d) {140+TEST_F(AdjacentDifferenceInfershape, adjacent_difference_infershape_3d)
135- gert::InfershapeContextPara infershapeContextPara("AdjacentDifference",141+{
136- {142+ gert::InfershapeContextPara infershapeContextPara(
137- {{{4, 5, 6}, {4, 5, 6}}, ge::DT_FLOAT, ge::FORMAT_ND},143+ "AdjacentDifference",
138- },144+ {
139- {145+ {{{4, 5, 6}, {4, 5, 6}}, ge::DT_FLOAT, ge::FORMAT_ND},
140- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},146+ },
141- }147+ {
142- );148+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},
149+ });
143 std::vector<std::vector<int64_t>> expectOutputShape = {{4, 5, 6}};150 std::vector<std::vector<int64_t>> expectOutputShape = {{4, 5, 6}};
144 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);151 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
145}152}
146 153 
147// Test: adjacent_difference infershape with small 1D tensor154// Test: adjacent_difference infershape with small 1D tensor
148-TEST_F(AdjacentDifferenceInfershape, adjacent_difference_infershape_small_1d) {155+TEST_F(AdjacentDifferenceInfershape, adjacent_difference_infershape_small_1d)
149- gert::InfershapeContextPara infershapeContextPara("AdjacentDifference",156+{
150- {157+ gert::InfershapeContextPara infershapeContextPara(
151- {{{5}, {5}}, ge::DT_FLOAT, ge::FORMAT_ND},158+ "AdjacentDifference",
152- },159+ {
153- {160+ {{{5}, {5}}, ge::DT_FLOAT, ge::FORMAT_ND},
154- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},161+ },
155- }162+ {
156- );163+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},
164+ });
157 std::vector<std::vector<int64_t>> expectOutputShape = {{5}};165 std::vector<std::vector<int64_t>> expectOutputShape = {{5}};
158 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);166 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
159}167}
160 168 
161// Test: adjacent_difference infershape with NHWC format169// Test: adjacent_difference infershape with NHWC format
162-TEST_F(AdjacentDifferenceInfershape, adjacent_difference_infershape_nhwc) {170+TEST_F(AdjacentDifferenceInfershape, adjacent_difference_infershape_nhwc)
163- gert::InfershapeContextPara infershapeContextPara("AdjacentDifference",171+{
164- {172+ gert::InfershapeContextPara infershapeContextPara(
165- {{{1, 16, 16, 3}, {1, 16, 16, 3}}, ge::DT_FLOAT, ge::FORMAT_NHWC},173+ "AdjacentDifference",
166- },174+ {
167- {175+ {{{1, 16, 16, 3}, {1, 16, 16, 3}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
168- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},176+ },
169- }177+ {
170- );178+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
179+ });
171 std::vector<std::vector<int64_t>> expectOutputShape = {{1, 16, 16, 3}};180 std::vector<std::vector<int64_t>> expectOutputShape = {{1, 16, 16, 3}};
172 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);181 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
173}182}
Mmath/mod/docs/aclnnFmodScalar&aclnnInplaceFmodScalar.md+1-0
@@ -4,6 +4,7 @@
4 4 
5| 产品 | 是否支持 |5| 产品 | 是否支持 |
6| :----------------------------------------------------------- | :------: |6| :----------------------------------------------------------- | :------: |
7+| <term>Ascend 950PR/Ascend 950DT</term> | √ |
7| <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term> | √ |8| <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term> | √ |
8| <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term> | √ |9| <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term> | √ |
9 10 
Mmath/mod/docs/aclnnFmodTensor&aclnnInplaceFmodTensor.md+1-0
@@ -4,6 +4,7 @@
4 4 
5| 产品 | 是否支持 |5| 产品 | 是否支持 |
6| :----------------------------------------------------------- | :------: |6| :----------------------------------------------------------- | :------: |
7+| <term>Ascend 950PR/Ascend 950DT</term> | √ |
7| <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term> | √ |8| <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term> | √ |
8| <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term> | √ |9| <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term> | √ |
9 10 
Dmath/mod/op_graph/fusion_pass/.gitkeep+0-0
The file is empty
Dmath/mod/op_graph/graph_plugin/mod_proto.h+0-55
@@ -1,55 +0,0 @@
1-/**
2- * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3- * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4- * CANN Open Software License Agreement Version 2.0 (the "License").
5- * Please refer to the License for details. You may not use this file except in compliance with the License.
6- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7- * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8- * See LICENSE in the root of the software repository for the full text of the License.
9- */
10- 
11-/*!
12- * \file mod_proto.h
13- * \brief
14- */
15-#ifndef OPS_OP_PROTO_INC_MOD_H_
16-#define OPS_OP_PROTO_INC_MOD_H_
17- 
18-#include "graph/operator_reg.h"
19-#include "graph/types.h"
20- 
21-namespace ge {
22- 
23-/**
24-* @brief Returns element-wise remainder of division. Support broadcasting operations.
25- 
26-* @par Inputs:
27-* Two inputs, including:
28-* @li x1: A ND tensor. Must be one of the following types: bfloat16, float16, float32,
29-* int32, int64, int8, uint8, double.
30-* @li x2: A ND tensor of the same dtype as "x1". \n
31- 
32-* @par Outputs:
33-* y: A ND tensor. Has the same dtype as "x1". \n
34- 
35-* @attention Constraints:
36-* @li x2: The input data does not support 0.
37-* @li When NUM exceeds 2048 , the accuracy of operator cannot guarantee the
38-* requirement of double thousandths in the mini form.
39-* @li Due to different architectures, the calculation results of this operator
40-* on NPU and CPU may be inconsistent.
41-* @li If shape is expressed as (D1,D2... ,Dn),
42-* then D1*D2... *DN<=1000000,n<=8. \n
43- 
44-* @par Third-party framework compatibility:
45-* Compatible with the TensorFlow operator Mod.
46-*/
47-REG_OP(Mod)
48- .INPUT(x1, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_UINT8, DT_INT64, DT_DOUBLE, DT_BF16}))
49- .INPUT(x2, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_UINT8, DT_INT64, DT_DOUBLE, DT_BF16}))
50- .OUTPUT(y, TensorType({DT_FLOAT16, DT_FLOAT, DT_INT32, DT_INT8, DT_UINT8, DT_INT64, DT_DOUBLE, DT_BF16}))
51- .OP_END_FACTORY_REG(Mod)
52- 
53-} // namespace ge
54- 
55-#endif // OPS_OP_PROTO_INC_MOD_H_
Mmath/mod/tests/ut/op_host/arch35/test_mod_tiling_arch35.cpp+32-17
@@ -37,9 +37,11 @@ protected:
37};37};
38 38 
39// Test: mod tiling with float3239// Test: mod tiling with float32
40-TEST_F(ModTilingTest, test_tiling_float32) {40+TEST_F(ModTilingTest, test_tiling_float32)
41+{
41 BroadcastCompileInfo compileInfo{};42 BroadcastCompileInfo compileInfo{};
42- gert::TilingContextPara tilingContextPara("Mod",43+ gert::TilingContextPara tilingContextPara(
44+ "Mod",
43 {45 {
44 {{{1, 64, 2, 64}, {1, 64, 2, 64}}, ge::DT_FLOAT, ge::FORMAT_ND},46 {{{1, 64, 2, 64}, {1, 64, 2, 64}}, ge::DT_FLOAT, ge::FORMAT_ND},
45 {{{1, 64, 2, 64}, {1, 64, 2, 64}}, ge::DT_FLOAT, ge::FORMAT_ND},47 {{{1, 64, 2, 64}, {1, 64, 2, 64}}, ge::DT_FLOAT, ge::FORMAT_ND},
@@ -56,9 +58,11 @@ TEST_F(ModTilingTest, test_tiling_float32) {
56}58}
57 59 
58// Test: mod tiling with float1660// Test: mod tiling with float16
59-TEST_F(ModTilingTest, test_tiling_float16) {61+TEST_F(ModTilingTest, test_tiling_float16)
62+{
60 BroadcastCompileInfo compileInfo{};63 BroadcastCompileInfo compileInfo{};
61- gert::TilingContextPara tilingContextPara("Mod",64+ gert::TilingContextPara tilingContextPara(
65+ "Mod",
62 {66 {
63 {{{1, 32, 4, 32}, {1, 32, 4, 32}}, ge::DT_FLOAT16, ge::FORMAT_ND},67 {{{1, 32, 4, 32}, {1, 32, 4, 32}}, ge::DT_FLOAT16, ge::FORMAT_ND},
64 {{{1, 32, 4, 32}, {1, 32, 4, 32}}, ge::DT_FLOAT16, ge::FORMAT_ND},68 {{{1, 32, 4, 32}, {1, 32, 4, 32}}, ge::DT_FLOAT16, ge::FORMAT_ND},
@@ -75,9 +79,11 @@ TEST_F(ModTilingTest, test_tiling_float16) {
75}79}
76 80 
77// Test: mod tiling with int3281// Test: mod tiling with int32
78-TEST_F(ModTilingTest, test_tiling_int32) {82+TEST_F(ModTilingTest, test_tiling_int32)
83+{
79 BroadcastCompileInfo compileInfo{};84 BroadcastCompileInfo compileInfo{};
80- gert::TilingContextPara tilingContextPara("Mod",85+ gert::TilingContextPara tilingContextPara(
86+ "Mod",
81 {87 {
82 {{{1, 64, 2, 64}, {1, 64, 2, 64}}, ge::DT_INT32, ge::FORMAT_ND},88 {{{1, 64, 2, 64}, {1, 64, 2, 64}}, ge::DT_INT32, ge::FORMAT_ND},
83 {{{1, 64, 2, 64}, {1, 64, 2, 64}}, ge::DT_INT32, ge::FORMAT_ND},89 {{{1, 64, 2, 64}, {1, 64, 2, 64}}, ge::DT_INT32, ge::FORMAT_ND},
@@ -93,11 +99,12 @@ TEST_F(ModTilingTest, test_tiling_int32) {
93 ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectTilingData, expectWorkspaces);99 ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectTilingData, expectWorkspaces);
94}100}
95 101 
96- 
97// Test: mod tiling with broadcast102// Test: mod tiling with broadcast
98-TEST_F(ModTilingTest, test_tiling_broadcast) {103+TEST_F(ModTilingTest, test_tiling_broadcast)
104+{
99 BroadcastCompileInfo compileInfo{};105 BroadcastCompileInfo compileInfo{};
100- gert::TilingContextPara tilingContextPara("Mod",106+ gert::TilingContextPara tilingContextPara(
107+ "Mod",
101 {108 {
102 {{{1, 64, 2, 64}, {1, 64, 2, 64}}, ge::DT_FLOAT, ge::FORMAT_ND},109 {{{1, 64, 2, 64}, {1, 64, 2, 64}}, ge::DT_FLOAT, ge::FORMAT_ND},
103 {{{1, 1, 1, 1}, {1, 1, 1, 1}}, ge::DT_FLOAT, ge::FORMAT_ND},110 {{{1, 1, 1, 1}, {1, 1, 1, 1}}, ge::DT_FLOAT, ge::FORMAT_ND},
@@ -113,9 +120,11 @@ TEST_F(ModTilingTest, test_tiling_broadcast) {
113}120}
114 121 
115// Test: mod tiling with small shape122// Test: mod tiling with small shape
116-TEST_F(ModTilingTest, test_tiling_small_shape) {123+TEST_F(ModTilingTest, test_tiling_small_shape)
124+{
117 BroadcastCompileInfo compileInfo{};125 BroadcastCompileInfo compileInfo{};
118- gert::TilingContextPara tilingContextPara("Mod",126+ gert::TilingContextPara tilingContextPara(
127+ "Mod",
119 {128 {
120 {{{2, 3}, {2, 3}}, ge::DT_FLOAT, ge::FORMAT_ND},129 {{{2, 3}, {2, 3}}, ge::DT_FLOAT, ge::FORMAT_ND},
121 {{{2, 3}, {2, 3}}, ge::DT_FLOAT, ge::FORMAT_ND},130 {{{2, 3}, {2, 3}}, ge::DT_FLOAT, ge::FORMAT_ND},
@@ -131,9 +140,11 @@ TEST_F(ModTilingTest, test_tiling_small_shape) {
131}140}
132 141 
133// Test: mod tiling with large shape142// Test: mod tiling with large shape
134-TEST_F(ModTilingTest, test_tiling_large_shape) {143+TEST_F(ModTilingTest, test_tiling_large_shape)
144+{
135 BroadcastCompileInfo compileInfo{};145 BroadcastCompileInfo compileInfo{};
136- gert::TilingContextPara tilingContextPara("Mod",146+ gert::TilingContextPara tilingContextPara(
147+ "Mod",
137 {148 {
138 {{{16, 128, 16, 128}, {16, 128, 16, 128}}, ge::DT_FLOAT, ge::FORMAT_ND},149 {{{16, 128, 16, 128}, {16, 128, 16, 128}}, ge::DT_FLOAT, ge::FORMAT_ND},
139 {{{16, 128, 16, 128}, {16, 128, 16, 128}}, ge::DT_FLOAT, ge::FORMAT_ND},150 {{{16, 128, 16, 128}, {16, 128, 16, 128}}, ge::DT_FLOAT, ge::FORMAT_ND},
@@ -149,9 +160,11 @@ TEST_F(ModTilingTest, test_tiling_large_shape) {
149}160}
150 161 
151// Test: mod tiling with 1D shape162// Test: mod tiling with 1D shape
152-TEST_F(ModTilingTest, test_tiling_1d) {163+TEST_F(ModTilingTest, test_tiling_1d)
164+{
153 BroadcastCompileInfo compileInfo{};165 BroadcastCompileInfo compileInfo{};
154- gert::TilingContextPara tilingContextPara("Mod",166+ gert::TilingContextPara tilingContextPara(
167+ "Mod",
155 {168 {
156 {{{1000}, {1000}}, ge::DT_FLOAT, ge::FORMAT_ND},169 {{{1000}, {1000}}, ge::DT_FLOAT, ge::FORMAT_ND},
157 {{{1000}, {1000}}, ge::DT_FLOAT, ge::FORMAT_ND},170 {{{1000}, {1000}}, ge::DT_FLOAT, ge::FORMAT_ND},
@@ -167,9 +180,11 @@ TEST_F(ModTilingTest, test_tiling_1d) {
167}180}
168 181 
169// Test: mod tiling with NHWC format182// Test: mod tiling with NHWC format
170-TEST_F(ModTilingTest, test_tiling_nhwc) {183+TEST_F(ModTilingTest, test_tiling_nhwc)
184+{
171 BroadcastCompileInfo compileInfo{};185 BroadcastCompileInfo compileInfo{};
172- gert::TilingContextPara tilingContextPara("Mod",186+ gert::TilingContextPara tilingContextPara(
187+ "Mod",
173 {188 {
174 {{{1, 16, 16, 3}, {1, 16, 16, 3}}, ge::DT_FLOAT, ge::FORMAT_NHWC},189 {{{1, 16, 16, 3}, {1, 16, 16, 3}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
175 {{{1, 16, 16, 3}, {1, 16, 16, 3}}, ge::DT_FLOAT, ge::FORMAT_NHWC},190 {{{1, 16, 16, 3}, {1, 16, 16, 3}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
Mmath/mod/tests/ut/op_host/test_mod_infershape.cpp+111-102
@@ -18,8 +18,7 @@
18#include "infershape_context_faker.h"18#include "infershape_context_faker.h"
19#include "infershape_case_executor.h"19#include "infershape_case_executor.h"
20 20 
21-class ModInfershape : public testing::Test21+class ModInfershape : public testing::Test {
22-{
23protected:22protected:
24 static void SetUpTestCase()23 static void SetUpTestCase()
25 {24 {
@@ -33,151 +32,161 @@ protected:
33};32};
34 33 
35// Test: mod infershape with same shape34// Test: mod infershape with same shape
36-TEST_F(ModInfershape, mod_infershape_same_shape) {35+TEST_F(ModInfershape, mod_infershape_same_shape)
37- gert::InfershapeContextPara infershapeContextPara("Mod",36+{
38- {37+ gert::InfershapeContextPara infershapeContextPara(
39- {{{4, 3, 4}, {4, 3, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},38+ "Mod",
40- {{{4, 3, 4}, {4, 3, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},39+ {
41- },40+ {{{4, 3, 4}, {4, 3, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},
42- {41+ {{{4, 3, 4}, {4, 3, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},
43- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},42+ },
44- }43+ {
45- );44+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},
45+ });
46 std::vector<std::vector<int64_t>> expectOutputShape = {{4, 3, 4}};46 std::vector<std::vector<int64_t>> expectOutputShape = {{4, 3, 4}};
47 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);47 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
48}48}
49 49 
50// Test: mod infershape with broadcast50// Test: mod infershape with broadcast
51-TEST_F(ModInfershape, mod_infershape_broadcast) {51+TEST_F(ModInfershape, mod_infershape_broadcast)
52- gert::InfershapeContextPara infershapeContextPara("Mod",52+{
53- {53+ gert::InfershapeContextPara infershapeContextPara(
54- {{{1, 3, 4}, {1, 3, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},54+ "Mod",
55- {{{3, 4}, {3, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},55+ {
56- },56+ {{{1, 3, 4}, {1, 3, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},
57- {57+ {{{3, 4}, {3, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},
58- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},58+ },
59- }59+ {
60- );60+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},
61+ });
61 std::vector<std::vector<int64_t>> expectOutputShape = {{1, 3, 4}};62 std::vector<std::vector<int64_t>> expectOutputShape = {{1, 3, 4}};
62 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);63 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
63}64}
64 65 
65// Test: mod infershape with broadcast different dims66// Test: mod infershape with broadcast different dims
66-TEST_F(ModInfershape, mod_infershape_broadcast_diff_dims) {67+TEST_F(ModInfershape, mod_infershape_broadcast_diff_dims)
67- gert::InfershapeContextPara infershapeContextPara("Mod",68+{
68- {69+ gert::InfershapeContextPara infershapeContextPara(
69- {{{2, 3}, {2, 3}}, ge::DT_FLOAT, ge::FORMAT_ND},70+ "Mod",
70- {{{1, 3}, {1, 3}}, ge::DT_FLOAT, ge::FORMAT_ND},71+ {
71- },72+ {{{2, 3}, {2, 3}}, ge::DT_FLOAT, ge::FORMAT_ND},
72- {73+ {{{1, 3}, {1, 3}}, ge::DT_FLOAT, ge::FORMAT_ND},
73- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},74+ },
74- }75+ {
75- );76+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},
77+ });
76 std::vector<std::vector<int64_t>> expectOutputShape = {{2, 3}};78 std::vector<std::vector<int64_t>> expectOutputShape = {{2, 3}};
77 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);79 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
78}80}
79 81 
80// Test: mod infershape with int32 dtype82// Test: mod infershape with int32 dtype
81-TEST_F(ModInfershape, mod_infershape_int32) {83+TEST_F(ModInfershape, mod_infershape_int32)
82- gert::InfershapeContextPara infershapeContextPara("Mod",84+{
83- {85+ gert::InfershapeContextPara infershapeContextPara(
84- {{{10, 20}, {10, 20}}, ge::DT_INT32, ge::FORMAT_ND},86+ "Mod",
85- {{{10, 20}, {10, 20}}, ge::DT_INT32, ge::FORMAT_ND},87+ {
86- },88+ {{{10, 20}, {10, 20}}, ge::DT_INT32, ge::FORMAT_ND},
87- {89+ {{{10, 20}, {10, 20}}, ge::DT_INT32, ge::FORMAT_ND},
88- {{{}, {}}, ge::DT_INT32, ge::FORMAT_ND},90+ },
89- }91+ {
90- );92+ {{{}, {}}, ge::DT_INT32, ge::FORMAT_ND},
93+ });
91 std::vector<std::vector<int64_t>> expectOutputShape = {{10, 20}};94 std::vector<std::vector<int64_t>> expectOutputShape = {{10, 20}};
92 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);95 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
93}96}
94 97 
95// Test: mod infershape with float32 dtype98// Test: mod infershape with float32 dtype
96-TEST_F(ModInfershape, mod_infershape_float32) {99+TEST_F(ModInfershape, mod_infershape_float32)
97- gert::InfershapeContextPara infershapeContextPara("Mod",100+{
98- {101+ gert::InfershapeContextPara infershapeContextPara(
99- {{{5, 6, 7}, {5, 6, 7}}, ge::DT_FLOAT, ge::FORMAT_ND},102+ "Mod",
100- {{{5, 6, 7}, {5, 6, 7}}, ge::DT_FLOAT, ge::FORMAT_ND},103+ {
101- },104+ {{{5, 6, 7}, {5, 6, 7}}, ge::DT_FLOAT, ge::FORMAT_ND},
102- {105+ {{{5, 6, 7}, {5, 6, 7}}, ge::DT_FLOAT, ge::FORMAT_ND},
103- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},106+ },
104- }107+ {
105- );108+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},
109+ });
106 std::vector<std::vector<int64_t>> expectOutputShape = {{5, 6, 7}};110 std::vector<std::vector<int64_t>> expectOutputShape = {{5, 6, 7}};
107 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);111 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
108}112}
109 113 
110// Test: mod infershape with float16 dtype114// Test: mod infershape with float16 dtype
111-TEST_F(ModInfershape, mod_infershape_float16) {115+TEST_F(ModInfershape, mod_infershape_float16)
112- gert::InfershapeContextPara infershapeContextPara("Mod",116+{
113- {117+ gert::InfershapeContextPara infershapeContextPara(
114- {{{8, 16}, {8, 16}}, ge::DT_FLOAT16, ge::FORMAT_ND},118+ "Mod",
115- {{{8, 16}, {8, 16}}, ge::DT_FLOAT16, ge::FORMAT_ND},119+ {
116- },120+ {{{8, 16}, {8, 16}}, ge::DT_FLOAT16, ge::FORMAT_ND},
117- {121+ {{{8, 16}, {8, 16}}, ge::DT_FLOAT16, ge::FORMAT_ND},
118- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},122+ },
119- }123+ {
120- );124+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
125+ });
121 std::vector<std::vector<int64_t>> expectOutputShape = {{8, 16}};126 std::vector<std::vector<int64_t>> expectOutputShape = {{8, 16}};
122 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);127 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
123}128}
124 129 
125// Test: mod infershape with scalar divisor130// Test: mod infershape with scalar divisor
126-TEST_F(ModInfershape, mod_infershape_scalar_divisor) {131+TEST_F(ModInfershape, mod_infershape_scalar_divisor)
127- gert::InfershapeContextPara infershapeContextPara("Mod",132+{
128- {133+ gert::InfershapeContextPara infershapeContextPara(
129- {{{10, 20}, {10, 20}}, ge::DT_FLOAT, ge::FORMAT_ND},134+ "Mod",
130- {{{1, 1}, {1, 1}}, ge::DT_FLOAT, ge::FORMAT_ND},135+ {
131- },136+ {{{10, 20}, {10, 20}}, ge::DT_FLOAT, ge::FORMAT_ND},
132- {137+ {{{1, 1}, {1, 1}}, ge::DT_FLOAT, ge::FORMAT_ND},
133- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},138+ },
134- }139+ {
135- );140+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},
141+ });
136 std::vector<std::vector<int64_t>> expectOutputShape = {{10, 20}};142 std::vector<std::vector<int64_t>> expectOutputShape = {{10, 20}};
137 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);143 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
138}144}
139 145 
140// Test: mod infershape with 1D tensors146// Test: mod infershape with 1D tensors
141-TEST_F(ModInfershape, mod_infershape_1d) {147+TEST_F(ModInfershape, mod_infershape_1d)
142- gert::InfershapeContextPara infershapeContextPara("Mod",148+{
143- {149+ gert::InfershapeContextPara infershapeContextPara(
144- {{{100}, {100}}, ge::DT_FLOAT, ge::FORMAT_ND},150+ "Mod",
145- {{{100}, {100}}, ge::DT_FLOAT, ge::FORMAT_ND},151+ {
146- },152+ {{{100}, {100}}, ge::DT_FLOAT, ge::FORMAT_ND},
147- {153+ {{{100}, {100}}, ge::DT_FLOAT, ge::FORMAT_ND},
148- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},154+ },
149- }155+ {
150- );156+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},
157+ });
151 std::vector<std::vector<int64_t>> expectOutputShape = {{100}};158 std::vector<std::vector<int64_t>> expectOutputShape = {{100}};
152 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);159 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
153}160}
154 161 
155// Test: mod infershape with double dtype162// Test: mod infershape with double dtype
156-TEST_F(ModInfershape, mod_infershape_double) {163+TEST_F(ModInfershape, mod_infershape_double)
157- gert::InfershapeContextPara infershapeContextPara("Mod",164+{
158- {165+ gert::InfershapeContextPara infershapeContextPara(
159- {{{10, 20}, {10, 20}}, ge::DT_DOUBLE, ge::FORMAT_ND},166+ "Mod",
160- {{{10, 20}, {10, 20}}, ge::DT_DOUBLE, ge::FORMAT_ND},167+ {
161- },168+ {{{10, 20}, {10, 20}}, ge::DT_DOUBLE, ge::FORMAT_ND},
162- {169+ {{{10, 20}, {10, 20}}, ge::DT_DOUBLE, ge::FORMAT_ND},
163- {{{}, {}}, ge::DT_DOUBLE, ge::FORMAT_ND},170+ },
164- }171+ {
165- );172+ {{{}, {}}, ge::DT_DOUBLE, ge::FORMAT_ND},
173+ });
166 std::vector<std::vector<int64_t>> expectOutputShape = {{10, 20}};174 std::vector<std::vector<int64_t>> expectOutputShape = {{10, 20}};
167 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);175 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
168}176}
169 177 
170// Test: mod infershape with NHWC format178// Test: mod infershape with NHWC format
171-TEST_F(ModInfershape, mod_infershape_nhwc) {179+TEST_F(ModInfershape, mod_infershape_nhwc)
172- gert::InfershapeContextPara infershapeContextPara("Mod",180+{
173- {181+ gert::InfershapeContextPara infershapeContextPara(
174- {{{1, 16, 16, 3}, {1, 16, 16, 3}}, ge::DT_FLOAT, ge::FORMAT_NHWC},182+ "Mod",
175- {{{1, 16, 16, 3}, {1, 16, 16, 3}}, ge::DT_FLOAT, ge::FORMAT_NHWC},183+ {
176- },184+ {{{1, 16, 16, 3}, {1, 16, 16, 3}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
177- {185+ {{{1, 16, 16, 3}, {1, 16, 16, 3}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
178- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},186+ },
179- }187+ {
180- );188+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_NHWC},
189+ });
181 std::vector<std::vector<int64_t>> expectOutputShape = {{1, 16, 16, 3}};190 std::vector<std::vector<int64_t>> expectOutputShape = {{1, 16, 16, 3}};
182 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);191 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
183}192}
Mmath/pow/docs/aclnnExp2&aclnnInplaceExp2.md+1-0
@@ -3,6 +3,7 @@
3 3 
4| 产品 | 是否支持 |4| 产品 | 是否支持 |
5| :----------------------------------------------------------- | :------: |5| :----------------------------------------------------------- | :------: |
6+| <term>Ascend 950PR/Ascend 950DT</term> | √ |
6| <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term> | √ |7| <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term> | √ |
7| <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term> | √ |8| <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term> | √ |
8 9 
Mmath/pow/docs/aclnnPowScalarTensor.md+1-0
@@ -4,6 +4,7 @@
4 4 
5| 产品 | 是否支持 |5| 产品 | 是否支持 |
6| :----------------------------------------------------------- | :------: |6| :----------------------------------------------------------- | :------: |
7+| <term>Ascend 950PR/Ascend 950DT</term> | √ |
7| <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term> | √ |8| <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term> | √ |
8| <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term> | √ |9| <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term> | √ |
9 10 
Mmath/pow/docs/aclnnPowTensorScalar&aclnnInplacePowTensorScalar.md+1-0
@@ -4,6 +4,7 @@
4 4 
5| 产品 | 是否支持 |5| 产品 | 是否支持 |
6| :----------------------------------------------------------- | :------: |6| :----------------------------------------------------------- | :------: |
7+| <term>Ascend 950PR/Ascend 950DT</term> | √ |
7| <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term> | √ |8| <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term> | √ |
8| <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term> | √ |9| <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term> | √ |
9 10 
Mmath/pow/docs/aclnnPowTensorTensor&aclnnInplacePowTensorTensor.md+1-0
@@ -4,6 +4,7 @@
4 4 
5| 产品 | 是否支持 |5| 产品 | 是否支持 |
6| :----------------------------------------------------------- | :------: |6| :----------------------------------------------------------- | :------: |
7+| <term>Ascend 950PR/Ascend 950DT</term> | √ |
7| <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term> | √ |8| <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term> | √ |
8| <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term> | √ |9| <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term> | √ |
9 10 
Mmath/pow/tests/ut/op_host/arch35/test_pow_tiling_arch35.cpp+15-11
@@ -38,7 +38,8 @@ protected:
38// The infershape tests pass correctly, validating the operator logic.38// The infershape tests pass correctly, validating the operator logic.
39// Tiling test is disabled pending further investigation of TilingRegistry requirements.39// Tiling test is disabled pending further investigation of TilingRegistry requirements.
40 40 
41-TEST_F(PowTilingTest, test_tiling_float32) {41+TEST_F(PowTilingTest, test_tiling_float32)
42+{
42 optiling::PowCompileInfo compileInfo;43 optiling::PowCompileInfo compileInfo;
43 compileInfo.coreNum = 64;44 compileInfo.coreNum = 64;
44 compileInfo.ubSize = 262144;45 compileInfo.ubSize = 262144;
@@ -46,18 +47,21 @@ TEST_F(PowTilingTest, test_tiling_float32) {
46 compileInfo.vectorLength = 128;47 compileInfo.vectorLength = 128;
47 compileInfo.blockSize = 32;48 compileInfo.blockSize = 32;
48 49 
49- gert::TilingContextPara tilingContextPara("Pow",50+ gert::TilingContextPara tilingContextPara(
50- {51+ "Pow",
51- {{{1, 64, 2, 64}, {1, 64, 2, 64}}, ge::DT_FLOAT, ge::FORMAT_ND},52+ {
52- {{{1, 64, 2, 64}, {1, 64, 2, 64}}, ge::DT_FLOAT, ge::FORMAT_ND},53+ {{{1, 64, 2, 64}, {1, 64, 2, 64}}, ge::DT_FLOAT, ge::FORMAT_ND},
53- },54+ {{{1, 64, 2, 64}, {1, 64, 2, 64}}, ge::DT_FLOAT, ge::FORMAT_ND},
54- {55+ },
55- {{{1, 64, 2, 64}, {1, 64, 2, 64}}, ge::DT_FLOAT, ge::FORMAT_ND},56+ {
56- },57+ {{{1, 64, 2, 64}, {1, 64, 2, 64}}, ge::DT_FLOAT, ge::FORMAT_ND},
57- &compileInfo);58+ },
59+ &compileInfo);
58 60 
59 uint64_t expectTilingKey = 300000001000100;61 uint64_t expectTilingKey = 300000001000100;
60- string expectTilingData = "1 640 13 512 1 1 0 13 640 8192 0 0 0 0 0 0 0 8192 0 0 0 0 0 0 0 8192 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 ";62+ string expectTilingData =
63+ "1 640 13 512 1 1 0 13 640 8192 0 0 0 0 0 0 0 8192 0 0 0 0 0 0 0 8192 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 0 0 0 "
64+ "0 0 0 1 0 0 0 0 0 0 0 ";
61 std::vector<size_t> expectWorkspaces = {16777216};65 std::vector<size_t> expectWorkspaces = {16777216};
62 ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectTilingData, expectWorkspaces);66 ExecuteTestCase(tilingContextPara, ge::GRAPH_SUCCESS, expectTilingKey, expectTilingData, expectWorkspaces);
63}67}
Mmath/pow/tests/ut/op_host/test_pow_infershape.cpp+100-92
@@ -18,8 +18,7 @@
18#include "infershape_context_faker.h"18#include "infershape_context_faker.h"
19#include "infershape_case_executor.h"19#include "infershape_case_executor.h"
20 20 
21-class PowInfershape : public testing::Test21+class PowInfershape : public testing::Test {
22-{
23protected:22protected:
24 static void SetUpTestCase()23 static void SetUpTestCase()
25 {24 {
@@ -33,136 +32,145 @@ protected:
33};32};
34 33 
35// Test: pow infershape with same shape34// Test: pow infershape with same shape
36-TEST_F(PowInfershape, pow_infershape_same_shape) {35+TEST_F(PowInfershape, pow_infershape_same_shape)
37- gert::InfershapeContextPara infershapeContextPara("Pow",36+{
38- {37+ gert::InfershapeContextPara infershapeContextPara(
39- {{{4, 3, 4}, {4, 3, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},38+ "Pow",
40- {{{4, 3, 4}, {4, 3, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},39+ {
41- },40+ {{{4, 3, 4}, {4, 3, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
42- {41+ {{{4, 3, 4}, {4, 3, 4}}, ge::DT_FLOAT16, ge::FORMAT_ND},
43- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},42+ },
44- }43+ {
45- );44+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
45+ });
46 std::vector<std::vector<int64_t>> expectOutputShape = {{4, 3, 4}};46 std::vector<std::vector<int64_t>> expectOutputShape = {{4, 3, 4}};
47 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);47 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
48}48}
49 49 
50// Test: pow infershape with broadcast50// Test: pow infershape with broadcast
51-TEST_F(PowInfershape, pow_infershape_broadcast) {51+TEST_F(PowInfershape, pow_infershape_broadcast)
52- gert::InfershapeContextPara infershapeContextPara("Pow",52+{
53- {53+ gert::InfershapeContextPara infershapeContextPara(
54- {{{1, 3, 4}, {1, 3, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},54+ "Pow",
55- {{{3, 4}, {3, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},55+ {
56- },56+ {{{1, 3, 4}, {1, 3, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},
57- {57+ {{{3, 4}, {3, 4}}, ge::DT_FLOAT, ge::FORMAT_ND},
58- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},58+ },
59- }59+ {
60- );60+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},
61+ });
61 std::vector<std::vector<int64_t>> expectOutputShape = {{1, 3, 4}};62 std::vector<std::vector<int64_t>> expectOutputShape = {{1, 3, 4}};
62 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);63 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
63}64}
64 65 
65// Test: pow infershape with broadcast different dims66// Test: pow infershape with broadcast different dims
66-TEST_F(PowInfershape, pow_infershape_broadcast_diff_dims) {67+TEST_F(PowInfershape, pow_infershape_broadcast_diff_dims)
67- gert::InfershapeContextPara infershapeContextPara("Pow",68+{
68- {69+ gert::InfershapeContextPara infershapeContextPara(
69- {{{2, 3}, {2, 3}}, ge::DT_FLOAT, ge::FORMAT_ND},70+ "Pow",
70- {{{1, 3}, {1, 3}}, ge::DT_FLOAT, ge::FORMAT_ND},71+ {
71- },72+ {{{2, 3}, {2, 3}}, ge::DT_FLOAT, ge::FORMAT_ND},
72- {73+ {{{1, 3}, {1, 3}}, ge::DT_FLOAT, ge::FORMAT_ND},
73- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},74+ },
74- }75+ {
75- );76+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},
77+ });
76 std::vector<std::vector<int64_t>> expectOutputShape = {{2, 3}};78 std::vector<std::vector<int64_t>> expectOutputShape = {{2, 3}};
77 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);79 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
78}80}
79 81 
80// Test: pow infershape with int32 dtype82// Test: pow infershape with int32 dtype
81-TEST_F(PowInfershape, pow_infershape_int32) {83+TEST_F(PowInfershape, pow_infershape_int32)
82- gert::InfershapeContextPara infershapeContextPara("Pow",84+{
83- {85+ gert::InfershapeContextPara infershapeContextPara(
84- {{{10, 20}, {10, 20}}, ge::DT_INT32, ge::FORMAT_ND},86+ "Pow",
85- {{{10, 20}, {10, 20}}, ge::DT_INT32, ge::FORMAT_ND},87+ {
86- },88+ {{{10, 20}, {10, 20}}, ge::DT_INT32, ge::FORMAT_ND},
87- {89+ {{{10, 20}, {10, 20}}, ge::DT_INT32, ge::FORMAT_ND},
88- {{{}, {}}, ge::DT_INT32, ge::FORMAT_ND},90+ },
89- }91+ {
90- );92+ {{{}, {}}, ge::DT_INT32, ge::FORMAT_ND},
93+ });
91 std::vector<std::vector<int64_t>> expectOutputShape = {{10, 20}};94 std::vector<std::vector<int64_t>> expectOutputShape = {{10, 20}};
92 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);95 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
93}96}
94 97 
95// Test: pow infershape with float32 dtype98// Test: pow infershape with float32 dtype
96-TEST_F(PowInfershape, pow_infershape_float32) {99+TEST_F(PowInfershape, pow_infershape_float32)
97- gert::InfershapeContextPara infershapeContextPara("Pow",100+{
98- {101+ gert::InfershapeContextPara infershapeContextPara(
99- {{{5, 6, 7}, {5, 6, 7}}, ge::DT_FLOAT, ge::FORMAT_ND},102+ "Pow",
100- {{{5, 6, 7}, {5, 6, 7}}, ge::DT_FLOAT, ge::FORMAT_ND},103+ {
101- },104+ {{{5, 6, 7}, {5, 6, 7}}, ge::DT_FLOAT, ge::FORMAT_ND},
102- {105+ {{{5, 6, 7}, {5, 6, 7}}, ge::DT_FLOAT, ge::FORMAT_ND},
103- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},106+ },
104- }107+ {
105- );108+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},
109+ });
106 std::vector<std::vector<int64_t>> expectOutputShape = {{5, 6, 7}};110 std::vector<std::vector<int64_t>> expectOutputShape = {{5, 6, 7}};
107 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);111 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
108}112}
109 113 
110// Test: pow infershape with bf16 dtype114// Test: pow infershape with bf16 dtype
111-TEST_F(PowInfershape, pow_infershape_bf16) {115+TEST_F(PowInfershape, pow_infershape_bf16)
112- gert::InfershapeContextPara infershapeContextPara("Pow",116+{
113- {117+ gert::InfershapeContextPara infershapeContextPara(
114- {{{8, 16}, {8, 16}}, ge::DT_BF16, ge::FORMAT_ND},118+ "Pow",
115- {{{8, 16}, {8, 16}}, ge::DT_BF16, ge::FORMAT_ND},119+ {
116- },120+ {{{8, 16}, {8, 16}}, ge::DT_BF16, ge::FORMAT_ND},
117- {121+ {{{8, 16}, {8, 16}}, ge::DT_BF16, ge::FORMAT_ND},
118- {{{}, {}}, ge::DT_BF16, ge::FORMAT_ND},122+ },
119- }123+ {
120- );124+ {{{}, {}}, ge::DT_BF16, ge::FORMAT_ND},
125+ });
121 std::vector<std::vector<int64_t>> expectOutputShape = {{8, 16}};126 std::vector<std::vector<int64_t>> expectOutputShape = {{8, 16}};
122 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);127 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
123}128}
124 129 
125// Test: pow infershape with mixed dtype (float32 input, float16 exponent)130// Test: pow infershape with mixed dtype (float32 input, float16 exponent)
126-TEST_F(PowInfershape, pow_infershape_mixed_dtype) {131+TEST_F(PowInfershape, pow_infershape_mixed_dtype)
127- gert::InfershapeContextPara infershapeContextPara("Pow",132+{
128- {133+ gert::InfershapeContextPara infershapeContextPara(
129- {{{4, 5}, {4, 5}}, ge::DT_FLOAT, ge::FORMAT_ND},134+ "Pow",
130- {{{4, 5}, {4, 5}}, ge::DT_FLOAT16, ge::FORMAT_ND},135+ {
131- },136+ {{{4, 5}, {4, 5}}, ge::DT_FLOAT, ge::FORMAT_ND},
132- {137+ {{{4, 5}, {4, 5}}, ge::DT_FLOAT16, ge::FORMAT_ND},
133- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},138+ },
134- }139+ {
135- );140+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},
141+ });
136 std::vector<std::vector<int64_t>> expectOutputShape = {{4, 5}};142 std::vector<std::vector<int64_t>> expectOutputShape = {{4, 5}};
137 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);143 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
138}144}
139 145 
140// Test: pow infershape with 1D tensors146// Test: pow infershape with 1D tensors
141-TEST_F(PowInfershape, pow_infershape_1d) {147+TEST_F(PowInfershape, pow_infershape_1d)
142- gert::InfershapeContextPara infershapeContextPara("Pow",148+{
143- {149+ gert::InfershapeContextPara infershapeContextPara(
144- {{{100}, {100}}, ge::DT_FLOAT, ge::FORMAT_ND},150+ "Pow",
145- {{{100}, {100}}, ge::DT_FLOAT, ge::FORMAT_ND},151+ {
146- },152+ {{{100}, {100}}, ge::DT_FLOAT, ge::FORMAT_ND},
147- {153+ {{{100}, {100}}, ge::DT_FLOAT, ge::FORMAT_ND},
148- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},154+ },
149- }155+ {
150- );156+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},
157+ });
151 std::vector<std::vector<int64_t>> expectOutputShape = {{100}};158 std::vector<std::vector<int64_t>> expectOutputShape = {{100}};
152 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);159 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
153}160}
154 161 
155// Test: pow infershape with scalar exponent162// Test: pow infershape with scalar exponent
156-TEST_F(PowInfershape, pow_infershape_scalar_exponent) {163+TEST_F(PowInfershape, pow_infershape_scalar_exponent)
157- gert::InfershapeContextPara infershapeContextPara("Pow",164+{
158- {165+ gert::InfershapeContextPara infershapeContextPara(
159- {{{10, 20}, {10, 20}}, ge::DT_FLOAT, ge::FORMAT_ND},166+ "Pow",
160- {{{1, 1}, {1, 1}}, ge::DT_FLOAT, ge::FORMAT_ND},167+ {
161- },168+ {{{10, 20}, {10, 20}}, ge::DT_FLOAT, ge::FORMAT_ND},
162- {169+ {{{1, 1}, {1, 1}}, ge::DT_FLOAT, ge::FORMAT_ND},
163- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},170+ },
164- }171+ {
165- );172+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},
173+ });
166 std::vector<std::vector<int64_t>> expectOutputShape = {{10, 20}};174 std::vector<std::vector<int64_t>> expectOutputShape = {{10, 20}};
167 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);175 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
168}176}
Dmath/range/op_graph/fusion_pass/.gitkeep+0-0
The file is empty
Dmath/range/op_host/op_api/aclnn_arange.cpp+0-213
@@ -1,213 +0,0 @@
1-/**
2- * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3- * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4- * CANN Open Software License Agreement Version 2.0 (the "License").
5- * Please refer to the License for details. You may not use this file except in compliance with the License.
6- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7- * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8- * See LICENSE in the root of the software repository for the full text of the License.
9- */
10- 
11-#include "aclnn_arange.h"
12-#include "arange.h"
13-#include "aclnn_kernels/cast.h"
14-#include "aclnn_kernels/contiguous.h"
15-#include "aclnn/aclnn_base.h"
16-#include "aclnn_kernels/common/op_error_check.h"
17-#include "opdev/common_types.h"
18-#include "opdev/data_type_utils.h"
19-#include "opdev/format_utils.h"
20-#include "opdev/op_dfx.h"
21-#include "opdev/op_executor.h"
22-#include "opdev/op_log.h"
23-#include "opdev/platform.h"
24-#include "opdev/tensor_view_utils.h"
25- 
26-using namespace op;
27- 
28-template <typename T>
29-inline static aclnnStatus CheckStep(T start, T end, T step)
30-{
31- if (!(step > static_cast<T>(0) || step < static_cast<T>(0))) {
32- OP_LOGE(ACLNN_ERR_PARAM_INVALID, "step must be nonzero.");
33- return ACLNN_ERR_PARAM_INVALID;
34- }
35- // 在step大于0时结束值必须大于等于起始值;在step小于0时结束值必须小于等于起始值
36- if ((step > static_cast<T>(0) && start > end) || (step < static_cast<T>(0) && start < end)) {
37- return ACLNN_ERR_PARAM_INVALID;
38- }
39- return ACLNN_SUCCESS;
40-}
41- 
42-#ifdef __cplusplus
43-extern "C" {
44-#endif
45- 
46-// 根据API定义,需要列出Ascend910所能支持的所有dtype
47-static const std::initializer_list<DataType> ASCEND910_INPUT_DTYPE_SUPPORT_LIST = {
48- DataType::DT_FLOAT, DataType::DT_INT32, DataType::DT_INT64, DataType::DT_FLOAT16, DataType::DT_INT16,
49- DataType::DT_INT8, DataType::DT_UINT8, DataType::DT_DOUBLE, DataType::DT_BOOL};
50- 
51-static const std::initializer_list<DataType> ASCEND910_OUTPUT_DTYPE_SUPPORT_LIST = {
52- DataType::DT_FLOAT16, DataType::DT_FLOAT, DataType::DT_DOUBLE, DataType::DT_INT64, DataType::DT_INT32};
53- 
54-// 根据API定义,需要列出Ascend910B所能支持的所有dtype
55-static const std::initializer_list<DataType> ASCEND910B_INPUT_DTYPE_SUPPORT_LIST = {
56- DataType::DT_FLOAT, DataType::DT_INT32, DataType::DT_INT64, DataType::DT_FLOAT16, DataType::DT_INT16,
57- DataType::DT_INT8, DataType::DT_UINT8, DataType::DT_DOUBLE, DataType::DT_BOOL, DataType::DT_BF16};
58- 
59-static const std::initializer_list<DataType> ASCEND910B_OUTPUT_DTYPE_SUPPORT_LIST = {
60- DataType::DT_FLOAT16, DataType::DT_FLOAT, DataType::DT_DOUBLE,
61- DataType::DT_INT64, DataType::DT_INT32, DataType::DT_BF16};
62- 
63-// 检查输入的数据类型是否在算子的支持列表内
64-static bool CheckDtypeValid(const aclScalar* start, const aclScalar* end, const aclScalar* step, const aclTensor* out) {
65- // 获取芯片类型,判断芯片是否为Ascend910B
66- bool isAscend910BSocVersion = (GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910B ||
67- GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910_93 ||
68- GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910_95);
69- const std::initializer_list<op::DataType> CURRENT_INPUT_DTYPE_SUPPORT_LIST =
70- isAscend910BSocVersion ? ASCEND910B_INPUT_DTYPE_SUPPORT_LIST : ASCEND910_INPUT_DTYPE_SUPPORT_LIST;
71- const std::initializer_list<op::DataType> CURRENT_OUTPUT_DTYPE_SUPPORT_LIST =
72- isAscend910BSocVersion ? ASCEND910B_OUTPUT_DTYPE_SUPPORT_LIST : ASCEND910_OUTPUT_DTYPE_SUPPORT_LIST;
73- 
74- // 检查start的数据类型是否在算子的支持列表内
75- OP_CHECK_DTYPE_NOT_SUPPORT(start, CURRENT_INPUT_DTYPE_SUPPORT_LIST, return false);
76- 
77- // 检查end的数据类型是否在算子的支持列表内
78- OP_CHECK_DTYPE_NOT_SUPPORT(end, CURRENT_INPUT_DTYPE_SUPPORT_LIST, return false);
79- 
80- // 检查step的数据类型是否在算子的支持列表内
81- OP_CHECK_DTYPE_NOT_SUPPORT(step, CURRENT_INPUT_DTYPE_SUPPORT_LIST, return false);
82- 
83- // 检查输出的数据类型是否在算子的支持列表内
84- OP_CHECK_DTYPE_NOT_SUPPORT(out, CURRENT_OUTPUT_DTYPE_SUPPORT_LIST, return false);
85- 
86- return true;
87-}
88- 
89-inline static aclnnStatus CheckStepCorrect(const aclScalar *start, const aclScalar *end,
90- const aclScalar *step, const aclTensor *out)
91-{
92- DataType outType = out->GetDataType();
93- switch (outType)
94- {
95- case DataType::DT_FLOAT16:
96- case DataType::DT_BF16:
97- case DataType::DT_FLOAT:
98- {
99- float startValueFloat = start->ToFloat();
100- float endValueFloat = end->ToFloat();
101- float stepValueFloat = step->ToFloat();
102- if (CheckStep<float>(startValueFloat, endValueFloat, stepValueFloat) != ACLNN_SUCCESS) {
103- OP_LOGE(ACLNN_ERR_PARAM_INVALID,
104- "upper bound and lower bound inconsistent with step sign. start:%f, end:%f, step:%f.",
105- startValueFloat, endValueFloat, stepValueFloat);
106- return ACLNN_ERR_PARAM_INVALID;
107- }
108- break;
109- }
110- case DataType::DT_DOUBLE:
111- {
112- double startValueDouble = start->ToDouble();
113- double endValueDouble = end->ToDouble();
114- double stepValueDouble = step->ToDouble();
115- if (CheckStep<double>(startValueDouble, endValueDouble, stepValueDouble) != ACLNN_SUCCESS) {
116- OP_LOGE(ACLNN_ERR_PARAM_INVALID,
117- "upper bound and lower bound inconsistent with step sign. start:%lf, end:%lf, step:%lf.",
118- startValueDouble, endValueDouble, stepValueDouble);
119- return ACLNN_ERR_PARAM_INVALID;
120- }
121- break;
122- }
123- case DataType::DT_INT32:
124- case DataType::DT_INT64:
125- {
126- int64_t startValueInt64 = start->ToInt64();
127- int64_t endValueInt64 = end->ToInt64();
128- int64_t stepValueInt64 = step->ToInt64();
129- if (CheckStep<int64_t>(startValueInt64, endValueInt64, stepValueInt64) != ACLNN_SUCCESS) {
130- OP_LOGE(ACLNN_ERR_PARAM_INVALID,
131- "upper bound and lower bound inconsistent with step sign. start:%ld, end:%ld, step:%ld.",
132- startValueInt64, endValueInt64, stepValueInt64);
133- return ACLNN_ERR_PARAM_INVALID;
134- }
135- break;
136- }
137- default:
138- {
139- OP_LOGE(ACLNN_ERR_PARAM_INVALID, "outputdtype invalid.");
140- return ACLNN_ERR_PARAM_INVALID;
141- break;
142- }
143- }
144- return ACLNN_SUCCESS;
145-}
146- 
147-// 检查输入是否是空指针
148-static bool CheckNotNull(const aclScalar* start, const aclScalar* end, const aclScalar* step, const aclTensor* out) {
149- // 检查start是否是空指针
150- OP_CHECK_NULL(start, return false);
151- 
152- // 检查end是否是空指针
153- OP_CHECK_NULL(end, return false);
154- 
155- // 检查step是否是空指针
156- OP_CHECK_NULL(step, return false);
157- 
158- // 检查输入是否是空指针
159- OP_CHECK_NULL(out, return false);
160- 
161- return true;
162-}
163- 
164-static aclnnStatus CheckParams(const aclScalar* start, const aclScalar* end, const aclScalar* step,
165- const aclTensor* out) {
166- // 1. 检查参数是否为空指针
167- CHECK_RET(CheckNotNull(start, end, step, out), ACLNN_ERR_INNER_NULLPTR);
168- // 2. 检查输入的数据类型是否在API支持的数据类型范围之内,需要根据api定义校验
169- CHECK_RET(CheckDtypeValid(start, end, step, out), ACLNN_ERR_PARAM_INVALID);
170- // 3. 检查输入的数据的值是否合理
171- CHECK_RET(CheckStepCorrect(start, end, step, out) == ACLNN_SUCCESS, ACLNN_ERR_PARAM_INVALID);
172- return ACLNN_SUCCESS;
173-}
174- 
175-aclnnStatus aclnnArangeGetWorkspaceSize(const aclScalar* start, const aclScalar* end, const aclScalar* step,
176- aclTensor* out, uint64_t* workspaceSize, aclOpExecutor** executor) {
177- L2_DFX_PHASE_1(aclnnArange, DFX_IN(start, end, step), DFX_OUT(out));
178- 
179- // 创建OpExecutor
180- auto uniqueExecutor = CREATE_EXECUTOR();
181- CHECK_RET(uniqueExecutor.get() != nullptr, ACLNN_ERR_INNER_CREATE_EXECUTOR);
182- 
183- // 参数检查
184- auto ret = CheckParams(start, end, step, out);
185- CHECK_RET(ret == ACLNN_SUCCESS, ret);
186- 
187- // 执行L0算子
188- static const bool isClosed = false;
189- auto arangeOutRet = l0op::Arange(start, end, step, out, isClosed, uniqueExecutor.get());
190- CHECK_RET(arangeOutRet != nullptr, ACLNN_ERR_INNER_NULLPTR);
191- // 将结果转换成输出类型
192- auto arangeOutCast = l0op::Cast(arangeOutRet, out->GetDataType(), uniqueExecutor.get());
193- CHECK_RET(arangeOutCast != nullptr, ACLNN_ERR_INNER_NULLPTR);
194- // 将计算结果拷贝到输出out上,out可能是非连续的tensor
195- auto viewCopyResult = l0op::ViewCopy(arangeOutCast, out, uniqueExecutor.get());
196- CHECK_RET(viewCopyResult != nullptr, ACLNN_ERR_INNER_NULLPTR);
197- 
198- // 获取计算过程中需要使用的workspace大小
199- *workspaceSize = uniqueExecutor->GetWorkspaceSize();
200- // 需要把 uniqueExecutor持有executor转移给executor
201- uniqueExecutor.ReleaseTo(executor);
202- return ACLNN_SUCCESS;
203-}
204- 
205-aclnnStatus aclnnArange(void* workspace, uint64_t workspaceSize, aclOpExecutor* executor, const aclrtStream stream) {
206- L2_DFX_PHASE_2(aclnnArange);
207- // 调用框架能力,完成计算
208- return CommonOpExecutorRun(workspace, workspaceSize, executor, stream);
209-}
210- 
211-#ifdef __cplusplus
212-}
213-#endif
Dmath/range/op_host/op_api/aclnn_arange.h+0-38
@@ -1,38 +0,0 @@
1-/**
2- * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3- *
4- * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
5- * CANN Open Software License Agreement Version 2.0 (the "License").
6- * Please refer to the License for details. You may not use this file except in compliance with the License.
7- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
8- * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
9- * See LICENSE in the root of the software repository for the full text of the License.
10- */
11- 
12-#ifndef OP_API_INC_ARANGE_H_
13-#define OP_API_INC_ARANGE_H_
14- 
15-#include "aclnn/aclnn_base.h"
16-#include "aclnn_util.h"
17- 
18-#ifdef __cplusplus
19-extern "C" {
20-#endif
21- 
22-/**
23- * @brief aclnnArange的第一段接口,根据具体的计算流程,计算workspace大小。
24- * @domain aclnn_ops_infer
25- * 功能描述:从start到end按照step的间隔获取每个值,保存到输出1维张量。
26- */
27-ACLNN_API aclnnStatus aclnnArangeGetWorkspaceSize(
28- const aclScalar* start, const aclScalar* end, const aclScalar* step, aclTensor* out, uint64_t* workspaceSize,
29- aclOpExecutor** executor);
30-/* @brief aclnnArange的第二段接口,用于执行计算。 */
31-ACLNN_API aclnnStatus
32-aclnnArange(void* workspace, uint64_t workspaceSize, aclOpExecutor* executor, const aclrtStream stream);
33- 
34-#ifdef __cplusplus
35-}
36-#endif
37- 
38-#endif
Dmath/range/op_host/op_api/aclnn_range.cpp+0-237
@@ -1,237 +0,0 @@
1-/**
2- * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3- * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4- * CANN Open Software License Agreement Version 2.0 (the "License").
5- * Please refer to the License for details. You may not use this file except in compliance with the License.
6- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7- * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8- * See LICENSE in the root of the software repository for the full text of the License.
9- */
10- 
11-#include <limits>
12-#include "aclnn_range.h"
13-#include "arange.h"
14-#include "aclnn_kernels/cast.h"
15-#include "aclnn_kernels/contiguous.h"
16-#include "aclnn/aclnn_base.h"
17-#include "aclnn_kernels/common/op_error_check.h"
18-#include "opdev/common_types.h"
19-#include "opdev/platform.h"
20-#include "opdev/data_type_utils.h"
21-#include "opdev/format_utils.h"
22-#include "opdev/op_dfx.h"
23-#include "opdev/op_executor.h"
24-#include "opdev/op_log.h"
25-#include "opdev/tensor_view_utils.h"
26- 
27-using namespace op;
28- 
29-template <typename T>
30-inline static aclnnStatus CheckStep(T start, T end, T step)
31-{
32- if (!(step > static_cast<T>(0) || step < static_cast<T>(0))) {
33- OP_LOGE(ACLNN_ERR_PARAM_INVALID, "step must be nonzero.");
34- return ACLNN_ERR_PARAM_INVALID;
35- }
36- // 在step大于0时结束值必须大于等于起始值;在step小于0时结束值必须小于等于起始值
37- if ((step > static_cast<T>(0) && start > end) || (step < static_cast<T>(0) && start < end)) {
38- return ACLNN_ERR_PARAM_INVALID;
39- }
40- return ACLNN_SUCCESS;
41-}
42- 
43-#ifdef __cplusplus
44-extern "C" {
45-#endif
46- 
47-/* Range 算子的完整计算流程如下:
48- * start step end
49- * | | |
50- * \ | /
51- * \ | /
52- * Arange(workspace4)
53- * |
54- * Cast(workspace5)
55- * |
56- * ViewCopy
57- * |
58- * result
59- */
60- 
61-// 根据API定义,需要列出Ascend910所能支持的所有dtype
62-static const std::initializer_list<DataType> ASCEND910_INPUT_DTYPE_SUPPORT_LIST = {
63- DataType::DT_FLOAT, DataType::DT_INT32, DataType::DT_INT64, DataType::DT_FLOAT16, DataType::DT_INT16,
64- DataType::DT_INT8, DataType::DT_UINT8, DataType::DT_DOUBLE, DataType::DT_BOOL};
65- 
66-static const std::initializer_list<DataType> ASCEND910_OUTPUT_DTYPE_SUPPORT_LIST = {
67- DataType::DT_FLOAT16, DataType::DT_FLOAT, DataType::DT_DOUBLE, DataType::DT_INT64, DataType::DT_INT32};
68- 
69-// 根据API定义,需要列出Ascend910B所能支持的所有dtype
70-static const std::initializer_list<DataType> ASCEND910B_INPUT_DTYPE_SUPPORT_LIST = {
71- DataType::DT_FLOAT, DataType::DT_INT32, DataType::DT_INT64, DataType::DT_FLOAT16, DataType::DT_INT16,
72- DataType::DT_INT8, DataType::DT_UINT8, DataType::DT_DOUBLE, DataType::DT_BOOL, DataType::DT_BF16};
73- 
74-static const std::initializer_list<DataType> ASCEND910B_OUTPUT_DTYPE_SUPPORT_LIST = {
75- DataType::DT_FLOAT16, DataType::DT_FLOAT, DataType::DT_DOUBLE,
76- DataType::DT_INT64, DataType::DT_INT32, DataType::DT_BF16};
77- 
78-// 检查输入是否是空指针
79-inline static bool CheckNotNull(const aclScalar *start, const aclScalar *end, const aclScalar *step, const aclTensor *out) {
80- OP_CHECK_NULL(start, return false);
81- OP_CHECK_NULL(end, return false);
82- OP_CHECK_NULL(step, return false);
83- OP_CHECK_NULL(out, return false);
84- return true;
85-}
86- 
87-inline static bool CheckDtypeValid(const aclScalar *start, const aclScalar *end, const aclScalar *step,
88- const aclTensor *out) {
89- // 获取芯片类型,判断芯片是否为Ascend910B
90- bool isAscend910BSocVersion = (GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910B ||
91- GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910_93 ||
92- GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910_95);
93- const std::initializer_list<op::DataType> CURRENT_INPUT_DTYPE_SUPPORT_LIST =
94- isAscend910BSocVersion ? ASCEND910B_INPUT_DTYPE_SUPPORT_LIST : ASCEND910_INPUT_DTYPE_SUPPORT_LIST;
95- const std::initializer_list<op::DataType> CURRENT_OUTPUT_DTYPE_SUPPORT_LIST =
96- isAscend910BSocVersion ? ASCEND910B_OUTPUT_DTYPE_SUPPORT_LIST : ASCEND910_OUTPUT_DTYPE_SUPPORT_LIST;
97- 
98- // 检查start的数据类型是否在算子的支持列表内
99- OP_CHECK_DTYPE_NOT_SUPPORT(start, CURRENT_INPUT_DTYPE_SUPPORT_LIST, return false);
100- 
101- // 检查end的数据类型是否在算子的支持列表内
102- OP_CHECK_DTYPE_NOT_SUPPORT(end, CURRENT_INPUT_DTYPE_SUPPORT_LIST, return false);
103- 
104- // 检查step的数据类型是否在算子的支持列表内
105- OP_CHECK_DTYPE_NOT_SUPPORT(step, CURRENT_INPUT_DTYPE_SUPPORT_LIST, return false);
106- 
107- // 检查输出的数据类型是否在算子的支持列表内
108- OP_CHECK_DTYPE_NOT_SUPPORT(out, CURRENT_OUTPUT_DTYPE_SUPPORT_LIST, return false);
109- 
110- return true;
111-}
112- 
113-inline static aclnnStatus CheckStepCorrect(const aclScalar *start, const aclScalar *end,
114- const aclScalar *step, const aclTensor *out)
115-{
116- DataType outType = out->GetDataType();
117- switch (outType)
118- {
119- case DataType::DT_FLOAT16:
120- case DataType::DT_BF16:
121- case DataType::DT_FLOAT:
122- {
123- float startValueFloat = start->ToFloat();
124- float endValueFloat = end->ToFloat();
125- float stepValueFloat = step->ToFloat();
126- if (CheckStep<float>(startValueFloat, endValueFloat, stepValueFloat) != ACLNN_SUCCESS) {
127- OP_LOGE(ACLNN_ERR_PARAM_INVALID,
128- "upper bound and lower bound inconsistent with step sign. start:%f, end:%f, step:%f.",
129- startValueFloat, endValueFloat, stepValueFloat);
130- return ACLNN_ERR_PARAM_INVALID;
131- }
132- break;
133- }
134- case DataType::DT_DOUBLE:
135- {
136- double startValueDouble = start->ToDouble();
137- double endValueDouble = end->ToDouble();
138- double stepValueDouble = step->ToDouble();
139- if (CheckStep<double>(startValueDouble, endValueDouble, stepValueDouble) != ACLNN_SUCCESS) {
140- OP_LOGE(ACLNN_ERR_PARAM_INVALID,
141- "upper bound and lower bound inconsistent with step sign. start:%lf, end:%lf, step:%lf.",
142- startValueDouble, endValueDouble, stepValueDouble);
143- return ACLNN_ERR_PARAM_INVALID;
144- }
145- break;
146- }
147- case DataType::DT_INT32:
148- case DataType::DT_INT64:
149- {
150- int64_t startValueInt64 = start->ToInt64();
151- int64_t endValueInt64 = end->ToInt64();
152- int64_t stepValueInt64 = step->ToInt64();
153- if (CheckStep<int64_t>(startValueInt64, endValueInt64, stepValueInt64) != ACLNN_SUCCESS) {
154- OP_LOGE(ACLNN_ERR_PARAM_INVALID,
155- "upper bound and lower bound inconsistent with step sign. start:%ld, end:%ld, step:%ld.",
156- startValueInt64, endValueInt64, stepValueInt64);
157- return ACLNN_ERR_PARAM_INVALID;
158- }
159- break;
160- }
161- default:
162- {
163- OP_LOGE(ACLNN_ERR_PARAM_INVALID, "outputdtype invalid.");
164- return ACLNN_ERR_PARAM_INVALID;
165- break;
166- }
167- }
168- return ACLNN_SUCCESS;
169-}
170- 
171-// 检查参数是否符合算子的逻辑
172-inline static aclnnStatus CheckParamsLogic(const aclScalar *start, const aclScalar *end, const aclScalar *step,
173- const aclTensor *out) {
174- size_t dim_num = out->GetViewShape().GetDimNum();
175- OP_CHECK(dim_num != 0,
176- OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Expected out a 1d tensor, but got %zu.", dim_num),
177- return ACLNN_ERR_PARAM_INVALID);
178- if (CheckStepCorrect(start, end, step, out) == ACLNN_ERR_PARAM_INVALID) {
179- return ACLNN_ERR_PARAM_INVALID;
180- }
181- return ACLNN_SUCCESS;
182-}
183- 
184-inline static aclnnStatus CheckParams(const aclScalar *start, const aclScalar *end, const aclScalar *step,
185- const aclTensor *out) {
186- // 1. 检查参数是否为空指针
187- CHECK_RET(CheckNotNull(start, end, step, out), ACLNN_ERR_INNER_NULLPTR);
188- 
189- // 2. 检查输入的数据类型是否在API支持的数据类型范围之内,需要根据api定义校验
190- CHECK_RET(CheckDtypeValid(start, end, step, out), ACLNN_ERR_PARAM_INVALID);
191- 
192- // 3. 检查输入的数据的值是否合理
193- CHECK_RET(CheckParamsLogic(start, end, step, out) == ACLNN_SUCCESS, ACLNN_ERR_PARAM_INVALID);
194- 
195- return ACLNN_SUCCESS;
196-}
197- 
198-aclnnStatus aclnnRangeGetWorkspaceSize(const aclScalar *start, const aclScalar *end, const aclScalar *step,
199- aclTensor *out, uint64_t *workspaceSize, aclOpExecutor **executor) {
200- L2_DFX_PHASE_1(aclnnRange, DFX_IN(start, end, step), DFX_OUT(out));
201- 
202- // 创建OpExecutor
203- auto uniqueExecutor = CREATE_EXECUTOR();
204- CHECK_RET(uniqueExecutor.get() != nullptr, ACLNN_ERR_INNER_CREATE_EXECUTOR);
205- 
206- // 参数检查
207- auto ret = CheckParams(start, end, step, out);
208- CHECK_RET(ret == ACLNN_SUCCESS, ret);
209- 
210- bool isClosed = true;
211- const aclTensor* rangeOutRet = l0op::Arange(start, end, step, out, isClosed, uniqueExecutor.get());
212- CHECK_RET(rangeOutRet != nullptr, ACLNN_ERR_INNER_NULLPTR);
213-
214- // 将计算结果转换成输出out的数据类型
215- auto castOut = l0op::Cast(rangeOutRet, out->GetDataType(), uniqueExecutor.get());
216- CHECK_RET(castOut != nullptr, ACLNN_ERR_INNER_NULLPTR);
217- 
218- // 将计算结果拷贝到输出out上,out可能是非连续的tensor
219- auto viewCopyResult = l0op::ViewCopy(castOut, out, uniqueExecutor.get());
220- CHECK_RET(viewCopyResult != nullptr, ACLNN_ERR_INNER_NULLPTR);
221- 
222- // 获取计算过程中需要使用的workspace大小
223- *workspaceSize = uniqueExecutor->GetWorkspaceSize();
224- // 需要把 uniqueExecutor持有executor转移给executor
225- uniqueExecutor.ReleaseTo(executor);
226- return ACLNN_SUCCESS;
227-}
228- 
229-aclnnStatus aclnnRange(void *workspace, uint64_t workspaceSize, aclOpExecutor *executor, aclrtStream stream) {
230- L2_DFX_PHASE_2(aclnnRange);
231- // 调用框架能力,完成计算
232- return CommonOpExecutorRun(workspace, workspaceSize, executor, stream);
233-}
234- 
235-#ifdef __cplusplus
236-}
237-#endif
Dmath/range/op_host/op_api/aclnn_range.h+0-96
@@ -1,96 +0,0 @@
1-/**
2- * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3- *
4- * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
5- * CANN Open Software License Agreement Version 2.0 (the "License").
6- * Please refer to the License for details. You may not use this file except in compliance with the License.
7- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
8- * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
9- * See LICENSE in the root of the software repository for the full text of the License.
10- */
11- 
12-#ifndef OP_API_INC_RANGE_H_
13-#define OP_API_INC_RANGE_H_
14- 
15-#include "aclnn/aclnn_base.h"
16-#include "aclnn_util.h"
17- 
18-#ifdef __cplusplus
19-extern "C" {
20-#endif
21- 
22-/**
23- * @brief aclnnRange的第一段接口,根据具体的计算流程,计算workspace大小。
24- * @domain aclnn_math
25- *
26- * 功能描述:从start起始到end结束按照step的间隔取值,并返回大小为 $ \lfloor \frac{end - start} {step} \rfloor + 1
27- * $的1维张量。其中,步长step是张量中 相邻两个值的间隔。
28- *
29- * 计算公式:$$ out_{i+1}=out_i+step $$
30- *
31- * 实现说明:
32- * api计算的基本路径:
33- * ```mermaid
34- * graph LR
35- * A[(Start)]--> E([l0op::Arange])
36- * B[(End)]--> D[(Limit = End + Step)]
37- * C[(Step)]--> D
38- * D--> E
39- * C--> E
40- * E--> H([l0op::Cast])
41- * H--> M([l0op::ViewCopy])
42- * M--> N[(Out)]
43- * ```
44- *
45- * 参数描述:
46- * @param [in] start
47- * 获取值的范围的起始位置:host侧的aclScalar,数据类型支持整型,浮点数据类型。数据格式支持ND。需要满足在step大于0时输入的start小于end,或者step小于0时输入的start大于end。
48- * @param [in] end
49- * 获取值的范围的结束位置:host侧的aclScalar,数据类型支持整型,浮点数据类型。数据格式支持ND。需要满足在step大于0时输入的start小于end,或者step小于0时输入的start大于end。
50- * @param [in] step
51- * 获取值的步长:host侧的aclScalar,数据类型支持整型,浮点数据类型。数据格式支持ND。需要满足step不等于0
52- * @param [in] out 指定的输出tensor:npu
53- * device侧的aclTensor,数据类型支持整型,浮点数据类型,数据格式支持ND。
54- * @param [out] workspaceSize: 返回用户需要在npu device侧申请的workspace大小。
55- * @param [out] executor: 返回op执行器,包含了算子计算流程。
56- * @return aclnnStatus: 返回状态码。
57- */
58-ACLNN_API aclnnStatus aclnnRangeGetWorkspaceSize(
59- const aclScalar* start, const aclScalar* end, const aclScalar* step, aclTensor* out, uint64_t* workspaceSize,
60- aclOpExecutor** executor);
61-/**
62- * @brief aclnnRange的第二段接口,用于执行计算。
63- *
64- *
65- * 功能描述:从start起始到end结束按照step的间隔取值,并返回大小为 $ \lfloor \frac{end - start} {step} \rfloor + 1
66- * $的1维张量。其中,步长step是张量中 相邻两个值的间隔。
67- *
68- * 计算公式:$$ out_{i+1}=out_i+step $$
69- *
70- * 实现说明:
71- * api计算的基本路径:
72- * ```mermaid
73- * graph LR
74- * A[(Start)]--> E([l0op::Arange])
75- * B[(End)]--> D[(Limit = End + Step)]
76- * C[(Step)]--> D
77- * D--> E
78- * C--> E
79- * E--> H([l0op::Cast])
80- * H--> M([l0op::ViewCopy])
81- * M--> N[(Out)]
82- * ```
83- *
84- * @param [in] workspace: 在npu device侧申请的workspace内存起址。
85- * @param [in] workspaceSize: 在npu device侧申请的workspace大小,由第一段接口aclnnRangeGetWorkspaceSize获取。
86- * @param [in] stream: acl stream流。
87- * @param [in] executor: op执行器,包含了算子计算流程。
88- * @return aclnnStatus: 返回状态码。
89- */
90-ACLNN_API aclnnStatus aclnnRange(void* workspace, uint64_t workspaceSize, aclOpExecutor* executor, aclrtStream stream);
91- 
92-#ifdef __cplusplus
93-}
94-#endif
95- 
96-#endif
Dmath/range/op_host/op_api/arange.cpp+0-106
@@ -1,106 +0,0 @@
1-/**
2- * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3- * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4- * CANN Open Software License Agreement Version 2.0 (the "License").
5- * Please refer to the License for details. You may not use this file except in compliance with the License.
6- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7- * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8- * See LICENSE in the root of the software repository for the full text of the License.
9- */
10- 
11-#include "arange.h"
12-#include "opdev/aicpu/aicpu_task.h"
13-#include "opdev/make_op_executor.h"
14-#include "opdev/op_def.h"
15-#include "opdev/op_dfx.h"
16-#include "opdev/op_executor.h"
17-#include "opdev/op_log.h"
18-#include "opdev/platform.h"
19-#include "opdev/shape_utils.h"
20-#include "aclnn_kernels/common/op_error_check.h"
21- 
22-using namespace op;
23- 
24-namespace l0op {
25- 
26-OP_TYPE_REGISTER(Range);
27-constexpr double eps = 0.0000000000001;
28-static const std::initializer_list<DataType> ASCEND910_AICORE_DTYPE_SUPPORT_LIST = {
29- DataType::DT_FLOAT, DataType::DT_INT32, DataType::DT_INT64, DataType::DT_FLOAT16};
30- 
31-static const std::initializer_list<DataType> ASCEND910B_AICORE_DTYPE_SUPPORT_LIST = {
32- DataType::DT_FLOAT, DataType::DT_INT32, DataType::DT_INT64, DataType::DT_BF16,
33- DataType::DT_FLOAT16};
34- 
35-static const std::initializer_list<DataType> ASCEND310B_AICORE_DTYPE_SUPPORT_LIST = {
36- DataType::DT_FLOAT, DataType::DT_INT32, DataType::DT_FLOAT16};
37- 
38-// 根据芯片类型、dtype判断算子是否支持走aicore
39-static bool IsAiCoreSupport(DataType outType) {
40- // 获取芯片类型
41- if (GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910B ||
42- GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910_93 ||
43- GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910_95) {
44- return CheckType(outType, ASCEND910B_AICORE_DTYPE_SUPPORT_LIST);
45- } else if (GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND310B) {
46- return CheckType(outType, ASCEND310B_AICORE_DTYPE_SUPPORT_LIST);
47- }
48- return CheckType(outType, ASCEND910_AICORE_DTYPE_SUPPORT_LIST);
49-}
50- 
51-// AICORE算子kernel
52-static const aclTensor* ArangeAiCore(const aclTensor* start, const aclTensor* end, const aclTensor* step,
53- aclTensor* arangeOut, const bool isClosed, aclOpExecutor* executor) {
54- L0_DFX(ArangeAiCore, start, end, step, arangeOut);
55- // 使用框架宏ADD_TO_LAUNCHER_LIST_AICORE,将AiCore Arange算子加入任务队列
56- auto ret = ADD_TO_LAUNCHER_LIST_AICORE(Range, OP_INPUT(start, end, step), OP_OUTPUT(arangeOut), OP_ATTR(isClosed));
57- OP_CHECK(ret == ACL_SUCCESS, OP_LOGE(ACLNN_ERR_INNER_NULLPTR, "ArangeAiCore ADD_TO_LAUNCHER_LIST_AICORE failed."), return nullptr);
58- return arangeOut;
59-}
60- 
61-// AICPU算子kernel
62-static const aclTensor* ArangeAiCpu(const aclTensor* start, const aclTensor* end, const aclTensor* step,
63- aclTensor* arangeOut, aclOpExecutor* executor) {
64- L0_DFX(ArangeAiCpu, start, end, step, arangeOut);
65- // 使用框架宏ADD_TO_LAUNCHER_LIST_AICPU,将AiCpu Arange算子加入任务队列
66- static internal::AicpuTaskSpace space("Range", ge::DEPEND_IN_SHAPE, true);
67- auto ret = ADD_TO_LAUNCHER_LIST_AICPU(Range, OP_ATTR_NAMES({"Tidx"}), OP_INPUT(start, end, step),
68- OP_OUTPUT(arangeOut), OP_ATTR(start->GetDataType()));
69- OP_CHECK(ret == ACL_SUCCESS, OP_LOGE(ACLNN_ERR_INNER_NULLPTR, "ArangeAiCpu ADD_TO_LAUNCHER_LIST_AICPU failed."), return nullptr);
70- return arangeOut;
71-}
72- 
73-const aclTensor* Arange(const aclScalar* start, const aclScalar* end, const aclScalar* step, const aclTensor* out,
74- const bool isClosed, aclOpExecutor* executor) {
75- DataType outType = out->GetDataType();
76- DataType inputType = outType;
77- if (GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910B ||
78- GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910_93 ||
79- GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910 ||
80- GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND310P ||
81- GetCurrentPlatformInfo().GetSocVersion() == SocVersion::ASCEND910_95) {
82- if (outType == DataType::DT_INT64) {
83- inputType = DataType::DT_INT64;
84- } else {
85- inputType = DataType::DT_DOUBLE;
86- }
87- }
88-
89- auto startTensor = executor->ConvertToTensor(start, inputType);
90- auto endTensor = executor->ConvertToTensor(end, inputType);
91- auto stepTensor = executor->ConvertToTensor(step, inputType);
92- 
93- auto arangeOpOut = executor->AllocTensor(out->GetViewShape(), outType);
94- 
95- if (IsAiCoreSupport(outType)) {
96- return ArangeAiCore(startTensor, endTensor, stepTensor, arangeOpOut, isClosed, executor);
97- } else {
98- if (isClosed) {
99- endTensor = executor->ConvertToTensor(executor->AllocScalar(end->ToDouble() + eps), inputType);
100- }
101- return ArangeAiCpu(startTensor, endTensor, stepTensor, arangeOpOut, executor);
102- }
103- 
104- return arangeOpOut;
105-}
106-} // namespace l0op
Dmath/range/op_host/op_api/arange.h+0-21
@@ -1,21 +0,0 @@
1-/**
2- * Copyright (c) 2025 Huawei Technologies Co., Ltd.
3- * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
4- * CANN Open Software License Agreement Version 2.0 (the "License").
5- * Please refer to the License for details. You may not use this file except in compliance with the License.
6- * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
7- * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
8- * See LICENSE in the root of the software repository for the full text of the License.
9- */
10-#ifndef PTA_NPU_OP_API_INC_LEVEL0_OP_ARANGE_OP_H_
11-#define PTA_NPU_OP_API_INC_LEVEL0_OP_ARANGE_OP_H_
12- 
13-#include "opdev/op_executor.h"
14- 
15-namespace l0op {
16-const aclTensor* Arange(
17- const aclScalar* start, const aclScalar* end, const aclScalar* step, const aclTensor* out, const bool isClosed,
18- aclOpExecutor* executor);
19-}
20- 
21-#endif
Mmath/range/tests/ut/op_host/test_range_infershape.cpp+85-79
@@ -18,8 +18,7 @@
18#include "infershape_context_faker.h"18#include "infershape_context_faker.h"
19#include "infershape_case_executor.h"19#include "infershape_case_executor.h"
20 20 
21-class RangeInfershape : public testing::Test21+class RangeInfershape : public testing::Test {
22-{
23protected:22protected:
24 static void SetUpTestCase()23 static void SetUpTestCase()
25 {24 {
@@ -33,113 +32,120 @@ protected:
33};32};
34 33 
35// Test: range infershape with int32, positive step34// Test: range infershape with int32, positive step
36-TEST_F(RangeInfershape, range_infershape_int32_positive_step) {35+TEST_F(RangeInfershape, range_infershape_int32_positive_step)
37- gert::InfershapeContextPara infershapeContextPara("Range",36+{
38- {37+ gert::InfershapeContextPara infershapeContextPara(
39- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, {}},38+ "Range",
40- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, {}},39+ {
41- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, {}},40+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, {}},
42- },41+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, {}},
43- {42+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, {}},
44- {{{}, {}}, ge::DT_INT32, ge::FORMAT_ND},43+ },
45- }44+ {
46- );45+ {{{}, {}}, ge::DT_INT32, ge::FORMAT_ND},
46+ });
47 std::vector<std::vector<int64_t>> expectOutputShape = {{-1}};47 std::vector<std::vector<int64_t>> expectOutputShape = {{-1}};
48 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);48 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
49}49}
50 50 
51// Test: range infershape with int32, negative step51// Test: range infershape with int32, negative step
52-TEST_F(RangeInfershape, range_infershape_int32_negative_step) {52+TEST_F(RangeInfershape, range_infershape_int32_negative_step)
53- gert::InfershapeContextPara infershapeContextPara("Range",53+{
54- {54+ gert::InfershapeContextPara infershapeContextPara(
55- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, {}},55+ "Range",
56- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, {}},56+ {
57- {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, {}},57+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, {}},
58- },58+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, {}},
59- {59+ {{{1}, {1}}, ge::DT_INT32, ge::FORMAT_ND, {}},
60- {{{}, {}}, ge::DT_INT32, ge::FORMAT_ND},60+ },
61- }61+ {
62- );62+ {{{}, {}}, ge::DT_INT32, ge::FORMAT_ND},
63+ });
63 std::vector<std::vector<int64_t>> expectOutputShape = {{-1}};64 std::vector<std::vector<int64_t>> expectOutputShape = {{-1}};
64 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);65 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
65}66}
66 67 
67// Test: range infershape with float3268// Test: range infershape with float32
68-TEST_F(RangeInfershape, range_infershape_float32) {69+TEST_F(RangeInfershape, range_infershape_float32)
69- gert::InfershapeContextPara infershapeContextPara("Range",70+{
70- {71+ gert::InfershapeContextPara infershapeContextPara(
71- {{{1}, {1}}, ge::DT_FLOAT, ge::FORMAT_ND, {}},72+ "Range",
72- {{{1}, {1}}, ge::DT_FLOAT, ge::FORMAT_ND, {}},73+ {
73- {{{1}, {1}}, ge::DT_FLOAT, ge::FORMAT_ND, {}},74+ {{{1}, {1}}, ge::DT_FLOAT, ge::FORMAT_ND, {}},
74- },75+ {{{1}, {1}}, ge::DT_FLOAT, ge::FORMAT_ND, {}},
75- {76+ {{{1}, {1}}, ge::DT_FLOAT, ge::FORMAT_ND, {}},
76- {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},77+ },
77- }78+ {
78- );79+ {{{}, {}}, ge::DT_FLOAT, ge::FORMAT_ND},
80+ });
79 std::vector<std::vector<int64_t>> expectOutputShape = {{-1}};81 std::vector<std::vector<int64_t>> expectOutputShape = {{-1}};
80 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);82 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
81}83}
82 84 
83// Test: range infershape with float1685// Test: range infershape with float16
84-TEST_F(RangeInfershape, range_infershape_float16) {86+TEST_F(RangeInfershape, range_infershape_float16)
85- gert::InfershapeContextPara infershapeContextPara("Range",87+{
86- {88+ gert::InfershapeContextPara infershapeContextPara(
87- {{{1}, {1}}, ge::DT_FLOAT16, ge::FORMAT_ND, {}},89+ "Range",
88- {{{1}, {1}}, ge::DT_FLOAT16, ge::FORMAT_ND, {}},90+ {
89- {{{1}, {1}}, ge::DT_FLOAT16, ge::FORMAT_ND, {}},91+ {{{1}, {1}}, ge::DT_FLOAT16, ge::FORMAT_ND, {}},
90- },92+ {{{1}, {1}}, ge::DT_FLOAT16, ge::FORMAT_ND, {}},
91- {93+ {{{1}, {1}}, ge::DT_FLOAT16, ge::FORMAT_ND, {}},
92- {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},94+ },
93- }95+ {
94- );96+ {{{}, {}}, ge::DT_FLOAT16, ge::FORMAT_ND},
97+ });
95 std::vector<std::vector<int64_t>> expectOutputShape = {{-1}};98 std::vector<std::vector<int64_t>> expectOutputShape = {{-1}};
96 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);99 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
97}100}
98 101 
99// Test: range infershape with bfloat16102// Test: range infershape with bfloat16
100-TEST_F(RangeInfershape, range_infershape_bfloat16) {103+TEST_F(RangeInfershape, range_infershape_bfloat16)
101- gert::InfershapeContextPara infershapeContextPara("Range",104+{
102- {105+ gert::InfershapeContextPara infershapeContextPara(
103- {{{1}, {1}}, ge::DT_BF16, ge::FORMAT_ND, {}},106+ "Range",
104- {{{1}, {1}}, ge::DT_BF16, ge::FORMAT_ND, {}},107+ {
105- {{{1}, {1}}, ge::DT_BF16, ge::FORMAT_ND, {}},108+ {{{1}, {1}}, ge::DT_BF16, ge::FORMAT_ND, {}},
106- },109+ {{{1}, {1}}, ge::DT_BF16, ge::FORMAT_ND, {}},
107- {110+ {{{1}, {1}}, ge::DT_BF16, ge::FORMAT_ND, {}},
108- {{{}, {}}, ge::DT_BF16, ge::FORMAT_ND},111+ },
109- }112+ {
110- );113+ {{{}, {}}, ge::DT_BF16, ge::FORMAT_ND},
114+ });
111 std::vector<std::vector<int64_t>> expectOutputShape = {{-1}};115 std::vector<std::vector<int64_t>> expectOutputShape = {{-1}};
112 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);116 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
113}117}
114 118 
115// Test: range infershape with int64119// Test: range infershape with int64
116-TEST_F(RangeInfershape, range_infershape_int64) {120+TEST_F(RangeInfershape, range_infershape_int64)
117- gert::InfershapeContextPara infershapeContextPara("Range",121+{
118- {122+ gert::InfershapeContextPara infershapeContextPara(
119- {{{1}, {1}}, ge::DT_INT64, ge::FORMAT_ND, {}},123+ "Range",
120- {{{1}, {1}}, ge::DT_INT64, ge::FORMAT_ND, {}},124+ {
121- {{{1}, {1}}, ge::DT_INT64, ge::FORMAT_ND, {}},125+ {{{1}, {1}}, ge::DT_INT64, ge::FORMAT_ND, {}},
122- },126+ {{{1}, {1}}, ge::DT_INT64, ge::FORMAT_ND, {}},
123- {127+ {{{1}, {1}}, ge::DT_INT64, ge::FORMAT_ND, {}},
124- {{{}, {}}, ge::DT_INT64, ge::FORMAT_ND},128+ },
125- }129+ {
126- );130+ {{{}, {}}, ge::DT_INT64, ge::FORMAT_ND},
131+ });
127 std::vector<std::vector<int64_t>> expectOutputShape = {{-1}};132 std::vector<std::vector<int64_t>> expectOutputShape = {{-1}};
128 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);133 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
129}134}
130 135 
131// Test: range infershape with double136// Test: range infershape with double
132-TEST_F(RangeInfershape, range_infershape_double) {137+TEST_F(RangeInfershape, range_infershape_double)
133- gert::InfershapeContextPara infershapeContextPara("Range",138+{
134- {139+ gert::InfershapeContextPara infershapeContextPara(
135- {{{1}, {1}}, ge::DT_DOUBLE, ge::FORMAT_ND, {}},140+ "Range",
136- {{{1}, {1}}, ge::DT_DOUBLE, ge::FORMAT_ND, {}},141+ {
137- {{{1}, {1}}, ge::DT_DOUBLE, ge::FORMAT_ND, {}},142+ {{{1}, {1}}, ge::DT_DOUBLE, ge::FORMAT_ND, {}},
138- },143+ {{{1}, {1}}, ge::DT_DOUBLE, ge::FORMAT_ND, {}},
139- {144+ {{{1}, {1}}, ge::DT_DOUBLE, ge::FORMAT_ND, {}},
140- {{{}, {}}, ge::DT_DOUBLE, ge::FORMAT_ND},145+ },
141- }146+ {
142- );147+ {{{}, {}}, ge::DT_DOUBLE, ge::FORMAT_ND},
148+ });
143 std::vector<std::vector<int64_t>> expectOutputShape = {{-1}};149 std::vector<std::vector<int64_t>> expectOutputShape = {{-1}};
144 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);150 ExecuteTestCase(infershapeContextPara, ge::GRAPH_SUCCESS, expectOutputShape);
145}151}