已合并
修复A5算子truncate_div在int64除0默认值 #3407
yefeicoding创建于 6月17日
修复A5算子truncate_div在int64除0默认值 #3407
已合并
yefeicoding创建于 6月17日
3 个文件变更+9-12
@@ -48,21 +48,21 @@
48 <td>x1</td>48 <td>x1</td>
49 <td>输入</td>49 <td>输入</td>
50 <td>公式中的被除数。</td>50 <td>公式中的被除数。</td>
51- <td>FLOAT16、FLOAT、INT32、UINT8、INT8、INT64、INT16</td>51+ <td>BFLOAT16、FLOAT16、FLOAT、INT32、UINT8、INT8、INT64、INT16</td>
52 <td>ND</td>52 <td>ND</td>
53 </tr>53 </tr>
54 <tr>54 <tr>
55 <td>x2</td>55 <td>x2</td>
56 <td>输入</td>56 <td>输入</td>
57 <td>公式中的除数。</td>57 <td>公式中的除数。</td>
58- <td>FLOAT16、FLOAT、INT32、UINT8、INT8、INT64、INT16</td>58+ <td>BFLOAT16、FLOAT16、FLOAT、INT32、UINT8、INT8、INT64、INT16</td>
59 <td>ND</td>59 <td>ND</td>
60 </tr>60 </tr>
61 <tr>61 <tr>
62 <td>y</td>62 <td>y</td>
63 <td>输出</td>63 <td>输出</td>
64 <td>公式中的out,截断除法结果。</td>64 <td>公式中的out,截断除法结果。</td>
65- <td>FLOAT16、FLOAT、INT32、UINT8、INT8、INT64、INT16</td>65+ <td>BFLOAT16、FLOAT16、FLOAT、INT32、UINT8、INT8、INT64、INT16</td>
66 <td>ND</td>66 <td>ND</td>
67 </tr>67 </tr>
68 </tbody></table>68 </tbody></table>
@@ -27,7 +27,7 @@ namespace ge {
27 * @par Inputs:27 * @par Inputs:
28 * Two inputs, including:28 * Two inputs, including:
29 * @li x1: A ND Tensor. Must be one of the following types:29 * @li x1: A ND Tensor. Must be one of the following types:
30- * bfloat16, float16, float32, double, int8, uint8, uint16, int16, int32, int64, complex64, complex128. The format can be ND.30+ * bfloat16, float16, float32, double, int8, uint8, uint16, int16, int32, int64. The format can be ND.
31 * @li x2: A ND Tensor. Has the same dtype and format as input "x1". \n31 * @li x2: A ND Tensor. Has the same dtype and format as input "x1". \n
32 32 
33 * @par Outputs:33 * @par Outputs:
@@ -39,16 +39,13 @@ namespace ge {
39REG_OP(TruncateDiv)39REG_OP(TruncateDiv)
40 .INPUT(40 .INPUT(
41 x1, TensorType(41 x1, TensorType(
42- {DT_FLOAT, DT_FLOAT16, DT_BF16, DT_INT8, DT_UINT8, DT_INT32, DT_DOUBLE, DT_UINT16, DT_INT16, DT_INT64,42+ {DT_FLOAT, DT_FLOAT16, DT_BF16, DT_INT8, DT_UINT8, DT_INT32, DT_DOUBLE, DT_UINT16, DT_INT16, DT_INT64}))
43- DT_COMPLEX64, DT_COMPLEX128}))
44 .INPUT(43 .INPUT(
45 x2, TensorType(44 x2, TensorType(
46- {DT_FLOAT, DT_FLOAT16, DT_BF16, DT_INT8, DT_UINT8, DT_INT32, DT_DOUBLE, DT_UINT16, DT_INT16, DT_INT64,45+ {DT_FLOAT, DT_FLOAT16, DT_BF16, DT_INT8, DT_UINT8, DT_INT32, DT_DOUBLE, DT_UINT16, DT_INT16, DT_INT64}))
47- DT_COMPLEX64, DT_COMPLEX128}))
48 .OUTPUT(46 .OUTPUT(
49 y, TensorType(47 y, TensorType(
50- {DT_FLOAT, DT_FLOAT16, DT_BF16, DT_INT8, DT_UINT8, DT_INT32, DT_DOUBLE, DT_UINT16, DT_INT16, DT_INT64,48+ {DT_FLOAT, DT_FLOAT16, DT_BF16, DT_INT8, DT_UINT8, DT_INT32, DT_DOUBLE, DT_UINT16, DT_INT16, DT_INT64}))
51- DT_COMPLEX64, DT_COMPLEX128}))
52 .OP_END_FACTORY_REG(TruncateDiv)49 .OP_END_FACTORY_REG(TruncateDiv)
53 50 
54} // namespace ge51} // namespace ge
@@ -32,7 +32,7 @@ constexpr int TRUNCATE_DIV_CAST_MODE_NONE = 0;
32constexpr int TRUNCATE_DIV_CAST_MODE_RINT = 1;32constexpr int TRUNCATE_DIV_CAST_MODE_RINT = 1;
33constexpr int8_t SAT_POS = 60;33constexpr int8_t SAT_POS = 60;
34constexpr int64_t INT64_MAX_VALUE = 9223372036854775807;34constexpr int64_t INT64_MAX_VALUE = 9223372036854775807;
35-constexpr int64_t INT32_MAX_VALUE = 2147483647;35+constexpr int64_t UINT32_MAX_VALUE = 4294967295;
36const uint32_t UINT32_SIGN = 0x80000000;36const uint32_t UINT32_SIGN = 0x80000000;
37const uint16_t UINT16_SIGN = 0x8000;37const uint16_t UINT16_SIGN = 0x8000;
38constexpr uint32_t TRUNCATE_DIV_SIMT_THREADS = 1024;38constexpr uint32_t TRUNCATE_DIV_SIMT_THREADS = 1024;
@@ -185,7 +185,7 @@ __simt_vf__ __aicore__ LAUNCH_BOUND(TRUNCATE_DIV_SIMT_THREADS) inline void Trunc
185 bool pos_div_zero = ((src1[index] >= 0) && (src1[index] < INT64_MAX_VALUE) && (src2[index] == 0));185 bool pos_div_zero = ((src1[index] >= 0) && (src1[index] < INT64_MAX_VALUE) && (src2[index] == 0));
186 bool div_zero = (src2[index] == 0);186 bool div_zero = (src2[index] == 0);
187 if (pos_div_zero) {187 if (pos_div_zero) {
188- dst[index] = INT32_MAX_VALUE;188+ dst[index] = UINT32_MAX_VALUE;
189 } else if (div_zero) {189 } else if (div_zero) {
190 dst[index] = -1;190 dst[index] = -1;
191 } else {191 } else {