Merged
bitwise_and新增int8/uint8/uint32/uint64数据类型支持 [9.2.0同步] #5573
wangqi_aiAdd on Sep 10
bitwise_and新增int8/uint8/uint32/uint64数据类型支持 [9.2.0同步] #5573
Merged
Total: 12 files changed+803-421
| @@ -23,10 +23,10 @@ | |||
| 23 | ## 参数说明 | 23 | ## 参数说明 |
| 24 | 24 | ||
| 25 | - self(aclTensor*,计算输入):公式中的```self```,支持[非连续的Tensor](../../docs/zh/context/non_contiguous_tensor.md),[数据格式](../../docs/zh/context/data_format.md)支持ND,数据维度不支持8维以上。 | 25 | - self(aclTensor*,计算输入):公式中的```self```,支持[非连续的Tensor](../../docs/zh/context/non_contiguous_tensor.md),[数据格式](../../docs/zh/context/data_format.md)支持ND,数据维度不支持8维以上。 |
| 26 | - - <term>Ascend 950PR/Ascend 950DT</term>:数据类型支持INT16、UINT16、INT32、INT64、INT8、UINT8、BOOL,且数据类型与other的数据类型需满足数据类型推导规则(参见[TensorScalar互推导关系](../../docs/zh/context/deduction_relationship.md)),推导后的数据类型需在支持的数据类型范围内。 | 26 | + - <term>Ascend 950PR/Ascend 950DT</term>:数据类型支持INT16、UINT16、INT32、INT64、INT8、UINT8、UINT32、UINT64、BOOL,且数据类型与other的数据类型需满足数据类型推导规则(参见[TensorScalar互推导关系](../../docs/zh/context/deduction_relationship.md)),推导后的数据类型需在支持的数据类型范围内。 |
| 27 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>:数据类型支持INT16、UINT16、INT32、INT64、INT8、UINT8、BOOL,且数据类型需要与other满足数据类型推导规则(参见[互推导关系](../../docs/zh/context/deduction_relationship.md)),推导后的数据类型需在支持的数据类型范围内。 | 27 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>:数据类型支持INT16、UINT16、INT32、INT64、INT8、UINT8、BOOL,且数据类型需要与other满足数据类型推导规则(参见[互推导关系](../../docs/zh/context/deduction_relationship.md)),推导后的数据类型需在支持的数据类型范围内。 |
| 28 | - other(aclScalar*,计算输入):公式中的```other```。 | 28 | - other(aclScalar*,计算输入):公式中的```other```。 |
| 29 | - - <term>Ascend 950PR/Ascend 950DT</term>:数据类型支持INT16、UINT16、INT32、INT64、INT8、UINT8、BOOL,且数据类型与self的数据类型需满足数据类型推导规则(参见[TensorScalar互推导关系](../../docs/zh/context/deduction_relationship.md)),推导后的数据类型需在支持的数据类型范围内。 | 29 | + - <term>Ascend 950PR/Ascend 950DT</term>:数据类型支持INT16、UINT16、INT32、INT64、INT8、UINT8、UINT32、UINT64、BOOL,且数据类型与self的数据类型需满足数据类型推导规则(参见[TensorScalar互推导关系](../../docs/zh/context/deduction_relationship.md)),推导后的数据类型需在支持的数据类型范围内。 |
| 30 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>:数据类型支持INT16、UINT16、INT32、INT64、INT8、UINT8、BOOL,且数据类型需要与self满足数据类型推导规则(参见[互推导关系](../../docs/zh/context/deduction_relationship.md)),推导后的数据类型需在支持的数据类型范围内。 | 30 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>:数据类型支持INT16、UINT16、INT32、INT64、INT8、UINT8、BOOL,且数据类型需要与self满足数据类型推导规则(参见[互推导关系](../../docs/zh/context/deduction_relationship.md)),推导后的数据类型需在支持的数据类型范围内。 |
| 31 | - out(aclTensor\*,计算输出):公式中的```out```,数据类型需要是self与other推导之后可转换的数据类型(参见[互转换关系](../../docs/zh/context/conversion_relationship.md)),shape需要与self保持一致,[数据格式](../../docs/zh/context/data_format.md)支持ND,数据维度不支持8维以上。 | 31 | - out(aclTensor\*,计算输出):公式中的```out```,数据类型需要是self与other推导之后可转换的数据类型(参见[互转换关系](../../docs/zh/context/conversion_relationship.md)),shape需要与self保持一致,[数据格式](../../docs/zh/context/data_format.md)支持ND,数据维度不支持8维以上。 |
| 32 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>:数据类型支持BOOL、INT8、INT16、UINT16、INT32、INT64、UINT8、FLOAT、FLOAT16、DOUBLE、BFLOAT16。 | 32 | - <term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>:数据类型支持BOOL、INT8、INT16、UINT16、INT32、INT64、UINT8、FLOAT、FLOAT16、DOUBLE、BFLOAT16。 |
| @@ -85,7 +85,7 @@ aclnnStatus aclnnBitwiseAndScalar( | |||
| 85 | <td>输入</td> | 85 | <td>输入</td> |
| 86 | <td>公式中的self。</td> | 86 | <td>公式中的self。</td> |
| 87 | <td>数据类型与other需满足数据类型推导规则(参见<a href="../../../docs/zh/context/conversion_relationship.md" target="_blank">互转换关系</a>),推导后的数据类型需在支持的数据类型范围内。</td> | 87 | <td>数据类型与other需满足数据类型推导规则(参见<a href="../../../docs/zh/context/conversion_relationship.md" target="_blank">互转换关系</a>),推导后的数据类型需在支持的数据类型范围内。</td> |
| 88 | - <td>INT16、UINT16、INT32、INT64、INT8、UINT8、BOOL</td> | 88 | + <td>INT16、UINT16、INT32、INT64、INT8、UINT8、UINT32、UINT64、BOOL</td> |
| 89 | <td>ND</td> | 89 | <td>ND</td> |
| 90 | <td>不超过8维</td> | 90 | <td>不超过8维</td> |
| 91 | <td>√</td> | 91 | <td>√</td> |
| @@ -95,7 +95,7 @@ aclnnStatus aclnnBitwiseAndScalar( | |||
| 95 | <td>输入</td> | 95 | <td>输入</td> |
| 96 | <td>公式中的other。</td> | 96 | <td>公式中的other。</td> |
| 97 | <td>数据类型与self需满足数据类型推导规则(参见<a href="../../../docs/zh/context/conversion_relationship.md" target="_blank">互转换关系</a>),推导后的数据类型需在支持的数据类型范围内。</td> | 97 | <td>数据类型与self需满足数据类型推导规则(参见<a href="../../../docs/zh/context/conversion_relationship.md" target="_blank">互转换关系</a>),推导后的数据类型需在支持的数据类型范围内。</td> |
| 98 | - <td>INT16、UINT16、INT32、INT64、INT8、UINT8、BOOL</td> | 98 | + <td>INT16、UINT16、INT32、INT64、INT8、UINT8、UINT32、UINT64、BOOL</td> |
| 99 | <td>-</td> | 99 | <td>-</td> |
| 100 | <td>-</td> | 100 | <td>-</td> |
| 101 | <td>-</td> | 101 | <td>-</td> |
| @@ -132,6 +132,10 @@ aclnnStatus aclnnBitwiseAndScalar( | |||
| 132 | </tr> | 132 | </tr> |
| 133 | </tbody></table> | 133 | </tbody></table> |
| 134 | 134 | ||
| 135 | + <!-- npu="A3,910b,910,310p" id7 --> | ||
| 136 | + - <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>、<term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas 推理系列产品</term>、<term>Atlas 训练系列产品</term>:self和other的数据类型不支持UINT32、UINT64。 | ||
| 137 | + <!-- end id7 --> | ||
| 138 | + | ||
| 135 | - **返回值:** | 139 | - **返回值:** |
| 136 | 140 | ||
| 137 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn_return_code.md)。 | 141 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn_return_code.md)。 |
| @@ -85,7 +85,7 @@ aclnnStatus aclnnBitwiseAndTensor( | |||
| 85 | <td>输入</td> | 85 | <td>输入</td> |
| 86 | <td>公式中的self。</td> | 86 | <td>公式中的self。</td> |
| 87 | <td><ul><li>数据类型需要与other满足数据类型推导规则(参见<a href="../../../docs/zh/context/conversion_relationship.md" target="_blank">互转换关系</a>)。</li><li>shape需要与other满足<a href="../../../docs/zh/context/broadcast_relationship.md" target="_blank">broadcast关系</a>。</li></ul></td> | 87 | <td><ul><li>数据类型需要与other满足数据类型推导规则(参见<a href="../../../docs/zh/context/conversion_relationship.md" target="_blank">互转换关系</a>)。</li><li>shape需要与other满足<a href="../../../docs/zh/context/broadcast_relationship.md" target="_blank">broadcast关系</a>。</li></ul></td> |
| 88 | - <td>BOOL、INT8、INT16、INT32、INT64、UINT8、UINT16</td> | 88 | + <td>BOOL、INT8、INT16、INT32、INT64、UINT8、UINT16、UINT32、UINT64</td> |
| 89 | <td>ND</td> | 89 | <td>ND</td> |
| 90 | <td>不超过8维</td> | 90 | <td>不超过8维</td> |
| 91 | <td>√</td> | 91 | <td>√</td> |
| @@ -95,7 +95,7 @@ aclnnStatus aclnnBitwiseAndTensor( | |||
| 95 | <td>输入</td> | 95 | <td>输入</td> |
| 96 | <td>公式中的other。</td> | 96 | <td>公式中的other。</td> |
| 97 | <td><ul><li>数据类型需要与self满足数据类型推导规则(参见<a href="../../../docs/zh/context/conversion_relationship.md" target="_blank">互转换关系</a>)。</li><li>shape需要与self满足broadcast关系。</li></ul></td> | 97 | <td><ul><li>数据类型需要与self满足数据类型推导规则(参见<a href="../../../docs/zh/context/conversion_relationship.md" target="_blank">互转换关系</a>)。</li><li>shape需要与self满足broadcast关系。</li></ul></td> |
| 98 | - <td>BOOL、INT8、INT16、INT32、INT64、UINT8、UINT16</td> | 98 | + <td>BOOL、INT8、INT16、INT32、INT64、UINT8、UINT16、UINT32、UINT64</td> |
| 99 | <td>ND</td> | 99 | <td>ND</td> |
| 100 | <td>不超过8维</td> | 100 | <td>不超过8维</td> |
| 101 | <td>√</td> | 101 | <td>√</td> |
| @@ -83,7 +83,7 @@ aclnnStatus aclnnInplaceBitwiseAndScalar( | |||
| 83 | <td>输入/输出</td> | 83 | <td>输入/输出</td> |
| 84 | <td>公式中的selfRef。</td> | 84 | <td>公式中的selfRef。</td> |
| 85 | <td>数据类型与other的数据类型需满足<a href="../../../docs/zh/context/deduction_relationship.md" target="_blank">数据类型推导规则</a>,且需要是推导之后可转换的数据类型。</td> | 85 | <td>数据类型与other的数据类型需满足<a href="../../../docs/zh/context/deduction_relationship.md" target="_blank">数据类型推导规则</a>,且需要是推导之后可转换的数据类型。</td> |
| 86 | - <td>INT16、UINT16、INT32、INT64、INT8、UINT8、BOOL</td> | 86 | + <td>INT16、UINT16、INT32、INT64、INT8、UINT8、UINT32、UINT64、BOOL</td> |
| 87 | <td>ND</td> | 87 | <td>ND</td> |
| 88 | <td>0-8</td> | 88 | <td>0-8</td> |
| 89 | <td>√</td> | 89 | <td>√</td> |
| @@ -93,7 +93,7 @@ aclnnStatus aclnnInplaceBitwiseAndScalar( | |||
| 93 | <td>输入</td> | 93 | <td>输入</td> |
| 94 | <td>公式中的other。</td> | 94 | <td>公式中的other。</td> |
| 95 | <td>数据类型与selfRef的数据类型需满足<a href="../../../docs/zh/context/deduction_relationship.md" target="_blank">数据类型推导规则</a>。</td> | 95 | <td>数据类型与selfRef的数据类型需满足<a href="../../../docs/zh/context/deduction_relationship.md" target="_blank">数据类型推导规则</a>。</td> |
| 96 | - <td>INT16、UINT16、INT32、INT64、INT8、UINT8、BOOL</td> | 96 | + <td>INT16、UINT16、INT32、INT64、INT8、UINT8、UINT32、UINT64、BOOL</td> |
| 97 | <td>-</td> | 97 | <td>-</td> |
| 98 | <td>-</td> | 98 | <td>-</td> |
| 99 | <td>-</td> | 99 | <td>-</td> |
| @@ -120,6 +120,10 @@ aclnnStatus aclnnInplaceBitwiseAndScalar( | |||
| 120 | </tr> | 120 | </tr> |
| 121 | </tbody></table> | 121 | </tbody></table> |
| 122 | 122 | ||
| 123 | + <!-- npu="A3,910b,910,310p" id7 --> | ||
| 124 | + - <term>Atlas A3 训练系列产品/Atlas A3 推理系列产品</term>、<term>Atlas A2 训练系列产品/Atlas A2 推理系列产品</term>、<term>Atlas 推理系列产品</term>、<term>Atlas 训练系列产品</term>:selfRef和other的数据类型不支持UINT32、UINT64。 | ||
| 125 | + <!-- end id7 --> | ||
| 126 | + | ||
| 123 | - **返回值:** | 127 | - **返回值:** |
| 124 | 128 | ||
| 125 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn_return_code.md)。 | 129 | aclnnStatus:返回状态码,具体参见[aclnn返回码](../../../docs/zh/context/aclnn_return_code.md)。 |
| @@ -83,7 +83,7 @@ aclnnStatus aclnnInplaceBitwiseAndTensor( | |||
| 83 | <td>输入/输出</td> | 83 | <td>输入/输出</td> |
| 84 | <td>输入和输出tensor,公式中的selfRef。</td> | 84 | <td>输入和输出tensor,公式中的selfRef。</td> |
| 85 | <td>数据类型需要与other的数据类型满足<a href="../../../docs/zh/context/deduction_relationship.md" target="_blank">数据类型推导规则</a>。shape需要与other满足<a href="../../../docs/zh/context/broadcast_relationship.md" target="_blank">broadcast关系</a>。</td> | 85 | <td>数据类型需要与other的数据类型满足<a href="../../../docs/zh/context/deduction_relationship.md" target="_blank">数据类型推导规则</a>。shape需要与other满足<a href="../../../docs/zh/context/broadcast_relationship.md" target="_blank">broadcast关系</a>。</td> |
| 86 | - <td>INT16、UINT16、INT32、INT64、INT8、UINT8、BOOL</td> | 86 | + <td>INT16、UINT16、INT32、INT64、INT8、UINT8、UINT32、UINT64、BOOL</td> |
| 87 | <td>ND</td> | 87 | <td>ND</td> |
| 88 | <td>0-8</td> | 88 | <td>0-8</td> |
| 89 | <td>√</td> | 89 | <td>√</td> |
| @@ -93,7 +93,7 @@ aclnnStatus aclnnInplaceBitwiseAndTensor( | |||
| 93 | <td>输入</td> | 93 | <td>输入</td> |
| 94 | <td>输入tensor,公式中的other。</td> | 94 | <td>输入tensor,公式中的other。</td> |
| 95 | <td>数据类型需要与selfRef构成满足<a href="../../../docs/zh/context/deduction_relationship.md" target="_blank">数据类型推导规则</a>。shape需要与selfRef满足<a href="../../../docs/zh/context/broadcast_relationship.md" target="_blank">broadcast关系</a>。</td> | 95 | <td>数据类型需要与selfRef构成满足<a href="../../../docs/zh/context/deduction_relationship.md" target="_blank">数据类型推导规则</a>。shape需要与selfRef满足<a href="../../../docs/zh/context/broadcast_relationship.md" target="_blank">broadcast关系</a>。</td> |
| 96 | - <td>INT16、UINT16、INT32、INT64、INT8、UINT8、BOOL</td> | 96 | + <td>INT16、UINT16、INT32、INT64、INT8、UINT8、UINT32、UINT64、BOOL</td> |
| 97 | <td>ND</td> | 97 | <td>ND</td> |
| 98 | <td>0-8</td> | 98 | <td>0-8</td> |
| 99 | <td>√</td> | 99 | <td>√</td> |
| @@ -31,221 +31,241 @@ using namespace op; | |||
| 31 | extern "C" { | 31 | extern "C" { |
| 32 | #endif | 32 | #endif |
| 33 | 33 | ||
| 34 | -static op::DataType InnerTypeToComplexType(const op::DataType input) { | 34 | +static op::DataType InnerTypeToComplexType(const op::DataType input) |
| 35 | - switch (input) { | 35 | +{ |
| 36 | - case op::DataType::DT_BF16: | 36 | + switch (input) { |
| 37 | - // BFloat16 has range equivalent to Float, | 37 | + case op::DataType::DT_BF16: |
| 38 | - // so we map it to ComplexFloat. | 38 | + // BFloat16 has range equivalent to Float, |
| 39 | - return op::DataType::DT_COMPLEX64; | 39 | + // so we map it to ComplexFloat. |
| 40 | - case op::DataType::DT_FLOAT16: | 40 | + return op::DataType::DT_COMPLEX64; |
| 41 | - return op::DataType::DT_COMPLEX32; | 41 | + case op::DataType::DT_FLOAT16: |
| 42 | - case op::DataType::DT_FLOAT: | 42 | + return op::DataType::DT_COMPLEX32; |
| 43 | - return op::DataType::DT_COMPLEX64; | 43 | + case op::DataType::DT_FLOAT: |
| 44 | - case op::DataType::DT_DOUBLE: | 44 | + return op::DataType::DT_COMPLEX64; |
| 45 | - return op::DataType::DT_COMPLEX128; | 45 | + case op::DataType::DT_DOUBLE: |
| 46 | - case op::DataType::DT_COMPLEX32: | 46 | + return op::DataType::DT_COMPLEX128; |
| 47 | - return op::DataType::DT_COMPLEX32; | 47 | + case op::DataType::DT_COMPLEX32: |
| 48 | - case op::DataType::DT_COMPLEX64: | 48 | + return op::DataType::DT_COMPLEX32; |
| 49 | - return op::DataType::DT_COMPLEX64; | 49 | + case op::DataType::DT_COMPLEX64: |
| 50 | - case op::DataType::DT_COMPLEX128: | 50 | + return op::DataType::DT_COMPLEX64; |
| 51 | - return op::DataType::DT_COMPLEX128; | 51 | + case op::DataType::DT_COMPLEX128: |
| 52 | - default: | 52 | + return op::DataType::DT_COMPLEX128; |
| 53 | - OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Unknown Complex ScalarType for [%s]", ToString(input).GetString()); | 53 | + default: |
| 54 | - return op::DataType::DT_UNDEFINED; | 54 | + OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Unknown Complex ScalarType for [%s]", ToString(input).GetString()); |
| 55 | - } | 55 | + return op::DataType::DT_UNDEFINED; |
| 56 | -} | ||
| 57 | - | ||
| 58 | -static op::DataType CombineCategoriesWithComplex(const op::DataType higher, const op::DataType lower) { | ||
| 59 | - if(IsComplexType(higher)) { | ||
| 60 | - return higher; | ||
| 61 | - } else if (IsComplexType(lower)) { | ||
| 62 | - // preserve value type of higher if it is floating type. | ||
| 63 | - if (IsFloatingType(higher)) { | ||
| 64 | - return InnerTypeToComplexType(higher); | ||
| 65 | } | 56 | } |
| 66 | - // in case of integral input | ||
| 67 | - // lower complex takes precedence. | ||
| 68 | - return lower; | ||
| 69 | - } else if (IsFloatingType(higher)) { | ||
| 70 | - return higher; | ||
| 71 | - } | ||
| 72 | - if (higher == op::DataType::DT_BOOL || IsFloatingType(lower)) { | ||
| 73 | - return op::PromoteType(higher, lower); | ||
| 74 | - } | ||
| 75 | - if (higher != op::DataType::DT_UNDEFINED) { | ||
| 76 | - return higher; | ||
| 77 | - } | ||
| 78 | - return lower; | ||
| 79 | } | 57 | } |
| 80 | 58 | ||
| 81 | -static op::DataType GetScalarDefaultDtype(const op::DataType input) { | 59 | +static op::DataType CombineCategoriesWithComplex(const op::DataType higher, const op::DataType lower) |
| 82 | - if (IsComplexType(input)) { | 60 | +{ |
| 83 | - return op::DataType::DT_COMPLEX64; | 61 | + if (IsComplexType(higher)) { |
| 84 | - } else if (IsFloatingType(input)) { | 62 | + return higher; |
| 85 | - return op::DataType::DT_FLOAT; | 63 | + } else if (IsComplexType(lower)) { |
| 86 | - } | 64 | + // preserve value type of higher if it is floating type. |
| 87 | - return input; | 65 | + if (IsFloatingType(higher)) { |
| 66 | + return InnerTypeToComplexType(higher); | ||
| 67 | + } | ||
| 68 | + // in case of integral input | ||
| 69 | + // lower complex takes precedence. | ||
| 70 | + return lower; | ||
| 71 | + } else if (IsFloatingType(higher)) { | ||
| 72 | + return higher; | ||
| 73 | + } | ||
| 74 | + if (higher == op::DataType::DT_BOOL || IsFloatingType(lower)) { | ||
| 75 | + return op::PromoteType(higher, lower); | ||
| 76 | + } | ||
| 77 | + if (higher != op::DataType::DT_UNDEFINED) { | ||
| 78 | + return higher; | ||
| 79 | + } | ||
| 80 | + return lower; | ||
| 81 | +} | ||
| 82 | + | ||
| 83 | +static op::DataType GetScalarDefaultDtype(const op::DataType input) | ||
| 84 | +{ | ||
| 85 | + if (IsComplexType(input)) { | ||
| 86 | + return op::DataType::DT_COMPLEX64; | ||
| 87 | + } else if (IsFloatingType(input)) { | ||
| 88 | + return op::DataType::DT_FLOAT; | ||
| 89 | + } | ||
| 90 | + return input; | ||
| 88 | } | 91 | } |
| 89 | 92 | ||
| 90 | // 根据API定义,需要列出所能支持的所有dtype | 93 | // 根据API定义,需要列出所能支持的所有dtype |
| 91 | -static const std::initializer_list<op::DataType> DTYPE_SUPPORT_LIST = { | 94 | +static const std::initializer_list<op::DataType> DTYPE_SUPPORT_LIST_DEFAULT = { |
| 92 | op::DataType::DT_INT16, op::DataType::DT_INT32, op::DataType::DT_INT64, op::DataType::DT_INT8, | 95 | op::DataType::DT_INT16, op::DataType::DT_INT32, op::DataType::DT_INT64, op::DataType::DT_INT8, |
| 93 | - op::DataType::DT_UINT8, op::DataType::DT_BOOL, op::DataType::DT_UINT16}; | 96 | + op::DataType::DT_UINT8, op::DataType::DT_BOOL, op::DataType::DT_UINT16}; |
| 94 | 97 | ||
| 95 | -static bool CheckNotNull(const aclTensor *self, const aclScalar *other, const aclTensor *out) { | 98 | +// RegBase(Ascend 950)上scalar接口额外支持uint32/uint64,对齐bitwise_or |
| 96 | - OP_CHECK_NULL(self, return false); | 99 | +static const std::initializer_list<op::DataType> REGBASE_DTYPE_SUPPORT_LIST = { |
| 97 | - OP_CHECK_NULL(other, return false); | 100 | + op::DataType::DT_INT8, op::DataType::DT_INT16, op::DataType::DT_INT32, |
| 98 | - OP_CHECK_NULL(out, return false); | 101 | + op::DataType::DT_INT64, op::DataType::DT_UINT8, op::DataType::DT_UINT16, |
| 102 | + op::DataType::DT_UINT32, op::DataType::DT_UINT64, op::DataType::DT_BOOL}; | ||
| 99 | 103 | ||
| 100 | - return true; | 104 | +static bool CheckNotNull(const aclTensor* self, const aclScalar* other, const aclTensor* out) |
| 105 | +{ | ||
| 106 | + OP_CHECK_NULL(self, return false); | ||
| 107 | + OP_CHECK_NULL(other, return false); | ||
| 108 | + OP_CHECK_NULL(out, return false); | ||
| 109 | + | ||
| 110 | + return true; | ||
| 101 | } | 111 | } |
| 102 | 112 | ||
| 103 | -static bool CheckDtypeValid(const aclTensor *self, const aclScalar *other) { | 113 | +static bool CheckDtypeValid(const aclTensor* self, const aclScalar* other) |
| 104 | - // 检查self的数据类型是否在and算子的支持列表内 | 114 | +{ |
| 105 | - OP_CHECK_DTYPE_NOT_SUPPORT(self, DTYPE_SUPPORT_LIST, return false); | 115 | + auto supportList = IsRegBase() ? REGBASE_DTYPE_SUPPORT_LIST : DTYPE_SUPPORT_LIST_DEFAULT; |
| 116 | + // 检查self的数据类型是否在and算子的支持列表内 | ||
| 117 | + OP_CHECK_DTYPE_NOT_SUPPORT(self, supportList, return false); | ||
| 106 | 118 | ||
| 107 | - // 检查other的数据类型是否在and算子的支持列表内 | 119 | + // 检查other的数据类型是否在and算子的支持列表内 |
| 108 | - OP_CHECK_DTYPE_NOT_SUPPORT(other, DTYPE_SUPPORT_LIST, return false); | 120 | + OP_CHECK_DTYPE_NOT_SUPPORT(other, supportList, return false); |
| 109 | 121 | ||
| 110 | - return true; | 122 | + return true; |
| 111 | } | 123 | } |
| 112 | 124 | ||
| 113 | -static DataType PromoteTypeScalar(const aclTensor* self, const aclScalar* other) { | 125 | +static DataType PromoteTypeScalar(const aclTensor* self, const aclScalar* other) |
| 114 | - if (IsRegBase()) { | 126 | +{ |
| 115 | - auto otherDefaultDtype = GetScalarDefaultDtype(other->GetDataType()); | 127 | + if (IsRegBase()) { |
| 116 | - auto promoteType = CombineCategoriesWithComplex(self->GetDataType(), otherDefaultDtype); | 128 | + auto otherDefaultDtype = GetScalarDefaultDtype(other->GetDataType()); |
| 117 | - return promoteType; | 129 | + auto promoteType = CombineCategoriesWithComplex(self->GetDataType(), otherDefaultDtype); |
| 118 | - } | 130 | + return promoteType; |
| 119 | - return op::PromoteType(self->GetDataType(), other->GetDataType()); | 131 | + } |
| 132 | + return op::PromoteType(self->GetDataType(), other->GetDataType()); | ||
| 120 | } | 133 | } |
| 121 | 134 | ||
| 122 | -static bool CheckPromoteType(const aclTensor *self, const aclScalar *other, const aclTensor *out) { | 135 | +static bool CheckPromoteType(const aclTensor* self, const aclScalar* other, const aclTensor* out) |
| 123 | - // 检查self和other能否做数据类型推导 | 136 | +{ |
| 124 | - op::DataType promoteType = PromoteTypeScalar(self, other); | 137 | + // 检查self和other能否做数据类型推导 |
| 125 | - if (promoteType == DataType::DT_UNDEFINED) { | 138 | + op::DataType promoteType = PromoteTypeScalar(self, other); |
| 126 | - OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Self dtype %s and other dtype %s can not promote dtype.", | 139 | + if (promoteType == DataType::DT_UNDEFINED) { |
| 127 | - op::ToString(self->GetDataType()).GetString(), op::ToString(other->GetDataType()).GetString()); | 140 | + OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Self dtype %s and other dtype %s can not promote dtype.", |
| 128 | - return false; | 141 | + op::ToString(self->GetDataType()).GetString(), op::ToString(other->GetDataType()).GetString()); |
| 129 | - } | 142 | + return false; |
| 143 | + } | ||
| 130 | 144 | ||
| 131 | - // 检查推导后的数据类型能否转换为输出的数据类型 | 145 | + // 检查推导后的数据类型能否转换为输出的数据类型 |
| 132 | - OP_CHECK_RESULT_DTYPE_CAST_FAILED(promoteType, out->GetDataType(), return false); | 146 | + OP_CHECK_RESULT_DTYPE_CAST_FAILED(promoteType, out->GetDataType(), return false); |
| 133 | 147 | ||
| 134 | - return true; | 148 | + return true; |
| 135 | } | 149 | } |
| 136 | 150 | ||
| 137 | -static bool CheckFormat(const aclTensor *self, const aclTensor *out) { | 151 | +static bool CheckFormat(const aclTensor* self, const aclTensor* out) |
| 138 | - // 如果输入格式是私有格式,记录日志,直接报错 | 152 | +{ |
| 139 | - if (op::IsPrivateFormat(self->GetStorageFormat()) || op::IsPrivateFormat(out->GetStorageFormat())) { | 153 | + // 如果输入格式是私有格式,记录日志,直接报错 |
| 140 | - OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Format only support ND,NCHW,NHWC,HWCN,NDHWC,NCDHW."); | 154 | + if (op::IsPrivateFormat(self->GetStorageFormat()) || op::IsPrivateFormat(out->GetStorageFormat())) { |
| 141 | - return false; | 155 | + OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Format only support ND,NCHW,NHWC,HWCN,NDHWC,NCDHW."); |
| 142 | - } | 156 | + return false; |
| 143 | - return true; | 157 | + } |
| 158 | + return true; | ||
| 144 | } | 159 | } |
| 145 | 160 | ||
| 146 | -static bool CheckShape(const aclTensor *self, const aclTensor *out) { | 161 | +static bool CheckShape(const aclTensor* self, const aclTensor* out) |
| 147 | - OP_CHECK_MAX_DIM(self, BITWISE_AND_MAX_TENSOR_DIM, return false); | 162 | +{ |
| 163 | + OP_CHECK_MAX_DIM(self, BITWISE_AND_MAX_TENSOR_DIM, return false); | ||
| 148 | 164 | ||
| 149 | - OP_CHECK_SHAPE_NOT_EQUAL(self, out, return false); | 165 | + OP_CHECK_SHAPE_NOT_EQUAL(self, out, return false); |
| 150 | 166 | ||
| 151 | - return true; | 167 | + return true; |
| 152 | } | 168 | } |
| 153 | 169 | ||
| 154 | -static aclnnStatus CheckParams(const aclTensor *self, const aclScalar *other, const aclTensor *out) { | 170 | +static aclnnStatus CheckParams(const aclTensor* self, const aclScalar* other, const aclTensor* out) |
| 155 | - // 错误码等DFX方案细化后刷新,错误日志在check接口内打印 | 171 | +{ |
| 156 | - // 1. 检查参数是否为空指针 | 172 | + // 错误码等DFX方案细化后刷新,错误日志在check接口内打印 |
| 157 | - CHECK_RET(CheckNotNull(self, other, out), ACLNN_ERR_PARAM_NULLPTR); | 173 | + // 1. 检查参数是否为空指针 |
| 174 | + CHECK_RET(CheckNotNull(self, other, out), ACLNN_ERR_PARAM_NULLPTR); | ||
| 158 | 175 | ||
| 159 | - // 2. 检查输入的数据类型是否在API支持的数据类型范围之内,需要根据api定义校验 | 176 | + // 2. 检查输入的数据类型是否在API支持的数据类型范围之内,需要根据api定义校验 |
| 160 | - CHECK_RET(CheckDtypeValid(self, other), ACLNN_ERR_PARAM_INVALID); | 177 | + CHECK_RET(CheckDtypeValid(self, other), ACLNN_ERR_PARAM_INVALID); |
| 161 | 178 | ||
| 162 | - // 3. 检查self和other能否做数据类型推导以及推导的数据类型能否转换为输出数据类型 | 179 | + // 3. 检查self和other能否做数据类型推导以及推导的数据类型能否转换为输出数据类型 |
| 163 | - CHECK_RET(CheckPromoteType(self, other, out), ACLNN_ERR_PARAM_INVALID); | 180 | + CHECK_RET(CheckPromoteType(self, other, out), ACLNN_ERR_PARAM_INVALID); |
| 164 | 181 | ||
| 165 | - // 4. 检查数据格式是否支持 | 182 | + // 4. 检查数据格式是否支持 |
| 166 | - CHECK_RET(CheckFormat(self, out), ACLNN_ERR_PARAM_INVALID); | 183 | + CHECK_RET(CheckFormat(self, out), ACLNN_ERR_PARAM_INVALID); |
| 167 | 184 | ||
| 168 | - // 5. 检查双输入是否能broadcast | 185 | + // 5. 检查双输入是否能broadcast |
| 169 | - CHECK_RET(CheckShape(self, out), ACLNN_ERR_PARAM_INVALID); | 186 | + CHECK_RET(CheckShape(self, out), ACLNN_ERR_PARAM_INVALID); |
| 170 | 187 | ||
| 171 | - return ACLNN_SUCCESS; | ||
| 172 | -} | ||
| 173 | - | ||
| 174 | -aclnnStatus aclnnBitwiseAndScalarGetWorkspaceSize(const aclTensor *self, const aclScalar *other, | ||
| 175 | - aclTensor *out, uint64_t *workspaceSize, aclOpExecutor **executor) { | ||
| 176 | - L2_DFX_PHASE_1(aclnnBitwiseAndScalar, DFX_IN(self, other), DFX_OUT(out)); | ||
| 177 | - // 固定写法,创建OpExecutor | ||
| 178 | - auto uniqueExecutor = CREATE_EXECUTOR(); | ||
| 179 | - CHECK_RET(uniqueExecutor.get() != nullptr, ACLNN_ERR_INNER_CREATE_EXECUTOR); | ||
| 180 | - | ||
| 181 | - // 固定写法,参数检查 | ||
| 182 | - auto ret = CheckParams(self, other, out); | ||
| 183 | - CHECK_RET(ret == ACLNN_SUCCESS, ret); | ||
| 184 | - | ||
| 185 | - // BitwiseAnd算子的空tensor在kernel中支持,对标竞品根据算子实际情况补充 | ||
| 186 | - if (self->IsEmpty()) { | ||
| 187 | - // 根据实际支持情况补充 | ||
| 188 | - *workspaceSize = 0; | ||
| 189 | - uniqueExecutor.ReleaseTo(executor); | ||
| 190 | return ACLNN_SUCCESS; | 188 | return ACLNN_SUCCESS; |
| 191 | - } | ||
| 192 | - | ||
| 193 | - // BitwiseAnd算子需要对self和other两个输入做隐式数据类型转换,根据具体算子语义按需调用 | ||
| 194 | - auto promoteType = PromoteTypeScalar(self, other); | ||
| 195 | - | ||
| 196 | - // 固定写法,将输入self转换成连续的tensor | ||
| 197 | - auto selfContiguous = l0op::Contiguous(self, uniqueExecutor.get()); | ||
| 198 | - CHECK_RET(selfContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR); | ||
| 199 | - | ||
| 200 | - // 将输入self的数据类型转换成隐式数据类型,根据具体算子语义按需调用 | ||
| 201 | - auto selfCasted = l0op::Cast(selfContiguous, promoteType, uniqueExecutor.get()); | ||
| 202 | - CHECK_RET(selfCasted != nullptr, ACLNN_ERR_INNER_NULLPTR); | ||
| 203 | - | ||
| 204 | - // 将输入other转换为数据类型为promoteType的tensor | ||
| 205 | - const aclTensor *otherTensor = (uniqueExecutor.get())->ConvertToTensor(other, promoteType); | ||
| 206 | - CHECK_RET(otherTensor != nullptr, ACLNN_ERR_INNER_NULLPTR); | ||
| 207 | - | ||
| 208 | - // 进行BitwiseAnd计算 | ||
| 209 | - const aclTensor *andOpOut = nullptr; | ||
| 210 | - if (promoteType == op::DataType::DT_BOOL) { | ||
| 211 | - andOpOut = l0op::LogicalAnd(selfCasted, otherTensor, uniqueExecutor.get()); | ||
| 212 | - } else { | ||
| 213 | - andOpOut = l0op::BitwiseAnd(selfCasted, otherTensor, uniqueExecutor.get()); | ||
| 214 | - } | ||
| 215 | - CHECK_RET(andOpOut != nullptr, ACLNN_ERR_INNER_NULLPTR); | ||
| 216 | - | ||
| 217 | - // 固定写法,将计算结果转换成输出out的数据类型 | ||
| 218 | - auto castOut = l0op::Cast(andOpOut, out->GetDataType(), uniqueExecutor.get()); | ||
| 219 | - CHECK_RET(castOut != nullptr, ACLNN_ERR_INNER_NULLPTR); | ||
| 220 | - | ||
| 221 | - // 固定写法,将计算结果拷贝到输出out上,out可能是非连续的tensor | ||
| 222 | - auto viewCopyResult = l0op::ViewCopy(castOut, out, uniqueExecutor.get()); | ||
| 223 | - CHECK_RET(viewCopyResult != nullptr, ACLNN_ERR_INNER_NULLPTR); | ||
| 224 | - | ||
| 225 | - // 固定写法,获取计算过程中需要使用的workspace大小 | ||
| 226 | - *workspaceSize = uniqueExecutor->GetWorkspaceSize(); | ||
| 227 | - uniqueExecutor.ReleaseTo(executor); // 需要把 uniqueExecutor持有executor转移给executor | ||
| 228 | - return ACLNN_SUCCESS; | ||
| 229 | } | 189 | } |
| 230 | 190 | ||
| 231 | -aclnnStatus aclnnInplaceBitwiseAndScalarGetWorkspaceSize(const aclTensor *selfRef, const aclScalar *other, | 191 | +aclnnStatus aclnnBitwiseAndScalarGetWorkspaceSize(const aclTensor* self, const aclScalar* other, aclTensor* out, |
| 232 | - uint64_t *workspaceSize, aclOpExecutor **executor) { | 192 | + uint64_t* workspaceSize, aclOpExecutor** executor) |
| 233 | - auto out = const_cast<aclTensor *>(selfRef); | 193 | +{ |
| 234 | - return aclnnBitwiseAndScalarGetWorkspaceSize(selfRef, other, out, workspaceSize, executor); | 194 | + L2_DFX_PHASE_1(aclnnBitwiseAndScalar, DFX_IN(self, other), DFX_OUT(out)); |
| 195 | + // 固定写法,创建OpExecutor | ||
| 196 | + auto uniqueExecutor = CREATE_EXECUTOR(); | ||
| 197 | + CHECK_RET(uniqueExecutor.get() != nullptr, ACLNN_ERR_INNER_CREATE_EXECUTOR); | ||
| 198 | + | ||
| 199 | + // 固定写法,参数检查 | ||
| 200 | + auto ret = CheckParams(self, other, out); | ||
| 201 | + CHECK_RET(ret == ACLNN_SUCCESS, ret); | ||
| 202 | + | ||
| 203 | + // BitwiseAnd算子的空tensor在kernel中支持,对标竞品根据算子实际情况补充 | ||
| 204 | + if (self->IsEmpty()) { | ||
| 205 | + // 根据实际支持情况补充 | ||
| 206 | + *workspaceSize = 0; | ||
| 207 | + uniqueExecutor.ReleaseTo(executor); | ||
| 208 | + return ACLNN_SUCCESS; | ||
| 209 | + } | ||
| 210 | + | ||
| 211 | + // BitwiseAnd算子需要对self和other两个输入做隐式数据类型转换,根据具体算子语义按需调用 | ||
| 212 | + auto promoteType = PromoteTypeScalar(self, other); | ||
| 213 | + | ||
| 214 | + // 固定写法,将输入self转换成连续的tensor | ||
| 215 | + auto selfContiguous = l0op::Contiguous(self, uniqueExecutor.get()); | ||
| 216 | + CHECK_RET(selfContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR); | ||
| 217 | + | ||
| 218 | + // 将输入self的数据类型转换成隐式数据类型,根据具体算子语义按需调用 | ||
| 219 | + auto selfCasted = l0op::Cast(selfContiguous, promoteType, uniqueExecutor.get()); | ||
| 220 | + CHECK_RET(selfCasted != nullptr, ACLNN_ERR_INNER_NULLPTR); | ||
| 221 | + | ||
| 222 | + // 将输入other转换为数据类型为promoteType的tensor | ||
| 223 | + const aclTensor* otherTensor = (uniqueExecutor.get())->ConvertToTensor(other, promoteType); | ||
| 224 | + CHECK_RET(otherTensor != nullptr, ACLNN_ERR_INNER_NULLPTR); | ||
| 225 | + | ||
| 226 | + // 进行BitwiseAnd计算 | ||
| 227 | + const aclTensor* andOpOut = nullptr; | ||
| 228 | + if (promoteType == op::DataType::DT_BOOL) { | ||
| 229 | + andOpOut = l0op::LogicalAnd(selfCasted, otherTensor, uniqueExecutor.get()); | ||
| 230 | + } else { | ||
| 231 | + andOpOut = l0op::BitwiseAnd(selfCasted, otherTensor, uniqueExecutor.get()); | ||
| 232 | + } | ||
| 233 | + CHECK_RET(andOpOut != nullptr, ACLNN_ERR_INNER_NULLPTR); | ||
| 234 | + | ||
| 235 | + // 固定写法,将计算结果转换成输出out的数据类型 | ||
| 236 | + auto castOut = l0op::Cast(andOpOut, out->GetDataType(), uniqueExecutor.get()); | ||
| 237 | + CHECK_RET(castOut != nullptr, ACLNN_ERR_INNER_NULLPTR); | ||
| 238 | + | ||
| 239 | + // 固定写法,将计算结果拷贝到输出out上,out可能是非连续的tensor | ||
| 240 | + auto viewCopyResult = l0op::ViewCopy(castOut, out, uniqueExecutor.get()); | ||
| 241 | + CHECK_RET(viewCopyResult != nullptr, ACLNN_ERR_INNER_NULLPTR); | ||
| 242 | + | ||
| 243 | + // 固定写法,获取计算过程中需要使用的workspace大小 | ||
| 244 | + *workspaceSize = uniqueExecutor->GetWorkspaceSize(); | ||
| 245 | + uniqueExecutor.ReleaseTo(executor); // 需要把 uniqueExecutor持有executor转移给executor | ||
| 246 | + return ACLNN_SUCCESS; | ||
| 235 | } | 247 | } |
| 236 | 248 | ||
| 237 | -aclnnStatus aclnnBitwiseAndScalar(void *workspace, uint64_t workspaceSize, | 249 | +aclnnStatus aclnnInplaceBitwiseAndScalarGetWorkspaceSize(const aclTensor* selfRef, const aclScalar* other, |
| 238 | - aclOpExecutor *executor, aclrtStream stream) { | 250 | + uint64_t* workspaceSize, aclOpExecutor** executor) |
| 239 | - L2_DFX_PHASE_2(aclnnBitwiseAndScalar); | 251 | +{ |
| 240 | - // 固定写法,调用框架能力,完成计算 | 252 | + auto out = const_cast<aclTensor*>(selfRef); |
| 241 | - return CommonOpExecutorRun(workspace, workspaceSize, executor, stream); | 253 | + return aclnnBitwiseAndScalarGetWorkspaceSize(selfRef, other, out, workspaceSize, executor); |
| 242 | } | 254 | } |
| 243 | 255 | ||
| 244 | -aclnnStatus aclnnInplaceBitwiseAndScalar(void *workspace, uint64_t workspaceSize, | 256 | +aclnnStatus aclnnBitwiseAndScalar(void* workspace, uint64_t workspaceSize, aclOpExecutor* executor, aclrtStream stream) |
| 245 | - aclOpExecutor *executor, aclrtStream stream) { | 257 | +{ |
| 246 | - L2_DFX_PHASE_2(aclnnInplaceBitwiseAndScalar); | 258 | + L2_DFX_PHASE_2(aclnnBitwiseAndScalar); |
| 247 | - // 固定写法,调用框架能力,完成计算 | 259 | + // 固定写法,调用框架能力,完成计算 |
| 248 | - return CommonOpExecutorRun(workspace, workspaceSize, executor, stream); | 260 | + return CommonOpExecutorRun(workspace, workspaceSize, executor, stream); |
| 261 | +} | ||
| 262 | + | ||
| 263 | +aclnnStatus aclnnInplaceBitwiseAndScalar(void* workspace, uint64_t workspaceSize, aclOpExecutor* executor, | ||
| 264 | + aclrtStream stream) | ||
| 265 | +{ | ||
| 266 | + L2_DFX_PHASE_2(aclnnInplaceBitwiseAndScalar); | ||
| 267 | + // 固定写法,调用框架能力,完成计算 | ||
| 268 | + return CommonOpExecutorRun(workspace, workspaceSize, executor, stream); | ||
| 249 | } | 269 | } |
| 250 | 270 | ||
| 251 | #ifdef __cplusplus | 271 | #ifdef __cplusplus |
| @@ -31,7 +31,6 @@ extern "C" { | |||
| 31 | #endif | 31 | #endif |
| 32 | 32 | ||
| 33 | /* BitwiseAndTensor算子的完整计算流程如下: | 33 | /* BitwiseAndTensor算子的完整计算流程如下: |
| 34 | - * self.dtype == bool | ||
| 35 | * self other | 34 | * self other |
| 36 | * | | | 35 | * | | |
| 37 | * \ / | 36 | * \ / |
| @@ -39,22 +38,7 @@ extern "C" { | |||
| 39 | * \ / | 38 | * \ / |
| 40 | * Cast(workspace_1) Cast(workspace_3) | 39 | * Cast(workspace_1) Cast(workspace_3) |
| 41 | * \ / | 40 | * \ / |
| 42 | - * LogicalAnd(workspace_4) | 41 | + * promoteType == BOOL ? LogicalAnd(workspace_4) : BitwiseAnd(workspace_4) |
| 43 | - * | | ||
| 44 | - * Cast(workspace_5) | ||
| 45 | - * | | ||
| 46 | - * ViewCopy | ||
| 47 | - * | | ||
| 48 | - * result | ||
| 49 | - * self.dtype == INT | ||
| 50 | - * self other | ||
| 51 | - * | | | ||
| 52 | - * \ / | ||
| 53 | - * Contiguous(workspace_0) Contiguous(workspace_2) | ||
| 54 | - * \ / | ||
| 55 | - * Cast(workspace_1) Cast(workspace_3) | ||
| 56 | - * \ / | ||
| 57 | - * BitwiseAnd(workspace_4) | ||
| 58 | * | | 42 | * | |
| 59 | * Cast(workspace_5) | 43 | * Cast(workspace_5) |
| 60 | * | | 44 | * | |
| @@ -65,162 +49,171 @@ extern "C" { | |||
| 65 | 49 | ||
| 66 | // 根据API定义,需要列出所能支持的所有dtype | 50 | // 根据API定义,需要列出所能支持的所有dtype |
| 67 | static const std::initializer_list<op::DataType> DTYPE_SUPPORT_LIST = { | 51 | static const std::initializer_list<op::DataType> DTYPE_SUPPORT_LIST = { |
| 68 | - op::DataType::DT_INT16, op::DataType::DT_INT32, op::DataType::DT_INT64, op::DataType::DT_INT8, | 52 | + op::DataType::DT_INT8, op::DataType::DT_INT16, op::DataType::DT_INT32, |
| 69 | - op::DataType::DT_UINT8, op::DataType::DT_BOOL, op::DataType::DT_UINT16}; | 53 | + op::DataType::DT_INT64, op::DataType::DT_UINT8, op::DataType::DT_UINT16, |
| 54 | + op::DataType::DT_UINT32, op::DataType::DT_UINT64, op::DataType::DT_BOOL}; | ||
| 70 | 55 | ||
| 71 | -static bool CheckNotNull(const aclTensor *self, const aclTensor *other, const aclTensor *out) { | 56 | +static bool CheckNotNull(const aclTensor* self, const aclTensor* other, const aclTensor* out) |
| 72 | - OP_CHECK_NULL(self, return false); | 57 | +{ |
| 73 | - OP_CHECK_NULL(other, return false); | 58 | + OP_CHECK_NULL(self, return false); |
| 74 | - OP_CHECK_NULL(out, return false); | 59 | + OP_CHECK_NULL(other, return false); |
| 60 | + OP_CHECK_NULL(out, return false); | ||
| 75 | 61 | ||
| 76 | - return true; | 62 | + return true; |
| 77 | } | 63 | } |
| 78 | 64 | ||
| 79 | -static bool CheckDtypeValid(const aclTensor *self, const aclTensor *other) { | 65 | +static bool CheckDtypeValid(const aclTensor* self, const aclTensor* other) |
| 80 | - // 检查self的数据类型是否在and算子的支持列表内 | 66 | +{ |
| 81 | - OP_CHECK_DTYPE_NOT_SUPPORT(self, DTYPE_SUPPORT_LIST, return false); | 67 | + // 检查self的数据类型是否在and算子的支持列表内 |
| 68 | + OP_CHECK_DTYPE_NOT_SUPPORT(self, DTYPE_SUPPORT_LIST, return false); | ||
| 82 | 69 | ||
| 83 | - // 检查other的数据类型是否在and算子的支持列表内 | 70 | + // 检查other的数据类型是否在and算子的支持列表内 |
| 84 | - OP_CHECK_DTYPE_NOT_SUPPORT(other, DTYPE_SUPPORT_LIST, return false); | 71 | + OP_CHECK_DTYPE_NOT_SUPPORT(other, DTYPE_SUPPORT_LIST, return false); |
| 85 | 72 | ||
| 86 | - return true; | 73 | + return true; |
| 87 | } | 74 | } |
| 88 | 75 | ||
| 89 | -static bool CheckPromoteType(const aclTensor *self, const aclTensor *other, const aclTensor *out) { | 76 | +static bool CheckPromoteType(const aclTensor* self, const aclTensor* other, const aclTensor* out) |
| 90 | - // 检查self和other能否做数据类型推导 | 77 | +{ |
| 91 | - op::DataType promoteType = op::PromoteType(self->GetDataType(), other->GetDataType()); | 78 | + // 检查self和other能否做数据类型推导 |
| 92 | - if (promoteType == DataType::DT_UNDEFINED) { | 79 | + op::DataType promoteType = op::PromoteType(self->GetDataType(), other->GetDataType()); |
| 93 | - OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Self dtype %s and other dtype %s can not promote dtype.", | 80 | + if (promoteType == DataType::DT_UNDEFINED) { |
| 94 | - op::ToString(self->GetDataType()).GetString(), op::ToString(other->GetDataType()).GetString()); | 81 | + OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Self dtype %s and other dtype %s can not promote dtype.", |
| 95 | - return false; | 82 | + op::ToString(self->GetDataType()).GetString(), op::ToString(other->GetDataType()).GetString()); |
| 96 | - } | 83 | + return false; |
| 84 | + } | ||
| 97 | 85 | ||
| 98 | - // 检查推导后的数据类型能否转换为输出的数据类型 | 86 | + // 检查推导后的数据类型能否转换为输出的数据类型 |
| 99 | - OP_CHECK_RESULT_DTYPE_CAST_FAILED(promoteType, out->GetDataType(), return false); | 87 | + OP_CHECK_RESULT_DTYPE_CAST_FAILED(promoteType, out->GetDataType(), return false); |
| 100 | 88 | ||
| 101 | - return true; | 89 | + return true; |
| 102 | } | 90 | } |
| 103 | 91 | ||
| 104 | -static bool CheckFormat(const aclTensor *self, const aclTensor *other, const aclTensor *out) { | 92 | +static bool CheckFormat(const aclTensor* self, const aclTensor* other, const aclTensor* out) |
| 105 | - // 如果输入格式是私有格式,记录日志,直接报错 | 93 | +{ |
| 106 | - if (op::IsPrivateFormat(self->GetStorageFormat()) || | 94 | + // 如果输入格式是私有格式,记录日志,直接报错 |
| 107 | - op::IsPrivateFormat(other->GetStorageFormat()) || | 95 | + if (op::IsPrivateFormat(self->GetStorageFormat()) || op::IsPrivateFormat(other->GetStorageFormat()) || |
| 108 | - op::IsPrivateFormat(out->GetStorageFormat())) { | 96 | + op::IsPrivateFormat(out->GetStorageFormat())) { |
| 109 | - OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Format only support ND,NCHW,NHWC,HWCN,NDHWC,NCDHW."); | 97 | + OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Format only support ND,NCHW,NHWC,HWCN,NDHWC,NCDHW."); |
| 110 | - return false; | 98 | + return false; |
| 111 | - } | 99 | + } |
| 112 | - return true; | 100 | + return true; |
| 113 | } | 101 | } |
| 114 | 102 | ||
| 115 | -static bool CheckShape(const aclTensor *self, const aclTensor *other, const aclTensor *out) { | 103 | +static bool CheckShape(const aclTensor* self, const aclTensor* other, const aclTensor* out) |
| 116 | - OP_CHECK_MAX_DIM(self, BITWISE_AND_MAX_TENSOR_DIM, return false); | 104 | +{ |
| 117 | - OP_CHECK_MAX_DIM(other, BITWISE_AND_MAX_TENSOR_DIM, return false); | 105 | + OP_CHECK_MAX_DIM(self, BITWISE_AND_MAX_TENSOR_DIM, return false); |
| 106 | + OP_CHECK_MAX_DIM(other, BITWISE_AND_MAX_TENSOR_DIM, return false); | ||
| 118 | 107 | ||
| 119 | - op::Shape broadcastShape; | 108 | + op::Shape broadcastShape; |
| 120 | - OP_CHECK_BROADCAST_AND_INFER_SHAPE(self, other, broadcastShape, return false); | 109 | + OP_CHECK_BROADCAST_AND_INFER_SHAPE(self, other, broadcastShape, return false); |
| 121 | - OP_CHECK_SHAPE_NOT_EQUAL_WITH_EXPECTED_SIZE(out, broadcastShape, return false); | 110 | + OP_CHECK_SHAPE_NOT_EQUAL_WITH_EXPECTED_SIZE(out, broadcastShape, return false); |
| 122 | - return true; | 111 | + return true; |
| 123 | } | 112 | } |
| 124 | 113 | ||
| 125 | -static aclnnStatus CheckParams(const aclTensor *self, const aclTensor *other, const aclTensor *out) { | 114 | +static aclnnStatus CheckParams(const aclTensor* self, const aclTensor* other, const aclTensor* out) |
| 126 | - // 错误码等DFX方案细化后刷新,错误日志在check接口内打印 | 115 | +{ |
| 127 | - // 1. 检查参数是否为空指针 | 116 | + // 错误码等DFX方案细化后刷新,错误日志在check接口内打印 |
| 128 | - CHECK_RET(CheckNotNull(self, other, out), ACLNN_ERR_PARAM_NULLPTR); | 117 | + // 1. 检查参数是否为空指针 |
| 118 | + CHECK_RET(CheckNotNull(self, other, out), ACLNN_ERR_PARAM_NULLPTR); | ||
| 129 | 119 | ||
| 130 | - // 2. 检查输入的数据类型是否在API支持的数据类型范围之内,需要根据api定义校验 | 120 | + // 2. 检查输入的数据类型是否在API支持的数据类型范围之内,需要根据api定义校验 |
| 131 | - CHECK_RET(CheckDtypeValid(self, other), ACLNN_ERR_PARAM_INVALID); | 121 | + CHECK_RET(CheckDtypeValid(self, other), ACLNN_ERR_PARAM_INVALID); |
| 132 | 122 | ||
| 133 | - // 3. 检查self和other能否做数据类型推导以及推导的数据类型能否转换为输出数据类型 | 123 | + // 3. 检查self和other能否做数据类型推导以及推导的数据类型能否转换为输出数据类型 |
| 134 | - CHECK_RET(CheckPromoteType(self, other, out), ACLNN_ERR_PARAM_INVALID); | 124 | + CHECK_RET(CheckPromoteType(self, other, out), ACLNN_ERR_PARAM_INVALID); |
| 135 | 125 | ||
| 136 | - // 4. 检查数据格式是否支持 | 126 | + // 4. 检查数据格式是否支持 |
| 137 | - CHECK_RET(CheckFormat(self, other, out), ACLNN_ERR_PARAM_INVALID); | 127 | + CHECK_RET(CheckFormat(self, other, out), ACLNN_ERR_PARAM_INVALID); |
| 138 | 128 | ||
| 139 | - // 5. 检查双输入是否能broadcast | 129 | + // 5. 检查双输入是否能broadcast |
| 140 | - CHECK_RET(CheckShape(self, other, out), ACLNN_ERR_PARAM_INVALID); | 130 | + CHECK_RET(CheckShape(self, other, out), ACLNN_ERR_PARAM_INVALID); |
| 141 | 131 | ||
| 142 | - return ACLNN_SUCCESS; | ||
| 143 | -} | ||
| 144 | - | ||
| 145 | -aclnnStatus aclnnBitwiseAndTensorGetWorkspaceSize(const aclTensor *self, const aclTensor *other, | ||
| 146 | - aclTensor *out, uint64_t *workspaceSize, aclOpExecutor **executor) { | ||
| 147 | - L2_DFX_PHASE_1(aclnnBitwiseAndTensor, DFX_IN(self, other), DFX_OUT(out)); | ||
| 148 | - // 固定写法,创建OpExecutor | ||
| 149 | - auto uniqueExecutor = CREATE_EXECUTOR(); | ||
| 150 | - CHECK_RET(uniqueExecutor.get() != nullptr, ACLNN_ERR_INNER_CREATE_EXECUTOR); | ||
| 151 | - | ||
| 152 | - // 固定写法,参数检查 | ||
| 153 | - auto ret = CheckParams(self, other, out); | ||
| 154 | - CHECK_RET(ret == ACLNN_SUCCESS, ret); | ||
| 155 | - | ||
| 156 | - // BitwiseAnd算子的空tensor在kernel中支持,对标竞品根据算子实际情况补充 | ||
| 157 | - if (self->IsEmpty() || other->IsEmpty()) { | ||
| 158 | - // 根据实际支持情况补充 | ||
| 159 | - *workspaceSize = 0; | ||
| 160 | - uniqueExecutor.ReleaseTo(executor); | ||
| 161 | return ACLNN_SUCCESS; | 132 | return ACLNN_SUCCESS; |
| 162 | - } | ||
| 163 | - | ||
| 164 | - // BitwiseAnd算子需要对self和other两个输入做隐式数据类型转换,根据具体算子语义按需调用 | ||
| 165 | - auto promoteType = op::PromoteType(self->GetDataType(), other->GetDataType()); | ||
| 166 | - | ||
| 167 | - // 固定写法,将输入self转换成连续的tensor | ||
| 168 | - auto selfContiguous = l0op::Contiguous(self, uniqueExecutor.get()); | ||
| 169 | - CHECK_RET(selfContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR); | ||
| 170 | - | ||
| 171 | - // 将输入self的数据类型转换成隐式数据类型,根据具体算子语义按需调用 | ||
| 172 | - auto selfCasted = l0op::Cast(selfContiguous, promoteType, uniqueExecutor.get()); | ||
| 173 | - CHECK_RET(selfCasted != nullptr, ACLNN_ERR_INNER_NULLPTR); | ||
| 174 | - | ||
| 175 | - // 固定写法,将输入other转换成连续的tensor | ||
| 176 | - auto otherContiguous = l0op::Contiguous(other, uniqueExecutor.get()); | ||
| 177 | - CHECK_RET(otherContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR); | ||
| 178 | - | ||
| 179 | - // 将输入other的数据类型转换成隐式数据类型,根据具体算子语义按需调用 | ||
| 180 | - auto otherCasted = l0op::Cast(otherContiguous, promoteType, uniqueExecutor.get()); | ||
| 181 | - CHECK_RET(otherCasted != nullptr, ACLNN_ERR_INNER_NULLPTR); | ||
| 182 | - | ||
| 183 | - // 进行BitwiseAnd计算 | ||
| 184 | - const aclTensor *andOpOut = nullptr; | ||
| 185 | - if (promoteType == op::DataType::DT_BOOL) { | ||
| 186 | - andOpOut = l0op::LogicalAnd(selfCasted, otherCasted, uniqueExecutor.get()); | ||
| 187 | - } else { | ||
| 188 | - andOpOut = l0op::BitwiseAnd(selfCasted, otherCasted, uniqueExecutor.get()); | ||
| 189 | - } | ||
| 190 | - CHECK_RET(andOpOut != nullptr, ACLNN_ERR_INNER_NULLPTR); | ||
| 191 | - | ||
| 192 | - // 固定写法,将计算结果转换成输出out的数据类型 | ||
| 193 | - auto castOut = l0op::Cast(andOpOut, out->GetDataType(), uniqueExecutor.get()); | ||
| 194 | - CHECK_RET(castOut != nullptr, ACLNN_ERR_INNER_NULLPTR); | ||
| 195 | - | ||
| 196 | - // 固定写法,将计算结果拷贝到输出out上,out可能是非连续的tensor | ||
| 197 | - auto viewCopyResult = l0op::ViewCopy(castOut, out, uniqueExecutor.get()); | ||
| 198 | - CHECK_RET(viewCopyResult != nullptr, ACLNN_ERR_INNER_NULLPTR); | ||
| 199 | - | ||
| 200 | - // 固定写法,获取计算过程中需要使用的workspace大小 | ||
| 201 | - *workspaceSize = uniqueExecutor->GetWorkspaceSize(); | ||
| 202 | - uniqueExecutor.ReleaseTo(executor); // 需要把 uniqueExecutor持有executor转移给executor | ||
| 203 | - return ACLNN_SUCCESS; | ||
| 204 | } | 133 | } |
| 205 | 134 | ||
| 206 | -aclnnStatus aclnnInplaceBitwiseAndTensorGetWorkspaceSize(const aclTensor *selfRef, const aclTensor *other, | 135 | +aclnnStatus aclnnBitwiseAndTensorGetWorkspaceSize(const aclTensor* self, const aclTensor* other, aclTensor* out, |
| 207 | - uint64_t *workspaceSize, aclOpExecutor **executor) { | 136 | + uint64_t* workspaceSize, aclOpExecutor** executor) |
| 208 | - auto out = const_cast<aclTensor *>(selfRef); | 137 | +{ |
| 209 | - return aclnnBitwiseAndTensorGetWorkspaceSize(selfRef, other, out, workspaceSize, executor); | 138 | + L2_DFX_PHASE_1(aclnnBitwiseAndTensor, DFX_IN(self, other), DFX_OUT(out)); |
| 139 | + // 固定写法,创建OpExecutor | ||
| 140 | + auto uniqueExecutor = CREATE_EXECUTOR(); | ||
| 141 | + CHECK_RET(uniqueExecutor.get() != nullptr, ACLNN_ERR_INNER_CREATE_EXECUTOR); | ||
| 142 | + | ||
| 143 | + // 固定写法,参数检查 | ||
| 144 | + auto ret = CheckParams(self, other, out); | ||
| 145 | + CHECK_RET(ret == ACLNN_SUCCESS, ret); | ||
| 146 | + | ||
| 147 | + // BitwiseAnd算子的空tensor在kernel中支持,对标竞品根据算子实际情况补充 | ||
| 148 | + if (self->IsEmpty() || other->IsEmpty()) { | ||
| 149 | + // 根据实际支持情况补充 | ||
| 150 | + *workspaceSize = 0; | ||
| 151 | + uniqueExecutor.ReleaseTo(executor); | ||
| 152 | + return ACLNN_SUCCESS; | ||
| 153 | + } | ||
| 154 | + | ||
| 155 | + // BitwiseAnd算子需要对self和other两个输入做隐式数据类型转换,根据具体算子语义按需调用 | ||
| 156 | + auto promoteType = op::PromoteType(self->GetDataType(), other->GetDataType()); | ||
| 157 | + | ||
| 158 | + // 固定写法,将输入self转换成连续的tensor | ||
| 159 | + auto selfContiguous = l0op::Contiguous(self, uniqueExecutor.get()); | ||
| 160 | + CHECK_RET(selfContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR); | ||
| 161 | + | ||
| 162 | + // 将输入self的数据类型转换成隐式数据类型,根据具体算子语义按需调用 | ||
| 163 | + auto selfCasted = l0op::Cast(selfContiguous, promoteType, uniqueExecutor.get()); | ||
| 164 | + CHECK_RET(selfCasted != nullptr, ACLNN_ERR_INNER_NULLPTR); | ||
| 165 | + | ||
| 166 | + // 固定写法,将输入other转换成连续的tensor | ||
| 167 | + auto otherContiguous = l0op::Contiguous(other, uniqueExecutor.get()); | ||
| 168 | + CHECK_RET(otherContiguous != nullptr, ACLNN_ERR_INNER_NULLPTR); | ||
| 169 | + | ||
| 170 | + // 将输入other的数据类型转换成隐式数据类型,根据具体算子语义按需调用 | ||
| 171 | + auto otherCasted = l0op::Cast(otherContiguous, promoteType, uniqueExecutor.get()); | ||
| 172 | + CHECK_RET(otherCasted != nullptr, ACLNN_ERR_INNER_NULLPTR); | ||
| 173 | + | ||
| 174 | + // 进行BitwiseAnd计算 | ||
| 175 | + const aclTensor* andOpOut = nullptr; | ||
| 176 | + if (promoteType == op::DataType::DT_BOOL) { | ||
| 177 | + andOpOut = l0op::LogicalAnd(selfCasted, otherCasted, uniqueExecutor.get()); | ||
| 178 | + } else { | ||
| 179 | + andOpOut = l0op::BitwiseAnd(selfCasted, otherCasted, uniqueExecutor.get()); | ||
| 180 | + } | ||
| 181 | + CHECK_RET(andOpOut != nullptr, ACLNN_ERR_INNER_NULLPTR); | ||
| 182 | + | ||
| 183 | + // 固定写法,将计算结果转换成输出out的数据类型 | ||
| 184 | + auto castOut = l0op::Cast(andOpOut, out->GetDataType(), uniqueExecutor.get()); | ||
| 185 | + CHECK_RET(castOut != nullptr, ACLNN_ERR_INNER_NULLPTR); | ||
| 186 | + | ||
| 187 | + // 固定写法,将计算结果拷贝到输出out上,out可能是非连续的tensor | ||
| 188 | + auto viewCopyResult = l0op::ViewCopy(castOut, out, uniqueExecutor.get()); | ||
| 189 | + CHECK_RET(viewCopyResult != nullptr, ACLNN_ERR_INNER_NULLPTR); | ||
| 190 | + | ||
| 191 | + // 固定写法,获取计算过程中需要使用的workspace大小 | ||
| 192 | + *workspaceSize = uniqueExecutor->GetWorkspaceSize(); | ||
| 193 | + uniqueExecutor.ReleaseTo(executor); // 需要把 uniqueExecutor持有executor转移给executor | ||
| 194 | + return ACLNN_SUCCESS; | ||
| 210 | } | 195 | } |
| 211 | 196 | ||
| 212 | -aclnnStatus aclnnBitwiseAndTensor(void *workspace, uint64_t workspaceSize, | 197 | +aclnnStatus aclnnInplaceBitwiseAndTensorGetWorkspaceSize(const aclTensor* selfRef, const aclTensor* other, |
| 213 | - aclOpExecutor *executor, aclrtStream stream) { | 198 | + uint64_t* workspaceSize, aclOpExecutor** executor) |
| 214 | - L2_DFX_PHASE_2(aclnnBitwiseAndTensor); | 199 | +{ |
| 215 | - // 固定写法,调用框架能力,完成计算 | 200 | + auto out = const_cast<aclTensor*>(selfRef); |
| 216 | - return CommonOpExecutorRun(workspace, workspaceSize, executor, stream); | 201 | + return aclnnBitwiseAndTensorGetWorkspaceSize(selfRef, other, out, workspaceSize, executor); |
| 217 | } | 202 | } |
| 218 | 203 | ||
| 219 | -aclnnStatus aclnnInplaceBitwiseAndTensor(void *workspace, uint64_t workspaceSize, | 204 | +aclnnStatus aclnnBitwiseAndTensor(void* workspace, uint64_t workspaceSize, aclOpExecutor* executor, aclrtStream stream) |
| 220 | - aclOpExecutor *executor, aclrtStream stream) { | 205 | +{ |
| 221 | - L2_DFX_PHASE_2(aclnnInplaceBitwiseAndTensor); | 206 | + L2_DFX_PHASE_2(aclnnBitwiseAndTensor); |
| 222 | - // 固定写法,调用框架能力,完成计算 | 207 | + // 固定写法,调用框架能力,完成计算 |
| 223 | - return CommonOpExecutorRun(workspace, workspaceSize, executor, stream); | 208 | + return CommonOpExecutorRun(workspace, workspaceSize, executor, stream); |
| 209 | +} | ||
| 210 | + | ||
| 211 | +aclnnStatus aclnnInplaceBitwiseAndTensor(void* workspace, uint64_t workspaceSize, aclOpExecutor* executor, | ||
| 212 | + aclrtStream stream) | ||
| 213 | +{ | ||
| 214 | + L2_DFX_PHASE_2(aclnnInplaceBitwiseAndTensor); | ||
| 215 | + // 固定写法,调用框架能力,完成计算 | ||
| 216 | + return CommonOpExecutorRun(workspace, workspaceSize, executor, stream); | ||
| 224 | } | 217 | } |
| 225 | 218 | ||
| 226 | #ifdef __cplusplus | 219 | #ifdef __cplusplus |
| @@ -31,56 +31,70 @@ static const std::initializer_list<op::DataType> AICORE_DTYPE_SUPPORT_LIST = { | |||
| 31 | static const std::initializer_list<op::DataType> ASCEND910B_AICORE_DTYPE_SUPPORT_LIST = { | 31 | static const std::initializer_list<op::DataType> ASCEND910B_AICORE_DTYPE_SUPPORT_LIST = { |
| 32 | op::DataType::DT_INT64, op::DataType::DT_UINT16, op::DataType::DT_INT32, op::DataType::DT_INT16}; | 32 | op::DataType::DT_INT64, op::DataType::DT_UINT16, op::DataType::DT_INT32, op::DataType::DT_INT16}; |
| 33 | 33 | ||
| 34 | +static const std::initializer_list<op::DataType> ASCEND950_AICORE_DTYPE_SUPPORT_LIST = { | ||
| 35 | + op::DataType::DT_INT8, op::DataType::DT_INT16, op::DataType::DT_UINT8, op::DataType::DT_UINT16, | ||
| 36 | + op::DataType::DT_INT32, op::DataType::DT_UINT32, op::DataType::DT_INT64, op::DataType::DT_UINT64}; | ||
| 37 | + | ||
| 34 | // 根据芯片类型、dtype判断算子是否支持走aicore | 38 | // 根据芯片类型、dtype判断算子是否支持走aicore |
| 35 | -static bool IsAiCoreSupport(const aclTensor *self) { | 39 | +static bool IsAiCoreSupport(const aclTensor* self) |
| 36 | - // 910B、910_93、regbase | 40 | +{ |
| 37 | - auto curArch = GetCurrentPlatformInfo().GetCurNpuArch(); | 41 | + // 910B、910_93 |
| 38 | - if (curArch == NpuArch::DAV_2201 || IsRegBase(curArch)) { | 42 | + auto curArch = GetCurrentPlatformInfo().GetCurNpuArch(); |
| 39 | - return CheckType(self->GetDataType(), ASCEND910B_AICORE_DTYPE_SUPPORT_LIST); | 43 | + if (curArch == NpuArch::DAV_2201) { |
| 40 | - } | 44 | + return CheckType(self->GetDataType(), ASCEND910B_AICORE_DTYPE_SUPPORT_LIST); |
| 41 | - // 910及其他 | 45 | + } |
| 42 | - return CheckType(self->GetDataType(), AICORE_DTYPE_SUPPORT_LIST); | 46 | + // regbase |
| 47 | + if (IsRegBase(curArch)) { | ||
| 48 | + return CheckType(self->GetDataType(), ASCEND950_AICORE_DTYPE_SUPPORT_LIST); | ||
| 49 | + } | ||
| 50 | + // 910及其他 | ||
| 51 | + return CheckType(self->GetDataType(), AICORE_DTYPE_SUPPORT_LIST); | ||
| 43 | } | 52 | } |
| 44 | 53 | ||
| 45 | // AICORE算子kernel | 54 | // AICORE算子kernel |
| 46 | -static const aclTensor *BitwiseAndAiCore(const aclTensor *self, const aclTensor *other, const aclTensor *BitwiseAndOut, | 55 | +static const aclTensor* BitwiseAndAiCore(const aclTensor* self, const aclTensor* other, const aclTensor* BitwiseAndOut, |
| 47 | - aclOpExecutor *executor) { | 56 | + aclOpExecutor* executor) |
| 48 | - L0_DFX(BitwiseAndAiCore); | 57 | +{ |
| 49 | - // 使用框架宏ADD_TO_LAUNCHER_LIST,将AiCore BitwiseAnd算子加入任务队列 | 58 | + L0_DFX(BitwiseAndAiCore); |
| 50 | - // BitwiseAnd是算子的OpType,self、other是算子的输入,BitwiseAndOut是算子的输出 | 59 | + // 使用框架宏ADD_TO_LAUNCHER_LIST,将AiCore BitwiseAnd算子加入任务队列 |
| 51 | - auto ret = ADD_TO_LAUNCHER_LIST_AICORE(BitwiseAnd, OP_INPUT(self, other), OP_OUTPUT(BitwiseAndOut)); | 60 | + // BitwiseAnd是算子的OpType,self、other是算子的输入,BitwiseAndOut是算子的输出 |
| 52 | - OP_CHECK(ret == ACL_SUCCESS, OP_LOGE(ACLNN_ERR_INNER_NULLPTR, "BitwiseAndAiCore ADD_TO_LAUNCHER_LIST_AICORE failed."), return nullptr); | 61 | + auto ret = ADD_TO_LAUNCHER_LIST_AICORE(BitwiseAnd, OP_INPUT(self, other), OP_OUTPUT(BitwiseAndOut)); |
| 53 | - return BitwiseAndOut; | 62 | + OP_CHECK(ret == ACL_SUCCESS, |
| 63 | + OP_LOGE(ACLNN_ERR_INNER_NULLPTR, "BitwiseAndAiCore ADD_TO_LAUNCHER_LIST_AICORE failed."), return nullptr); | ||
| 64 | + return BitwiseAndOut; | ||
| 54 | } | 65 | } |
| 55 | 66 | ||
| 56 | // AICPU算子kernel | 67 | // AICPU算子kernel |
| 57 | -static const aclTensor *BitwiseAndAiCpu(const aclTensor *self, const aclTensor *other, aclTensor *BitwiseAndOut, | 68 | +static const aclTensor* BitwiseAndAiCpu(const aclTensor* self, const aclTensor* other, aclTensor* BitwiseAndOut, |
| 58 | - aclOpExecutor *executor) { | 69 | + aclOpExecutor* executor) |
| 59 | - // 使用框架宏ADD_TO_LAUNCHER_LIST,将AiCpu BitwiseAnd算子加入任务队列 | 70 | +{ |
| 60 | - // BitwiseAnd是算子的OpType,self、other是算子的输入,BitwiseAndOut是算子的输出 | 71 | + // 使用框架宏ADD_TO_LAUNCHER_LIST,将AiCpu BitwiseAnd算子加入任务队列 |
| 61 | - L0_DFX(BitwiseAndAiCpu); | 72 | + // BitwiseAnd是算子的OpType,self、other是算子的输入,BitwiseAndOut是算子的输出 |
| 62 | - static internal::AicpuTaskSpace space("BitwiseAnd", ge::DEPEND_IN_SHAPE, true); | 73 | + L0_DFX(BitwiseAndAiCpu); |
| 63 | - auto ret = ADD_TO_LAUNCHER_LIST_AICPU(BitwiseAnd, OP_ATTR_NAMES(), OP_INPUT(self, other), OP_OUTPUT(BitwiseAndOut)); | 74 | + static internal::AicpuTaskSpace space("BitwiseAnd", ge::DEPEND_IN_SHAPE, true); |
| 64 | - OP_CHECK(ret == ACL_SUCCESS, OP_LOGE(ACLNN_ERR_INNER_NULLPTR, "BitwiseAndAiCpu ADD_TO_LAUNCHER_LIST_AICPU failed."), return nullptr); | 75 | + auto ret = ADD_TO_LAUNCHER_LIST_AICPU(BitwiseAnd, OP_ATTR_NAMES(), OP_INPUT(self, other), OP_OUTPUT(BitwiseAndOut)); |
| 65 | - return BitwiseAndOut; | 76 | + OP_CHECK(ret == ACL_SUCCESS, OP_LOGE(ACLNN_ERR_INNER_NULLPTR, "BitwiseAndAiCpu ADD_TO_LAUNCHER_LIST_AICPU failed."), |
| 77 | + return nullptr); | ||
| 78 | + return BitwiseAndOut; | ||
| 66 | } | 79 | } |
| 67 | 80 | ||
| 68 | -const aclTensor *BitwiseAnd(const aclTensor *self, const aclTensor *other, aclOpExecutor *executor) { | 81 | +const aclTensor* BitwiseAnd(const aclTensor* self, const aclTensor* other, aclOpExecutor* executor) |
| 69 | - // 根据输入shape推导输出shape | 82 | +{ |
| 70 | - op::Shape broadcastShape; | 83 | + // 根据输入shape推导输出shape |
| 71 | - if (!BroadcastInferShape(self->GetViewShape(), other->GetViewShape(), broadcastShape)) { | 84 | + op::Shape broadcastShape; |
| 72 | - OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Broadcast %s and %s failed.", op::ToString(self->GetViewShape()).GetString(), | 85 | + if (!BroadcastInferShape(self->GetViewShape(), other->GetViewShape(), broadcastShape)) { |
| 73 | - op::ToString(other->GetViewShape()).GetString()); | 86 | + OP_LOGE(ACLNN_ERR_PARAM_INVALID, "Broadcast %s and %s failed.", op::ToString(self->GetViewShape()).GetString(), |
| 74 | - return nullptr; | 87 | + op::ToString(other->GetViewShape()).GetString()); |
| 75 | - } | 88 | + return nullptr; |
| 76 | - // 根据输出shape申请输出tensor | 89 | + } |
| 77 | - auto BitwiseAndOut = executor->AllocTensor(broadcastShape, self->GetDataType(), op::Format::FORMAT_ND); | 90 | + // 根据输出shape申请输出tensor |
| 78 | - if (IsAiCoreSupport(self)) { | 91 | + auto BitwiseAndOut = executor->AllocTensor(broadcastShape, self->GetDataType(), op::Format::FORMAT_ND); |
| 79 | - return BitwiseAndAiCore(self, other, BitwiseAndOut, executor); | 92 | + if (IsAiCoreSupport(self)) { |
| 80 | - } else { | 93 | + return BitwiseAndAiCore(self, other, BitwiseAndOut, executor); |
| 81 | - return BitwiseAndAiCpu(self, other, BitwiseAndOut, executor); | 94 | + } else { |
| 82 | - } | 95 | + return BitwiseAndAiCpu(self, other, BitwiseAndOut, executor); |
| 83 | - return BitwiseAndOut; | 96 | + } |
| 97 | + return BitwiseAndOut; | ||
| 84 | } | 98 | } |
| 85 | 99 | ||
| 86 | -} // namespace l0op | 100 | +} // namespace l0op |
| @@ -27,15 +27,9 @@ namespace optiling { | |||
| 27 | 27 | ||
| 28 | static constexpr uint64_t BITWISE_AND_COMMON_TILING_PRIORITY = 0; | 28 | static constexpr uint64_t BITWISE_AND_COMMON_TILING_PRIORITY = 0; |
| 29 | 29 | ||
| 30 | -ge::graphStatus BitwiseAndTiling::GetShapeAttrsInfo() | 30 | +ge::graphStatus BitwiseAndTiling::GetShapeAttrsInfo() { return ge::GRAPH_SUCCESS; } |
| 31 | -{ | ||
| 32 | - return ge::GRAPH_SUCCESS; | ||
| 33 | -} | ||
| 34 | 31 | ||
| 35 | -bool BitwiseAndTiling::IsCapable() | 32 | +bool BitwiseAndTiling::IsCapable() { return true; } |
| 36 | -{ | ||
| 37 | - return true; | ||
| 38 | -} | ||
| 39 | 33 | ||
| 40 | ge::graphStatus BitwiseAndTiling::DoOpTiling() | 34 | ge::graphStatus BitwiseAndTiling::DoOpTiling() |
| 41 | { | 35 | { |
| @@ -54,16 +48,24 @@ ge::graphStatus BitwiseAndTiling::DoOpTiling() | |||
| 54 | std::string reasonMsg = "The dtype of x1 must be the same as the dtypes " + | 48 | std::string reasonMsg = "The dtype of x1 must be the same as the dtypes " + |
| 55 | ge::TypeUtils::DataTypeToSerialString(input1DType) + " and " + | 49 | ge::TypeUtils::DataTypeToSerialString(input1DType) + " and " + |
| 56 | ge::TypeUtils::DataTypeToSerialString(outputDtype) + " of x2 and y"; | 50 | ge::TypeUtils::DataTypeToSerialString(outputDtype) + " of x2 and y"; |
| 57 | - OP_LOGE_FOR_INVALID_DTYPE_WITH_REASON( | 51 | + OP_LOGE_FOR_INVALID_DTYPE_WITH_REASON(context_->GetNodeName(), "x1", |
| 58 | - context_->GetNodeName(), "x1", ge::TypeUtils::DataTypeToSerialString(input0DType).c_str(), | 52 | + ge::TypeUtils::DataTypeToSerialString(input0DType).c_str(), |
| 59 | - reasonMsg.c_str()); | 53 | + reasonMsg.c_str()); |
| 60 | return ge::GRAPH_FAILED; | 54 | return ge::GRAPH_FAILED; |
| 61 | } | 55 | } |
| 62 | ge::graphStatus ret = ge::GRAPH_SUCCESS; | 56 | ge::graphStatus ret = ge::GRAPH_SUCCESS; |
| 63 | - if (input0DType == ge::DT_INT16) { | 57 | + if (input0DType == ge::DT_INT8) { |
| 58 | + BroadcastBaseTiling<BitwiseAndOp::BitwiseAndCompute<int8_t>::OpDag> brcBaseTiling(context_); | ||
| 59 | + ret = brcBaseTiling.DoTiling(); | ||
| 60 | + tilingKey = GET_TPL_TILING_KEY(brcBaseTiling.GetSchMode()); | ||
| 61 | + } else if (input0DType == ge::DT_INT16) { | ||
| 64 | BroadcastBaseTiling<BitwiseAndOp::BitwiseAndCompute<int16_t>::OpDag> brcBaseTiling(context_); | 62 | BroadcastBaseTiling<BitwiseAndOp::BitwiseAndCompute<int16_t>::OpDag> brcBaseTiling(context_); |
| 65 | ret = brcBaseTiling.DoTiling(); | 63 | ret = brcBaseTiling.DoTiling(); |
| 66 | tilingKey = GET_TPL_TILING_KEY(brcBaseTiling.GetSchMode()); | 64 | tilingKey = GET_TPL_TILING_KEY(brcBaseTiling.GetSchMode()); |
| 65 | + } else if (input0DType == ge::DT_UINT8) { | ||
| 66 | + BroadcastBaseTiling<BitwiseAndOp::BitwiseAndCompute<uint8_t>::OpDag> brcBaseTiling(context_); | ||
| 67 | + ret = brcBaseTiling.DoTiling(); | ||
| 68 | + tilingKey = GET_TPL_TILING_KEY(brcBaseTiling.GetSchMode()); | ||
| 67 | } else if (input0DType == ge::DT_UINT16) { | 69 | } else if (input0DType == ge::DT_UINT16) { |
| 68 | BroadcastBaseTiling<BitwiseAndOp::BitwiseAndCompute<uint16_t>::OpDag> brcBaseTiling(context_); | 70 | BroadcastBaseTiling<BitwiseAndOp::BitwiseAndCompute<uint16_t>::OpDag> brcBaseTiling(context_); |
| 69 | ret = brcBaseTiling.DoTiling(); | 71 | ret = brcBaseTiling.DoTiling(); |
| @@ -72,43 +74,36 @@ ge::graphStatus BitwiseAndTiling::DoOpTiling() | |||
| 72 | BroadcastBaseTiling<BitwiseAndOp::BitwiseAndCompute<int32_t>::OpDag> brcBaseTiling(context_); | 74 | BroadcastBaseTiling<BitwiseAndOp::BitwiseAndCompute<int32_t>::OpDag> brcBaseTiling(context_); |
| 73 | ret = brcBaseTiling.DoTiling(); | 75 | ret = brcBaseTiling.DoTiling(); |
| 74 | tilingKey = GET_TPL_TILING_KEY(brcBaseTiling.GetSchMode()); | 76 | tilingKey = GET_TPL_TILING_KEY(brcBaseTiling.GetSchMode()); |
| 77 | + } else if (input0DType == ge::DT_UINT32) { | ||
| 78 | + BroadcastBaseTiling<BitwiseAndOp::BitwiseAndCompute<uint32_t>::OpDag> brcBaseTiling(context_); | ||
| 79 | + ret = brcBaseTiling.DoTiling(); | ||
| 80 | + tilingKey = GET_TPL_TILING_KEY(brcBaseTiling.GetSchMode()); | ||
| 75 | } else if (input0DType == ge::DT_INT64) { | 81 | } else if (input0DType == ge::DT_INT64) { |
| 76 | BroadcastBaseTiling<BitwiseAndOp::BitwiseAndCompute<int64_t>::OpDag> brcBaseTiling(context_); | 82 | BroadcastBaseTiling<BitwiseAndOp::BitwiseAndCompute<int64_t>::OpDag> brcBaseTiling(context_); |
| 77 | ret = brcBaseTiling.DoTiling(); | 83 | ret = brcBaseTiling.DoTiling(); |
| 78 | tilingKey = GET_TPL_TILING_KEY(brcBaseTiling.GetSchMode()); | 84 | tilingKey = GET_TPL_TILING_KEY(brcBaseTiling.GetSchMode()); |
| 85 | + } else if (input0DType == ge::DT_UINT64) { | ||
| 86 | + BroadcastBaseTiling<BitwiseAndOp::BitwiseAndCompute<uint64_t>::OpDag> brcBaseTiling(context_); | ||
| 87 | + ret = brcBaseTiling.DoTiling(); | ||
| 88 | + tilingKey = GET_TPL_TILING_KEY(brcBaseTiling.GetSchMode()); | ||
| 79 | } else { | 89 | } else { |
| 80 | - OP_LOGE_FOR_INVALID_DTYPE( | 90 | + OP_LOGE_FOR_INVALID_DTYPE(context_->GetNodeName(), "x1", |
| 81 | - context_->GetNodeName(), "x1", ge::TypeUtils::DataTypeToSerialString(input0DType).c_str(), | 91 | + ge::TypeUtils::DataTypeToSerialString(input0DType).c_str(), |
| 82 | - "int16, uint16, int32 or int64"); | 92 | + "int8, uint8, int16, uint16, int32, uint32, int64 or uint64"); |
| 83 | return ge::GRAPH_FAILED; | 93 | return ge::GRAPH_FAILED; |
| 84 | } | 94 | } |
| 85 | return ret; | 95 | return ret; |
| 86 | } | 96 | } |
| 87 | 97 | ||
| 88 | -ge::graphStatus BitwiseAndTiling::DoLibApiTiling() | 98 | +ge::graphStatus BitwiseAndTiling::DoLibApiTiling() { return ge::GRAPH_SUCCESS; } |
| 89 | -{ | ||
| 90 | - return ge::GRAPH_SUCCESS; | ||
| 91 | -} | ||
| 92 | 99 | ||
| 93 | -uint64_t BitwiseAndTiling::GetTilingKey() const | 100 | +uint64_t BitwiseAndTiling::GetTilingKey() const { return tilingKey; } |
| 94 | -{ | ||
| 95 | - return tilingKey; | ||
| 96 | -} | ||
| 97 | 101 | ||
| 98 | -ge::graphStatus BitwiseAndTiling::GetWorkspaceSize() | 102 | +ge::graphStatus BitwiseAndTiling::GetWorkspaceSize() { return ge::GRAPH_SUCCESS; } |
| 99 | -{ | ||
| 100 | - return ge::GRAPH_SUCCESS; | ||
| 101 | -} | ||
| 102 | 103 | ||
| 103 | -ge::graphStatus BitwiseAndTiling::PostTiling() | 104 | +ge::graphStatus BitwiseAndTiling::PostTiling() { return ge::GRAPH_SUCCESS; } |
| 104 | -{ | ||
| 105 | - return ge::GRAPH_SUCCESS; | ||
| 106 | -} | ||
| 107 | 105 | ||
| 108 | -ge::graphStatus BitwiseAndTiling::GetPlatformInfo() | 106 | +ge::graphStatus BitwiseAndTiling::GetPlatformInfo() { return ge::GRAPH_SUCCESS; } |
| 109 | -{ | ||
| 110 | - return ge::GRAPH_SUCCESS; | ||
| 111 | -} | ||
| 112 | 107 | ||
| 113 | ge::graphStatus TilingForBitwiseAnd(gert::TilingContext* context) | 108 | ge::graphStatus TilingForBitwiseAnd(gert::TilingContext* context) |
| 114 | { | 109 | { |
| @@ -134,9 +129,7 @@ ge::graphStatus TilingPrepareForBitwiseAnd(gert::TilingParseContext* context) | |||
| 134 | return ge::GRAPH_SUCCESS; | 129 | return ge::GRAPH_SUCCESS; |
| 135 | } | 130 | } |
| 136 | 131 | ||
| 137 | -IMPL_OP_OPTILING(BitwiseAnd) | 132 | +IMPL_OP_OPTILING(BitwiseAnd).Tiling(TilingForBitwiseAnd).TilingParse<BitWiseAndCompileInfo>(TilingPrepareForBitwiseAnd); |
| 138 | - .Tiling(TilingForBitwiseAnd) | ||
| 139 | - .TilingParse<BitWiseAndCompileInfo>(TilingPrepareForBitwiseAnd); | ||
| 140 | 133 | ||
| 141 | REGISTER_OPS_TILING_TEMPLATE(BitwiseAnd, BitwiseAndTiling, BITWISE_AND_COMMON_TILING_PRIORITY); | 134 | REGISTER_OPS_TILING_TEMPLATE(BitwiseAnd, BitwiseAndTiling, BITWISE_AND_COMMON_TILING_PRIORITY); |
| 142 | -} // namespace optiling | 135 | +} // namespace optiling |
| @@ -21,19 +21,28 @@ public: | |||
| 21 | { | 21 | { |
| 22 | this->Input("x1") | 22 | this->Input("x1") |
| 23 | .ParamType(REQUIRED) | 23 | .ParamType(REQUIRED) |
| 24 | - .DataType({ge::DT_INT16, ge::DT_UINT16, ge::DT_INT32, ge::DT_INT64}) | 24 | + .DataType({ge::DT_INT8, ge::DT_INT16, ge::DT_UINT8, ge::DT_UINT16, ge::DT_INT32, ge::DT_UINT32, |
| 25 | - .Format({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND}) | 25 | + ge::DT_INT64, ge::DT_UINT64}) |
| 26 | - .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND}); | 26 | + .Format({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, |
| 27 | + ge::FORMAT_ND, ge::FORMAT_ND}) | ||
| 28 | + .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, | ||
| 29 | + ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND}); | ||
| 27 | this->Input("x2") | 30 | this->Input("x2") |
| 28 | .ParamType(REQUIRED) | 31 | .ParamType(REQUIRED) |
| 29 | - .DataType({ge::DT_INT16, ge::DT_UINT16, ge::DT_INT32, ge::DT_INT64}) | 32 | + .DataType({ge::DT_INT8, ge::DT_INT16, ge::DT_UINT8, ge::DT_UINT16, ge::DT_INT32, ge::DT_UINT32, |
| 30 | - .Format({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND}) | 33 | + ge::DT_INT64, ge::DT_UINT64}) |
| 31 | - .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND}); | 34 | + .Format({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, |
| 35 | + ge::FORMAT_ND, ge::FORMAT_ND}) | ||
| 36 | + .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, | ||
| 37 | + ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND}); | ||
| 32 | this->Output("y") | 38 | this->Output("y") |
| 33 | .ParamType(REQUIRED) | 39 | .ParamType(REQUIRED) |
| 34 | - .DataType({ge::DT_INT16, ge::DT_UINT16, ge::DT_INT32, ge::DT_INT64}) | 40 | + .DataType({ge::DT_INT8, ge::DT_INT16, ge::DT_UINT8, ge::DT_UINT16, ge::DT_INT32, ge::DT_UINT32, |
| 35 | - .Format({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND}) | 41 | + ge::DT_INT64, ge::DT_UINT64}) |
| 36 | - .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND}); | 42 | + .Format({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, |
| 43 | + ge::FORMAT_ND, ge::FORMAT_ND}) | ||
| 44 | + .UnknownShapeFormat({ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND, | ||
| 45 | + ge::FORMAT_ND, ge::FORMAT_ND, ge::FORMAT_ND}); | ||
| 37 | OpAICoreConfig aicoreConfig; | 46 | OpAICoreConfig aicoreConfig; |
| 38 | aicoreConfig.DynamicCompileStaticFlag(true) | 47 | aicoreConfig.DynamicCompileStaticFlag(true) |
| 39 | .DynamicFormatFlag(false) | 48 | .DynamicFormatFlag(false) |
| @@ -1,6 +1,46 @@ | |||
| 1 | { | 1 | { |
| 2 | "op_type": "BitwiseAnd", | 2 | "op_type": "BitwiseAnd", |
| 3 | "op_list": [ | 3 | "op_list": [ |
| 4 | + { | ||
| 5 | + "bin_filename": "BitwiseAnd_int8", | ||
| 6 | + "inputs": [ | ||
| 7 | + { | ||
| 8 | + "name": "x1", | ||
| 9 | + "index": 0, | ||
| 10 | + "dtype": "int8", | ||
| 11 | + "format": "ND", | ||
| 12 | + "paramType": "required", | ||
| 13 | + "shape": [ | ||
| 14 | + -2 | ||
| 15 | + ], | ||
| 16 | + "format_match_mode": "FormatAgnostic" | ||
| 17 | + }, | ||
| 18 | + { | ||
| 19 | + "name": "x2", | ||
| 20 | + "index": 1, | ||
| 21 | + "dtype": "int8", | ||
| 22 | + "format": "ND", | ||
| 23 | + "paramType": "required", | ||
| 24 | + "shape": [ | ||
| 25 | + -2 | ||
| 26 | + ], | ||
| 27 | + "format_match_mode": "FormatAgnostic" | ||
| 28 | + } | ||
| 29 | + ], | ||
| 30 | + "outputs": [ | ||
| 31 | + { | ||
| 32 | + "name": "y", | ||
| 33 | + "index": 0, | ||
| 34 | + "dtype": "int8", | ||
| 35 | + "format": "ND", | ||
| 36 | + "paramType": "required", | ||
| 37 | + "shape": [ | ||
| 38 | + -2 | ||
| 39 | + ], | ||
| 40 | + "format_match_mode": "FormatAgnostic" | ||
| 41 | + } | ||
| 42 | + ] | ||
| 43 | + }, | ||
| 4 | { | 44 | { |
| 5 | "bin_filename": "BitwiseAnd_int16", | 45 | "bin_filename": "BitwiseAnd_int16", |
| 6 | "inputs": [ | 46 | "inputs": [ |
| @@ -41,6 +81,46 @@ | |||
| 41 | } | 81 | } |
| 42 | ] | 82 | ] |
| 43 | }, | 83 | }, |
| 84 | + { | ||
| 85 | + "bin_filename": "BitwiseAnd_uint8", | ||
| 86 | + "inputs": [ | ||
| 87 | + { | ||
| 88 | + "name": "x1", | ||
| 89 | + "index": 0, | ||
| 90 | + "dtype": "uint8", | ||
| 91 | + "format": "ND", | ||
| 92 | + "paramType": "required", | ||
| 93 | + "shape": [ | ||
| 94 | + -2 | ||
| 95 | + ], | ||
| 96 | + "format_match_mode": "FormatAgnostic" | ||
| 97 | + }, | ||
| 98 | + { | ||
| 99 | + "name": "x2", | ||
| 100 | + "index": 1, | ||
| 101 | + "dtype": "uint8", | ||
| 102 | + "format": "ND", | ||
| 103 | + "paramType": "required", | ||
| 104 | + "shape": [ | ||
| 105 | + -2 | ||
| 106 | + ], | ||
| 107 | + "format_match_mode": "FormatAgnostic" | ||
| 108 | + } | ||
| 109 | + ], | ||
| 110 | + "outputs": [ | ||
| 111 | + { | ||
| 112 | + "name": "y", | ||
| 113 | + "index": 0, | ||
| 114 | + "dtype": "uint8", | ||
| 115 | + "format": "ND", | ||
| 116 | + "paramType": "required", | ||
| 117 | + "shape": [ | ||
| 118 | + -2 | ||
| 119 | + ], | ||
| 120 | + "format_match_mode": "FormatAgnostic" | ||
| 121 | + } | ||
| 122 | + ] | ||
| 123 | + }, | ||
| 44 | { | 124 | { |
| 45 | "bin_filename": "BitwiseAnd_uint16", | 125 | "bin_filename": "BitwiseAnd_uint16", |
| 46 | "inputs": [ | 126 | "inputs": [ |
| @@ -121,6 +201,46 @@ | |||
| 121 | } | 201 | } |
| 122 | ] | 202 | ] |
| 123 | }, | 203 | }, |
| 204 | + { | ||
| 205 | + "bin_filename": "BitwiseAnd_uint32", | ||
| 206 | + "inputs": [ | ||
| 207 | + { | ||
| 208 | + "name": "x1", | ||
| 209 | + "index": 0, | ||
| 210 | + "dtype": "uint32", | ||
| 211 | + "format": "ND", | ||
| 212 | + "paramType": "required", | ||
| 213 | + "shape": [ | ||
| 214 | + -2 | ||
| 215 | + ], | ||
| 216 | + "format_match_mode": "FormatAgnostic" | ||
| 217 | + }, | ||
| 218 | + { | ||
| 219 | + "name": "x2", | ||
| 220 | + "index": 1, | ||
| 221 | + "dtype": "uint32", | ||
| 222 | + "format": "ND", | ||
| 223 | + "paramType": "required", | ||
| 224 | + "shape": [ | ||
| 225 | + -2 | ||
| 226 | + ], | ||
| 227 | + "format_match_mode": "FormatAgnostic" | ||
| 228 | + } | ||
| 229 | + ], | ||
| 230 | + "outputs": [ | ||
| 231 | + { | ||
| 232 | + "name": "y", | ||
| 233 | + "index": 0, | ||
| 234 | + "dtype": "uint32", | ||
| 235 | + "format": "ND", | ||
| 236 | + "paramType": "required", | ||
| 237 | + "shape": [ | ||
| 238 | + -2 | ||
| 239 | + ], | ||
| 240 | + "format_match_mode": "FormatAgnostic" | ||
| 241 | + } | ||
| 242 | + ] | ||
| 243 | + }, | ||
| 124 | { | 244 | { |
| 125 | "bin_filename": "BitwiseAnd_int64", | 245 | "bin_filename": "BitwiseAnd_int64", |
| 126 | "inputs": [ | 246 | "inputs": [ |
| @@ -160,6 +280,46 @@ | |||
| 160 | "format_match_mode": "FormatAgnostic" | 280 | "format_match_mode": "FormatAgnostic" |
| 161 | } | 281 | } |
| 162 | ] | 282 | ] |
| 283 | + }, | ||
| 284 | + { | ||
| 285 | + "bin_filename": "BitwiseAnd_uint64", | ||
| 286 | + "inputs": [ | ||
| 287 | + { | ||
| 288 | + "name": "x1", | ||
| 289 | + "index": 0, | ||
| 290 | + "dtype": "uint64", | ||
| 291 | + "format": "ND", | ||
| 292 | + "paramType": "required", | ||
| 293 | + "shape": [ | ||
| 294 | + -2 | ||
| 295 | + ], | ||
| 296 | + "format_match_mode": "FormatAgnostic" | ||
| 297 | + }, | ||
| 298 | + { | ||
| 299 | + "name": "x2", | ||
| 300 | + "index": 1, | ||
| 301 | + "dtype": "uint64", | ||
| 302 | + "format": "ND", | ||
| 303 | + "paramType": "required", | ||
| 304 | + "shape": [ | ||
| 305 | + -2 | ||
| 306 | + ], | ||
| 307 | + "format_match_mode": "FormatAgnostic" | ||
| 308 | + } | ||
| 309 | + ], | ||
| 310 | + "outputs": [ | ||
| 311 | + { | ||
| 312 | + "name": "y", | ||
| 313 | + "index": 0, | ||
| 314 | + "dtype": "uint64", | ||
| 315 | + "format": "ND", | ||
| 316 | + "paramType": "required", | ||
| 317 | + "shape": [ | ||
| 318 | + -2 | ||
| 319 | + ], | ||
| 320 | + "format_match_mode": "FormatAgnostic" | ||
| 321 | + } | ||
| 322 | + ] | ||
| 163 | } | 323 | } |
| 164 | ] | 324 | ] |
| 165 | - } | 325 | + } |
| @@ -95,6 +95,32 @@ TEST_F(l2_bitwise_and_test, case_bitwise_and_tensor_int64) | |||
| 95 | EXPECT_EQ(aclRet, ACL_SUCCESS); | 95 | EXPECT_EQ(aclRet, ACL_SUCCESS); |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | +// test UINT32 | ||
| 99 | +TEST_F(l2_bitwise_and_test, case_bitwise_and_tensor_uint32) | ||
| 100 | +{ | ||
| 101 | + auto self_desc = TensorDesc({3, 3, 3}, ACL_UINT32, ACL_FORMAT_ND).ValueRange(0, 10); | ||
| 102 | + auto other_desc = TensorDesc({3, 3, 3}, ACL_UINT32, ACL_FORMAT_ND).ValueRange(0, 10); | ||
| 103 | + auto out_desc = TensorDesc({3, 3, 3}, ACL_UINT32, ACL_FORMAT_ND); | ||
| 104 | + | ||
| 105 | + auto ut = OP_API_UT(aclnnBitwiseAndTensor, INPUT(self_desc, other_desc), OUTPUT(out_desc)); | ||
| 106 | + uint64_t workspace_size = 0; | ||
| 107 | + aclnnStatus aclRet = ut.TestGetWorkspaceSize(&workspace_size); | ||
| 108 | + EXPECT_EQ(aclRet, ACL_SUCCESS); | ||
| 109 | +} | ||
| 110 | + | ||
| 111 | +// test UINT64 | ||
| 112 | +TEST_F(l2_bitwise_and_test, case_bitwise_and_tensor_uint64) | ||
| 113 | +{ | ||
| 114 | + auto self_desc = TensorDesc({3, 3, 3}, ACL_UINT64, ACL_FORMAT_ND).ValueRange(0, 10); | ||
| 115 | + auto other_desc = TensorDesc({3, 3, 3}, ACL_UINT64, ACL_FORMAT_ND).ValueRange(0, 10); | ||
| 116 | + auto out_desc = TensorDesc({3, 3, 3}, ACL_UINT64, ACL_FORMAT_ND); | ||
| 117 | + | ||
| 118 | + auto ut = OP_API_UT(aclnnBitwiseAndTensor, INPUT(self_desc, other_desc), OUTPUT(out_desc)); | ||
| 119 | + uint64_t workspace_size = 0; | ||
| 120 | + aclnnStatus aclRet = ut.TestGetWorkspaceSize(&workspace_size); | ||
| 121 | + EXPECT_EQ(aclRet, ACL_SUCCESS); | ||
| 122 | +} | ||
| 123 | + | ||
| 98 | // test BOOL | 124 | // test BOOL |
| 99 | TEST_F(l2_bitwise_and_test, case_bitwise_and_tensor_bool) | 125 | TEST_F(l2_bitwise_and_test, case_bitwise_and_tensor_bool) |
| 100 | { | 126 | { |
| @@ -161,6 +187,165 @@ TEST_F(l2_bitwise_and_test, case_bitwise_and_scalar_int64) | |||
| 161 | EXPECT_EQ(aclRet, ACL_SUCCESS); | 187 | EXPECT_EQ(aclRet, ACL_SUCCESS); |
| 162 | } | 188 | } |
| 163 | 189 | ||
| 190 | +// === Ascend 950 RegBase dtype gate === | ||
| 191 | +// scalar的uint32/uint64仅RegBase(Ascend 950)支持,用例显式切ASCEND950并在结束还原ASCEND910B | ||
| 192 | +TEST_F(l2_bitwise_and_test, ascend950_case_bitwise_and_scalar_uint32) | ||
| 193 | +{ | ||
| 194 | + op::SetPlatformSocVersion(op::SocVersion::ASCEND950); | ||
| 195 | + auto self_desc = TensorDesc({3, 3, 3}, ACL_UINT32, ACL_FORMAT_ND).ValueRange(0, 10); | ||
| 196 | + auto scalar_desc = ScalarDesc(uint32_t(5)); | ||
| 197 | + auto out_desc = TensorDesc({3, 3, 3}, ACL_UINT32, ACL_FORMAT_ND); | ||
| 198 | + | ||
| 199 | + auto ut = OP_API_UT(aclnnBitwiseAndScalar, INPUT(self_desc, scalar_desc), OUTPUT(out_desc)); | ||
| 200 | + uint64_t workspace_size = 0; | ||
| 201 | + aclnnStatus aclRet = ut.TestGetWorkspaceSize(&workspace_size); | ||
| 202 | + EXPECT_EQ(aclRet, ACL_SUCCESS); | ||
| 203 | + op::SetPlatformSocVersion(op::SocVersion::ASCEND910B); | ||
| 204 | +} | ||
| 205 | + | ||
| 206 | +TEST_F(l2_bitwise_and_test, ascend950_case_bitwise_and_scalar_uint64) | ||
| 207 | +{ | ||
| 208 | + op::SetPlatformSocVersion(op::SocVersion::ASCEND950); | ||
| 209 | + auto self_desc = TensorDesc({3, 3, 3}, ACL_UINT64, ACL_FORMAT_ND).ValueRange(0, 10); | ||
| 210 | + auto scalar_desc = ScalarDesc(uint64_t(5)); | ||
| 211 | + auto out_desc = TensorDesc({3, 3, 3}, ACL_UINT64, ACL_FORMAT_ND); | ||
| 212 | + | ||
| 213 | + auto ut = OP_API_UT(aclnnBitwiseAndScalar, INPUT(self_desc, scalar_desc), OUTPUT(out_desc)); | ||
| 214 | + uint64_t workspace_size = 0; | ||
| 215 | + aclnnStatus aclRet = ut.TestGetWorkspaceSize(&workspace_size); | ||
| 216 | + EXPECT_EQ(aclRet, ACL_SUCCESS); | ||
| 217 | + op::SetPlatformSocVersion(op::SocVersion::ASCEND910B); | ||
| 218 | +} | ||
| 219 | + | ||
| 220 | +TEST_F(l2_bitwise_and_test, case_bitwise_and_scalar_uint32_not_support_on_910b) | ||
| 221 | +{ | ||
| 222 | + op::SetPlatformSocVersion(op::SocVersion::ASCEND910B); | ||
| 223 | + auto self_desc = TensorDesc({3, 3, 3}, ACL_UINT32, ACL_FORMAT_ND).ValueRange(0, 10); | ||
| 224 | + auto scalar_desc = ScalarDesc(uint32_t(5)); | ||
| 225 | + auto out_desc = TensorDesc({3, 3, 3}, ACL_UINT32, ACL_FORMAT_ND); | ||
| 226 | + | ||
| 227 | + auto ut = OP_API_UT(aclnnBitwiseAndScalar, INPUT(self_desc, scalar_desc), OUTPUT(out_desc)); | ||
| 228 | + uint64_t workspace_size = 0; | ||
| 229 | + aclnnStatus aclRet = ut.TestGetWorkspaceSize(&workspace_size); | ||
| 230 | + EXPECT_EQ(aclRet, ACLNN_ERR_PARAM_INVALID); | ||
| 231 | +} | ||
| 232 | + | ||
| 233 | +TEST_F(l2_bitwise_and_test, case_bitwise_and_scalar_uint64_not_support_on_910b) | ||
| 234 | +{ | ||
| 235 | + op::SetPlatformSocVersion(op::SocVersion::ASCEND910B); | ||
| 236 | + auto self_desc = TensorDesc({3, 3, 3}, ACL_UINT64, ACL_FORMAT_ND).ValueRange(0, 10); | ||
| 237 | + auto scalar_desc = ScalarDesc(uint64_t(5)); | ||
| 238 | + auto out_desc = TensorDesc({3, 3, 3}, ACL_UINT64, ACL_FORMAT_ND); | ||
| 239 | + | ||
| 240 | + auto ut = OP_API_UT(aclnnBitwiseAndScalar, INPUT(self_desc, scalar_desc), OUTPUT(out_desc)); | ||
| 241 | + uint64_t workspace_size = 0; | ||
| 242 | + aclnnStatus aclRet = ut.TestGetWorkspaceSize(&workspace_size); | ||
| 243 | + EXPECT_EQ(aclRet, ACLNN_ERR_PARAM_INVALID); | ||
| 244 | +} | ||
| 245 | + | ||
| 246 | +// out=bool推导拒绝(对标竞品CanCast规则) | ||
| 247 | +TEST_F(l2_bitwise_and_test, case_bitwise_and_tensor_int_out_bool_not_support) | ||
| 248 | +{ | ||
| 249 | + auto self_desc = TensorDesc({3, 3, 3}, ACL_INT32, ACL_FORMAT_ND).ValueRange(-10, 10); | ||
| 250 | + auto other_desc = TensorDesc({3, 3, 3}, ACL_INT32, ACL_FORMAT_ND).ValueRange(-10, 10); | ||
| 251 | + auto out_desc = TensorDesc({3, 3, 3}, ACL_BOOL, ACL_FORMAT_ND); | ||
| 252 | + | ||
| 253 | + auto ut = OP_API_UT(aclnnBitwiseAndTensor, INPUT(self_desc, other_desc), OUTPUT(out_desc)); | ||
| 254 | + uint64_t workspace_size = 0; | ||
| 255 | + aclnnStatus aclRet = ut.TestGetWorkspaceSize(&workspace_size); | ||
| 256 | + EXPECT_EQ(aclRet, ACLNN_ERR_PARAM_INVALID); | ||
| 257 | +} | ||
| 258 | + | ||
| 259 | +// 950标量弱推导: int64标量不抬升int32推导(对标竞品wrapped number) | ||
| 260 | +TEST_F(l2_bitwise_and_test, ascend950_case_bitwise_and_scalar_int32_weak_scalar) | ||
| 261 | +{ | ||
| 262 | + op::SetPlatformSocVersion(op::SocVersion::ASCEND950); | ||
| 263 | + auto self_desc = TensorDesc({3, 3, 3}, ACL_INT32, ACL_FORMAT_ND).ValueRange(-10, 10); | ||
| 264 | + auto scalar_desc = ScalarDesc(int64_t(5)); | ||
| 265 | + auto out_desc = TensorDesc({3, 3, 3}, ACL_INT32, ACL_FORMAT_ND); | ||
| 266 | + | ||
| 267 | + auto ut = OP_API_UT(aclnnBitwiseAndScalar, INPUT(self_desc, scalar_desc), OUTPUT(out_desc)); | ||
| 268 | + uint64_t workspace_size = 0; | ||
| 269 | + aclnnStatus aclRet = ut.TestGetWorkspaceSize(&workspace_size); | ||
| 270 | + EXPECT_EQ(aclRet, ACL_SUCCESS); | ||
| 271 | + op::SetPlatformSocVersion(op::SocVersion::ASCEND910B); | ||
| 272 | +} | ||
| 273 | + | ||
| 274 | +// i64输入, out=i32收窄场景 | ||
| 275 | +TEST_F(l2_bitwise_and_test, ascend950_case_bitwise_and_tensor_int64_out_int32) | ||
| 276 | +{ | ||
| 277 | + op::SetPlatformSocVersion(op::SocVersion::ASCEND950); | ||
| 278 | + auto self_desc = TensorDesc({3, 3, 3}, ACL_INT64, ACL_FORMAT_ND).ValueRange(-10, 10); | ||
| 279 | + auto other_desc = TensorDesc({3, 3, 3}, ACL_INT64, ACL_FORMAT_ND).ValueRange(-10, 10); | ||
| 280 | + auto out_desc = TensorDesc({3, 3, 3}, ACL_INT32, ACL_FORMAT_ND); | ||
| 281 | + | ||
| 282 | + auto ut = OP_API_UT(aclnnBitwiseAndTensor, INPUT(self_desc, other_desc), OUTPUT(out_desc)); | ||
| 283 | + uint64_t workspace_size = 0; | ||
| 284 | + aclnnStatus aclRet = ut.TestGetWorkspaceSize(&workspace_size); | ||
| 285 | + EXPECT_EQ(aclRet, ACL_SUCCESS); | ||
| 286 | + op::SetPlatformSocVersion(op::SocVersion::ASCEND910B); | ||
| 287 | +} | ||
| 288 | + | ||
| 289 | +// inplace混合位宽: i32 |= i64 | ||
| 290 | +TEST_F(l2_bitwise_and_test, ascend950_case_bitwise_and_inplace_int32_or_int64) | ||
| 291 | +{ | ||
| 292 | + op::SetPlatformSocVersion(op::SocVersion::ASCEND950); | ||
| 293 | + auto self_desc = TensorDesc({3, 3, 3}, ACL_INT32, ACL_FORMAT_ND).ValueRange(-10, 10); | ||
| 294 | + auto other_desc = TensorDesc({3, 3, 3}, ACL_INT64, ACL_FORMAT_ND).ValueRange(-10, 10); | ||
| 295 | + auto ut = OP_API_UT(aclnnInplaceBitwiseAndTensor, INPUT(self_desc, other_desc), OUTPUT()); | ||
| 296 | + uint64_t workspace_size = 0; | ||
| 297 | + EXPECT_EQ(ut.TestGetWorkspaceSize(&workspace_size), ACL_SUCCESS); | ||
| 298 | + op::SetPlatformSocVersion(op::SocVersion::ASCEND910B); | ||
| 299 | +} | ||
| 300 | + | ||
| 301 | +// inplace混合位宽: u8 |= i64 | ||
| 302 | +TEST_F(l2_bitwise_and_test, ascend950_case_bitwise_and_inplace_uint8_or_int64) | ||
| 303 | +{ | ||
| 304 | + op::SetPlatformSocVersion(op::SocVersion::ASCEND950); | ||
| 305 | + auto self_desc = TensorDesc({3, 3, 3}, ACL_UINT8, ACL_FORMAT_ND).ValueRange(0, 10); | ||
| 306 | + auto other_desc = TensorDesc({3, 3, 3}, ACL_INT64, ACL_FORMAT_ND).ValueRange(-10, 10); | ||
| 307 | + auto ut = OP_API_UT(aclnnInplaceBitwiseAndTensor, INPUT(self_desc, other_desc), OUTPUT()); | ||
| 308 | + uint64_t workspace_size = 0; | ||
| 309 | + EXPECT_EQ(ut.TestGetWorkspaceSize(&workspace_size), ACL_SUCCESS); | ||
| 310 | + op::SetPlatformSocVersion(op::SocVersion::ASCEND910B); | ||
| 311 | +} | ||
| 312 | + | ||
| 313 | +// 混合uint32/uint64推导拒绝(对标竞品c10::promoteTypes对barebones unsigned的限制) | ||
| 314 | +TEST_F(l2_bitwise_and_test, ascend950_case_bitwise_and_inplace_uint32_or_uint64_not_support) | ||
| 315 | +{ | ||
| 316 | + op::SetPlatformSocVersion(op::SocVersion::ASCEND950); | ||
| 317 | + auto self_desc = TensorDesc({3, 3, 3}, ACL_UINT32, ACL_FORMAT_ND).ValueRange(0, 10); | ||
| 318 | + auto other_desc = TensorDesc({3, 3, 3}, ACL_UINT64, ACL_FORMAT_ND).ValueRange(0, 10); | ||
| 319 | + auto ut = OP_API_UT(aclnnInplaceBitwiseAndTensor, INPUT(self_desc, other_desc), OUTPUT()); | ||
| 320 | + uint64_t workspace_size = 0; | ||
| 321 | + EXPECT_EQ(ut.TestGetWorkspaceSize(&workspace_size), ACLNN_ERR_PARAM_INVALID); | ||
| 322 | + op::SetPlatformSocVersion(op::SocVersion::ASCEND910B); | ||
| 323 | +} | ||
| 324 | + | ||
| 325 | +// out升宽场景: i32输入, out=i64 | ||
| 326 | +TEST_F(l2_bitwise_and_test, case_bitwise_and_tensor_int32_out_int64) | ||
| 327 | +{ | ||
| 328 | + auto self_desc = TensorDesc({3, 3, 3}, ACL_INT32, ACL_FORMAT_ND).ValueRange(-10, 10); | ||
| 329 | + auto other_desc = TensorDesc({3, 3, 3}, ACL_INT32, ACL_FORMAT_ND).ValueRange(-10, 10); | ||
| 330 | + auto out_desc = TensorDesc({3, 3, 3}, ACL_INT64, ACL_FORMAT_ND); | ||
| 331 | + auto ut = OP_API_UT(aclnnBitwiseAndTensor, INPUT(self_desc, other_desc), OUTPUT(out_desc)); | ||
| 332 | + uint64_t workspace_size = 0; | ||
| 333 | + EXPECT_EQ(ut.TestGetWorkspaceSize(&workspace_size), ACL_SUCCESS); | ||
| 334 | +} | ||
| 335 | + | ||
| 336 | +// u64输入, out=u32收窄场景 | ||
| 337 | +TEST_F(l2_bitwise_and_test, ascend950_case_bitwise_and_tensor_uint64_out_uint32) | ||
| 338 | +{ | ||
| 339 | + op::SetPlatformSocVersion(op::SocVersion::ASCEND950); | ||
| 340 | + auto self_desc = TensorDesc({3, 3, 3}, ACL_UINT64, ACL_FORMAT_ND).ValueRange(0, 10); | ||
| 341 | + auto other_desc = TensorDesc({3, 3, 3}, ACL_UINT64, ACL_FORMAT_ND).ValueRange(0, 10); | ||
| 342 | + auto out_desc = TensorDesc({3, 3, 3}, ACL_UINT32, ACL_FORMAT_ND); | ||
| 343 | + auto ut = OP_API_UT(aclnnBitwiseAndTensor, INPUT(self_desc, other_desc), OUTPUT(out_desc)); | ||
| 344 | + uint64_t workspace_size = 0; | ||
| 345 | + EXPECT_EQ(ut.TestGetWorkspaceSize(&workspace_size), ACL_SUCCESS); | ||
| 346 | + op::SetPlatformSocVersion(op::SocVersion::ASCEND910B); | ||
| 347 | +} | ||
| 348 | + | ||
| 164 | // === Error cases === | 349 | // === Error cases === |
| 165 | // test nullptr | 350 | // test nullptr |
| 166 | TEST_F(l2_bitwise_and_test, case_bitwise_and_tensor_nullptr) | 351 | TEST_F(l2_bitwise_and_test, case_bitwise_and_tensor_nullptr) |