mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-07 17:15:29 +00:00
DML EP Bitwise operators opset 18 (#15892)
### Description <!-- Describe your changes. --> Add dml registration for bitwise and, or, xor and not added in opset 18. ### Motivation and Context <!-- - Why is this change required? What problem does it solve? - If it fixes an open issue, please link to the issue here. --> --------- Co-authored-by: Linnea May <linneamay@microsoft.com>
This commit is contained in:
parent
5abaca9d69
commit
0d6416c0e9
7 changed files with 308 additions and 21 deletions
|
|
@ -880,6 +880,10 @@ Do not modify directly.*
|
|||
|||9+|**T** = tensor(float), tensor(float16)|
|
||||
|||7+|**T** = tensor(float), tensor(float16)|
|
||||
|BitShift|*in* X:**T**<br> *in* Y:**T**<br> *out* Z:**T**|11+|**T** = tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)|
|
||||
|BitwiseAnd|*in* A:**T**<br> *in* B:**T**<br> *out* C:**T**|18+|**T** = tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)|
|
||||
|BitwiseNot|*in* X:**T**<br> *out* Y:**T**|18+|**T** = tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)|
|
||||
|BitwiseOr|*in* A:**T**<br> *in* B:**T**<br> *out* C:**T**|18+|**T** = tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)|
|
||||
|BitwiseXor|*in* A:**T**<br> *in* B:**T**<br> *out* C:**T**|18+|**T** = tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)|
|
||||
|Cast|*in* input:**T1**<br> *out* output:**T2**|13+|**T1** = tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)<br/> **T2** = tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)|
|
||||
|||9+|**T1** = tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)<br/> **T2** = tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)|
|
||||
|||6+|**T1** = tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)<br/> **T2** = tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(int16), tensor(int32), tensor(int64), tensor(int8), tensor(uint16), tensor(uint32), tensor(uint64), tensor(uint8)|
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ void SetFusedActivation(T& opDesc, const DML_OPERATOR_DESC* fusedActivation)
|
|||
|
||||
template<>
|
||||
void SetFusedActivation(DML_ELEMENT_WISE_ADD1_OPERATOR_DESC& opDesc, const DML_OPERATOR_DESC* fusedActivation)
|
||||
{
|
||||
{
|
||||
opDesc.FusedActivation = fusedActivation;
|
||||
}
|
||||
|
||||
|
|
@ -118,7 +118,7 @@ public:
|
|||
DML_OPERATOR_DESC opDescDesc = { ApiTraits::OperatorDescTraits<TOperatorDesc>::Type, &opDesc};
|
||||
|
||||
if (fusedActivation != std::nullopt)
|
||||
{
|
||||
{
|
||||
// Activation is only fused for two-input sum operators
|
||||
ORT_THROW_HR_IF(E_INVALIDARG, opDescDesc.Type != DML_OPERATOR_ELEMENT_WISE_ADD1 || kernelInfo.GetInputCount() > 2);
|
||||
|
||||
|
|
@ -160,7 +160,7 @@ public:
|
|||
|
||||
std::optional<ActivationOperatorDesc> fusedActivation = FusionHelpers::TryGetFusedActivationDesc(kernelInfo);
|
||||
DML_OPERATOR_DESC fusedActivationDmlDesc = fusedActivation ? fusedActivation->GetDmlDesc() : DML_OPERATOR_DESC();
|
||||
|
||||
|
||||
// Activation is only fused for two-input sum operators
|
||||
ORT_THROW_HR_IF(E_INVALIDARG, fusedActivation != std::nullopt && inputCount != 2);
|
||||
|
||||
|
|
@ -294,7 +294,7 @@ public:
|
|||
meanDesc.ATensor = &inputDescs[0];
|
||||
meanDesc.BTensor = &inputDescs[1];
|
||||
meanDesc.OutputTensor = &outputDescs[0];
|
||||
|
||||
|
||||
SetDmlOperatorDesc({ DML_OPERATOR_ELEMENT_WISE_MEAN, &meanDesc}, kernelInfo);
|
||||
}
|
||||
else
|
||||
|
|
@ -447,7 +447,7 @@ public:
|
|||
opDesc.OutputTensor = outputDescs.data();
|
||||
// MinMaxDataType will always be equal to inputDataTensorDataType
|
||||
// Assigning minMaxDataType to inputDataTensorDataType because this field
|
||||
// has to be assigned even if program does not go through below conditional
|
||||
// has to be assigned even if program does not go through below conditional
|
||||
// logic for some corner test case
|
||||
// Same applies to min and max value.
|
||||
opDesc.MinMaxDataType = this->m_inputTensorDescs[0].GetDmlDataType();
|
||||
|
|
@ -458,7 +458,7 @@ public:
|
|||
{
|
||||
ReadScalarTensorData(kernelInfo.GetConstantInputTensor(1), /*out*/ &opDesc.Min.Bytes, sizeof(opDesc.Min.Bytes));
|
||||
}
|
||||
if (kernelInfo.IsInputValid(2))
|
||||
if (kernelInfo.IsInputValid(2))
|
||||
{
|
||||
ReadScalarTensorData(kernelInfo.GetConstantInputTensor(2), /*out*/ &opDesc.Max.Bytes, sizeof(opDesc.Max.Bytes));
|
||||
}
|
||||
|
|
@ -720,6 +720,7 @@ DML_OP_DEFINE_CREATION_FUNCTION(Asinh, DmlOperatorElementwiseUnary<DM
|
|||
DML_OP_DEFINE_CREATION_FUNCTION(Acosh, DmlOperatorElementwiseUnary<DML_ELEMENT_WISE_ACOSH_OPERATOR_DESC>);
|
||||
DML_OP_DEFINE_CREATION_FUNCTION(Atanh, DmlOperatorElementwiseUnary<DML_ELEMENT_WISE_ATANH_OPERATOR_DESC>);
|
||||
DML_OP_DEFINE_CREATION_FUNCTION(Erf, DmlOperatorElementwiseUnary<DML_ELEMENT_WISE_ERF_OPERATOR_DESC>);
|
||||
DML_OP_DEFINE_CREATION_FUNCTION(BitwiseNot, DmlOperatorElementwiseUnary<DML_ELEMENT_WISE_BIT_NOT_OPERATOR_DESC>);
|
||||
|
||||
// Binary operators:
|
||||
DML_OP_DEFINE_CREATION_FUNCTION(Greater, DmlOperatorElementwiseBinary<DML_ELEMENT_WISE_LOGICAL_GREATER_THAN_OPERATOR_DESC>);
|
||||
|
|
@ -734,6 +735,9 @@ DML_OP_DEFINE_CREATION_FUNCTION(Add, DmlOperatorElementwiseBinary<D
|
|||
DML_OP_DEFINE_CREATION_FUNCTION(Sub, DmlOperatorElementwiseBinary<DML_ELEMENT_WISE_SUBTRACT_OPERATOR_DESC>);
|
||||
DML_OP_DEFINE_CREATION_FUNCTION(Mul, DmlOperatorElementwiseBinary<DML_ELEMENT_WISE_MULTIPLY_OPERATOR_DESC>);
|
||||
DML_OP_DEFINE_CREATION_FUNCTION(Div, DmlOperatorElementwiseBinary<DML_ELEMENT_WISE_DIVIDE_OPERATOR_DESC>);
|
||||
DML_OP_DEFINE_CREATION_FUNCTION(BitwiseAnd, DmlOperatorElementwiseBinary<DML_ELEMENT_WISE_BIT_AND_OPERATOR_DESC>);
|
||||
DML_OP_DEFINE_CREATION_FUNCTION(BitwiseOr, DmlOperatorElementwiseBinary<DML_ELEMENT_WISE_BIT_OR_OPERATOR_DESC>);
|
||||
DML_OP_DEFINE_CREATION_FUNCTION(BitwiseXor, DmlOperatorElementwiseBinary<DML_ELEMENT_WISE_BIT_XOR_OPERATOR_DESC>);
|
||||
|
||||
// Binary operators that support >2 inputs:
|
||||
DML_OP_DEFINE_CREATION_FUNCTION(Sum, DmlOperatorElementwiseBinaryLoop<DML_ELEMENT_WISE_ADD_OPERATOR_DESC>);
|
||||
|
|
|
|||
|
|
@ -441,6 +441,10 @@ DML_OP_EXTERN_CREATION_FUNCTION(Size);
|
|||
DML_OP_EXTERN_CREATION_FUNCTION(Attention);
|
||||
DML_OP_EXTERN_CREATION_FUNCTION(NonZero);
|
||||
DML_OP_EXTERN_CREATION_FUNCTION(QuickGelu);
|
||||
DML_OP_EXTERN_CREATION_FUNCTION(BitwiseAnd);
|
||||
DML_OP_EXTERN_CREATION_FUNCTION(BitwiseOr);
|
||||
DML_OP_EXTERN_CREATION_FUNCTION(BitwiseXor);
|
||||
DML_OP_EXTERN_CREATION_FUNCTION(BitwiseNot);
|
||||
|
||||
DML_OP_EXTERN_QUERY_FUNCTION(MaxPool);
|
||||
DML_OP_EXTERN_QUERY_FUNCTION(Slice);
|
||||
|
|
@ -487,6 +491,7 @@ constexpr static std::array<SupportedTensorDataTypes, 1> supportedTypeListFloat1
|
|||
constexpr static std::array<SupportedTensorDataTypes, 1> supportedTypeListFloat16to32SignedInts8to32 = {SupportedTensorDataTypes::Float16to32 | SupportedTensorDataTypes::Int8 | SupportedTensorDataTypes::Int16 | SupportedTensorDataTypes::Int32};
|
||||
constexpr static std::array<SupportedTensorDataTypes, 1> supportedTypeListFloat16to32Ints32to64 = {SupportedTensorDataTypes::Float16to32 | SupportedTensorDataTypes::Ints32Bit | SupportedTensorDataTypes::Ints64Bit};
|
||||
constexpr static std::array<SupportedTensorDataTypes, 1> supportedTypeListUInt8to64 = {SupportedTensorDataTypes::UInt8to64};
|
||||
constexpr static std::array<SupportedTensorDataTypes, 1> supportedTypeListAllIntegers = {SupportedTensorDataTypes::Ints8to64};
|
||||
constexpr static std::array<SupportedTensorDataTypes, 1> supportedTypeListNumericDefault = { SupportedTensorDataTypes::NumericDefault };
|
||||
constexpr static std::array<SupportedTensorDataTypes, 1> supportedTypeListAllScalars = {SupportedTensorDataTypes::AllScalars};
|
||||
constexpr static std::array<SupportedTensorDataTypes, 1> supportedTypeListAllScalarsAndSequences = {SupportedTensorDataTypes::AllScalars | SupportedTensorDataTypes::AllSequences};
|
||||
|
|
@ -841,6 +846,10 @@ constexpr static OperatorRegistrationInformation operatorRegistrationInformation
|
|||
{REG_INFO( 7, And, typeNameListDefault, supportedTypeListBool, DmlGraphSupport::Supported)},
|
||||
{REG_INFO( 7, Or, typeNameListDefault, supportedTypeListBool, DmlGraphSupport::Supported)},
|
||||
{REG_INFO( 7, Xor, typeNameListDefault, supportedTypeListBool, DmlGraphSupport::Supported)},
|
||||
{REG_INFO( 18, BitwiseAnd, typeNameListDefault, supportedTypeListAllIntegers, DmlGraphSupport::Supported)},
|
||||
{REG_INFO( 18, BitwiseOr, typeNameListDefault, supportedTypeListAllIntegers, DmlGraphSupport::Supported)},
|
||||
{REG_INFO( 18, BitwiseXor, typeNameListDefault, supportedTypeListAllIntegers, DmlGraphSupport::Supported)},
|
||||
{REG_INFO( 18, BitwiseNot, typeNameListDefault, supportedTypeListAllIntegers, DmlGraphSupport::Supported)},
|
||||
|
||||
// Imaging Operators
|
||||
{REG_INFO( 7, Crop, typeNameListDefault, supportedTypeListFloat16to32, DmlGraphSupport::Supported)},
|
||||
|
|
|
|||
|
|
@ -1571,6 +1571,10 @@ using ShapeInferenceHelper_Mod = GetBroadcastedOutputShapeHelper;
|
|||
using ShapeInferenceHelper_BitShift= GetBroadcastedOutputShapeHelper;
|
||||
using ShapeInferenceHelper_Round = GetBroadcastedOutputShapeHelper;
|
||||
using ShapeInferenceHelper_QuickGelu = GetOutputShapeAsInputShapeHelper;
|
||||
using ShapeInferenceHelper_BitwiseAnd = GetBroadcastedOutputShapeHelper;
|
||||
using ShapeInferenceHelper_BitwiseOr = GetBroadcastedOutputShapeHelper;
|
||||
using ShapeInferenceHelper_BitwiseXor = GetBroadcastedOutputShapeHelper;
|
||||
using ShapeInferenceHelper_BitwiseNot = GetBroadcastedOutputShapeHelper;
|
||||
|
||||
using ShapeInferenceHelper_ReduceSum = ReduceHelper;
|
||||
using ShapeInferenceHelper_ReduceMean = ReduceHelper;
|
||||
|
|
|
|||
|
|
@ -400,6 +400,10 @@ namespace OperatorHelper
|
|||
static const int sc_sinceVer_ReduceMin = 18;
|
||||
static const int sc_sinceVer_ReduceProd = 18;
|
||||
static const int sc_sinceVer_ReduceSumSquare = 18;
|
||||
static const int sc_sinceVer_BitwiseAnd = 18;
|
||||
static const int sc_sinceVer_BitwiseOr = 18;
|
||||
static const int sc_sinceVer_BitwiseXor = 18;
|
||||
static const int sc_sinceVer_BitwiseNot = 18;
|
||||
static const int sc_sinceVer_Split = 18;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1973,7 +1973,7 @@ TEST(MathOpTest, Less_broadcastBA) {
|
|||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Less_multidiretional_broadcastAB) {
|
||||
TEST(MathOpTest, Less_multidirectional_broadcastAB) {
|
||||
OpTester test("Less", 9);
|
||||
test.AddInput<int32_t>("A", {4, 1}, {10, 11, 12, 13});
|
||||
test.AddInput<int32_t>("B", {2}, {15, 7});
|
||||
|
|
@ -1981,7 +1981,7 @@ TEST(MathOpTest, Less_multidiretional_broadcastAB) {
|
|||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Less_multidiretional_broadcastBA) {
|
||||
TEST(MathOpTest, Less_multidirectional_broadcastBA) {
|
||||
OpTester test("Less", 9);
|
||||
test.AddInput<int32_t>("A", {2}, {15, 7});
|
||||
test.AddInput<int32_t>("B", {4, 1}, {10, 11, 12, 13});
|
||||
|
|
@ -2043,7 +2043,7 @@ TEST(MathOpTest, LessOrEqual_broadcastBA) {
|
|||
{kTensorrtExecutionProvider, kNnapiExecutionProvider, kOpenVINOExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(MathOpTest, LessOrEqual_multidiretional_broadcastAB) {
|
||||
TEST(MathOpTest, LessOrEqual_multidirectional_broadcastAB) {
|
||||
OpTester test("LessOrEqual", 12);
|
||||
test.AddInput<int32_t>("A", {4, 1}, {10, 11, 12, 13});
|
||||
test.AddInput<int32_t>("B", {2}, {15, 7});
|
||||
|
|
@ -2052,7 +2052,7 @@ TEST(MathOpTest, LessOrEqual_multidiretional_broadcastAB) {
|
|||
{kTensorrtExecutionProvider, kNnapiExecutionProvider, kOpenVINOExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(MathOpTest, LessOrEqual_multidiretional_broadcastBA) {
|
||||
TEST(MathOpTest, LessOrEqual_multidirectional_broadcastBA) {
|
||||
OpTester test("LessOrEqual", 12);
|
||||
test.AddInput<int32_t>("A", {2}, {15, 7});
|
||||
test.AddInput<int32_t>("B", {4, 1}, {10, 11, 12, 13});
|
||||
|
|
@ -2182,7 +2182,7 @@ TEST(MathOpTest, LessOrEqual_bfloat16_broadcastBA) {
|
|||
{kTensorrtExecutionProvider, kNnapiExecutionProvider, kOpenVINOExecutionProvider}, nullptr, &execution_providers);
|
||||
}
|
||||
|
||||
TEST(MathOpTest, LessOrEqual_multidiretional_bfloat16_broadcastAB) {
|
||||
TEST(MathOpTest, LessOrEqual_multidirectional_bfloat16_broadcastAB) {
|
||||
#ifdef USE_DNNL
|
||||
#ifdef DNNL_GPU_RUNTIME
|
||||
LOGS_DEFAULT(WARNING) << "Hardware does NOT support BF16";
|
||||
|
|
@ -2206,7 +2206,7 @@ TEST(MathOpTest, LessOrEqual_multidiretional_bfloat16_broadcastAB) {
|
|||
{kTensorrtExecutionProvider, kNnapiExecutionProvider, kOpenVINOExecutionProvider}, nullptr, &execution_providers);
|
||||
}
|
||||
|
||||
TEST(MathOpTest, LessOrEqual_multidiretional_bfloat16_broadcastBA) {
|
||||
TEST(MathOpTest, LessOrEqual_multidirectional_bfloat16_broadcastBA) {
|
||||
#ifdef USE_DNNL
|
||||
#ifdef DNNL_GPU_RUNTIME
|
||||
LOGS_DEFAULT(WARNING) << "Hardware does NOT support BF16";
|
||||
|
|
@ -2317,7 +2317,7 @@ TEST(MathOpTest, Greater_broadcastBA) {
|
|||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Greater_multidiretional_broadcastAB) {
|
||||
TEST(MathOpTest, Greater_multidirectional_broadcastAB) {
|
||||
OpTester test("Greater", 9);
|
||||
test.AddInput<int32_t>("A", {4, 1}, {10, 11, 12, 13});
|
||||
test.AddInput<int32_t>("B", {2}, {15, 7});
|
||||
|
|
@ -2325,7 +2325,7 @@ TEST(MathOpTest, Greater_multidiretional_broadcastAB) {
|
|||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Greater_multidiretional_broadcastBA) {
|
||||
TEST(MathOpTest, Greater_multidirectional_broadcastBA) {
|
||||
OpTester test("Greater", 9);
|
||||
test.AddInput<int32_t>("A", {2}, {15, 7});
|
||||
test.AddInput<int32_t>("B", {4, 1}, {10, 11, 12, 13});
|
||||
|
|
@ -2418,7 +2418,7 @@ TEST(MathOpTest, GreaterOrEqual_broadcastBA) {
|
|||
{kTensorrtExecutionProvider, kNnapiExecutionProvider, kOpenVINOExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(MathOpTest, GreaterOrEqual_multidiretional_broadcastAB) {
|
||||
TEST(MathOpTest, GreaterOrEqual_multidirectional_broadcastAB) {
|
||||
OpTester test("GreaterOrEqual", 12);
|
||||
test.AddInput<int32_t>("A", {4, 1}, {10, 11, 12, 13});
|
||||
test.AddInput<int32_t>("B", {2}, {15, 7});
|
||||
|
|
@ -2427,7 +2427,7 @@ TEST(MathOpTest, GreaterOrEqual_multidiretional_broadcastAB) {
|
|||
{kTensorrtExecutionProvider, kNnapiExecutionProvider, kOpenVINOExecutionProvider});
|
||||
}
|
||||
|
||||
TEST(MathOpTest, GreaterOrEqual_multidiretional_broadcastBA) {
|
||||
TEST(MathOpTest, GreaterOrEqual_multidirectional_broadcastBA) {
|
||||
OpTester test("GreaterOrEqual", 12);
|
||||
test.AddInput<int32_t>("A", {2}, {15, 7});
|
||||
test.AddInput<int32_t>("B", {4, 1}, {10, 11, 12, 13});
|
||||
|
|
@ -2539,7 +2539,7 @@ TEST(MathOpTest, Equal_broadcastBA) {
|
|||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Equal_multidiretional_broadcastAB) {
|
||||
TEST(MathOpTest, Equal_multidirectional_broadcastAB) {
|
||||
OpTester test("Equal");
|
||||
test.AddInput<int32_t>("A", {4, 1}, {1, 0, -1, -1});
|
||||
test.AddInput<int32_t>("B", {2}, {1, 1});
|
||||
|
|
@ -2547,7 +2547,7 @@ TEST(MathOpTest, Equal_multidiretional_broadcastAB) {
|
|||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Equal_multidiretional_broadcastBA) {
|
||||
TEST(MathOpTest, Equal_multidirectional_broadcastBA) {
|
||||
OpTester test("Equal");
|
||||
test.AddInput<int32_t>("A", {2}, {1, 1});
|
||||
test.AddInput<int32_t>("B", {4, 1}, {1, 0, -1, -1});
|
||||
|
|
@ -2555,7 +2555,7 @@ TEST(MathOpTest, Equal_multidiretional_broadcastBA) {
|
|||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, Equal_multidiretional_broadcastAB_bool) {
|
||||
TEST(MathOpTest, Equal_multidirectional_broadcastAB_bool) {
|
||||
OpTester test("Equal");
|
||||
test.AddInput<bool>("A", {4, 1}, {true, false, false, false});
|
||||
test.AddInput<bool>("B", {2}, {true, true});
|
||||
|
|
@ -3076,5 +3076,267 @@ TEST(BitShiftOpTest, BroadcastXRight_Uint8) {
|
|||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseAnd) {
|
||||
OpTester test("BitwiseAnd", 18);
|
||||
std::vector<int64_t> dims{3};
|
||||
test.AddInput<int32_t>("A", dims, {-1, -2, 3});
|
||||
test.AddInput<int32_t>("B", dims, {1, 0, 3});
|
||||
test.AddOutput<int32_t>("C", dims, {1, 0, 3});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseAnd_int64) {
|
||||
OpTester test("BitwiseAnd", 18);
|
||||
std::vector<int64_t> dims{3};
|
||||
test.AddInput<int64_t>("A", dims, {-1, -2, 3});
|
||||
test.AddInput<int64_t>("B", dims, {1, 0, 3});
|
||||
test.AddOutput<int64_t>("C", dims, {1, 0, 3});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseAnd_int8) {
|
||||
OpTester test("BitwiseAnd", 18);
|
||||
std::vector<int64_t> dims{3};
|
||||
test.AddInput<int8_t>("A", dims, {-1, -2, 3});
|
||||
test.AddInput<int8_t>("B", dims, {1, 0, 3});
|
||||
test.AddOutput<int8_t>("C", dims, {1, 0, 3});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseAnd_uint8) {
|
||||
OpTester test("BitwiseAnd", 18);
|
||||
std::vector<int64_t> dims{4};
|
||||
test.AddInput<uint8_t>("A", dims, {1, 4, 5, 3});
|
||||
test.AddInput<uint8_t>("B", dims, {1, 2, 2, 1});
|
||||
test.AddOutput<uint8_t>("C", dims, {1, 0, 0, 1});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseAnd_uint64) {
|
||||
OpTester test("BitwiseAnd", 18);
|
||||
std::vector<int64_t> dims{4};
|
||||
test.AddInput<uint64_t>("A", dims, {10, 11, 12, 13});
|
||||
test.AddInput<uint64_t>("B", dims, {15, 7, 12, 9});
|
||||
test.AddOutput<uint64_t>("C", dims, {10, 3, 12, 9});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseAnd_broadcastAB) {
|
||||
OpTester test("BitwiseAnd", 18);
|
||||
test.AddInput<int32_t>("A", {4, 2}, {10, 11, 12, 13, 14, 15, 16, 17});
|
||||
test.AddInput<int32_t>("B", {2}, {15, 7});
|
||||
test.AddOutput<int32_t>("C", {4, 2}, {10, 3, 12, 5, 14, 7, 0, 1});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseAnd_broadcastBA) {
|
||||
OpTester test("BitwiseAnd", 18);
|
||||
test.AddInput<int32_t>("A", {2}, {15, 7});
|
||||
test.AddInput<int32_t>("B", {4, 2}, {10, 11, 12, 13, 14, 15, 16, 17});
|
||||
test.AddOutput<int32_t>("C", {4, 2}, {10, 3, 12, 5, 14, 7, 0, 1});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseAnd_multidirectional_broadcastAB) {
|
||||
OpTester test("BitwiseAnd", 18);
|
||||
test.AddInput<int32_t>("A", {4, 1}, {10, 11, 12, 13});
|
||||
test.AddInput<int32_t>("B", {2}, {15, 7});
|
||||
test.AddOutput<int32_t>("C", {4, 2}, {10, 2, 11, 3, 12, 4, 13, 5});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseAnd_multidirectional_broadcastBA) {
|
||||
OpTester test("BitwiseAnd", 18);
|
||||
test.AddInput<int32_t>("A", {2}, {15, 7});
|
||||
test.AddInput<int32_t>("B", {4, 1}, {10, 11, 12, 13});
|
||||
test.AddOutput<int32_t>("C", {4, 2}, {10, 2, 11, 3, 12, 4, 13, 5});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseOr) {
|
||||
OpTester test("BitwiseOr", 18);
|
||||
std::vector<int64_t> dims{3};
|
||||
test.AddInput<int32_t>("A", dims, {-1, -2, 3});
|
||||
test.AddInput<int32_t>("B", dims, {1, 0, 4});
|
||||
test.AddOutput<int32_t>("C", dims, {-1, -2, 7});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseOr_int64) {
|
||||
OpTester test("BitwiseOr", 18);
|
||||
std::vector<int64_t> dims{3};
|
||||
test.AddInput<int64_t>("A", dims, {-1, -2, 3});
|
||||
test.AddInput<int64_t>("B", dims, {1, 0, 4});
|
||||
test.AddOutput<int64_t>("C", dims, {-1, -2, 7});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseOr_int8) {
|
||||
OpTester test("BitwiseOr", 18);
|
||||
std::vector<int64_t> dims{3};
|
||||
test.AddInput<int8_t>("A", dims, {-1, -2, 3});
|
||||
test.AddInput<int8_t>("B", dims, {1, 0, 4});
|
||||
test.AddOutput<int8_t>("C", dims, {-1, -2, 7});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseOr_uint8) {
|
||||
OpTester test("BitwiseOr", 18);
|
||||
std::vector<int64_t> dims{4};
|
||||
test.AddInput<uint8_t>("A", dims, {1, 4, 5, 3});
|
||||
test.AddInput<uint8_t>("B", dims, {1, 2, 2, 1});
|
||||
test.AddOutput<uint8_t>("C", dims, {1, 6, 7, 3});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseOr_uint64) {
|
||||
OpTester test("BitwiseOr", 18);
|
||||
std::vector<int64_t> dims{4};
|
||||
test.AddInput<uint64_t>("A", dims, {10, 11, 12, 13});
|
||||
test.AddInput<uint64_t>("B", dims, {15, 7, 12, 9});
|
||||
test.AddOutput<uint64_t>("C", dims, {15, 15, 12, 13});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseOr_broadcastAB) {
|
||||
OpTester test("BitwiseOr", 18);
|
||||
test.AddInput<int32_t>("A", {4, 2}, {10, 11, 12, 13, 14, 15, 16, 17});
|
||||
test.AddInput<int32_t>("B", {2}, {15, 7});
|
||||
test.AddOutput<int32_t>("C", {4, 2}, {15, 15, 15, 15, 15, 15, 31, 23});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseOr_broadcastBA) {
|
||||
OpTester test("BitwiseOr", 18);
|
||||
test.AddInput<int32_t>("A", {2}, {15, 7});
|
||||
test.AddInput<int32_t>("B", {4, 2}, {10, 11, 12, 13, 14, 15, 16, 17});
|
||||
test.AddOutput<int32_t>("C", {4, 2}, {15, 15, 15, 15, 15, 15, 31, 23});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseOr_multidirectional_broadcastAB) {
|
||||
OpTester test("BitwiseOr", 18);
|
||||
test.AddInput<int32_t>("A", {4, 1}, {10, 11, 12, 13});
|
||||
test.AddInput<int32_t>("B", {2}, {15, 7});
|
||||
test.AddOutput<int32_t>("C", {4, 2}, {15, 15, 15, 15, 15, 15, 15, 15});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseOr_multidirectional_broadcastBA) {
|
||||
OpTester test("BitwiseOr", 18);
|
||||
test.AddInput<int32_t>("A", {2}, {15, 7});
|
||||
test.AddInput<int32_t>("B", {4, 1}, {10, 11, 12, 13});
|
||||
test.AddOutput<int32_t>("C", {4, 2}, {15, 15, 15, 15, 15, 15, 15, 15});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseXor) {
|
||||
OpTester test("BitwiseXor", 18);
|
||||
std::vector<int64_t> dims{3};
|
||||
test.AddInput<int32_t>("A", dims, {-1, -2, 3});
|
||||
test.AddInput<int32_t>("B", dims, {1, 0, 4});
|
||||
test.AddOutput<int32_t>("C", dims, {-2, -2, 7});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseXor_int64) {
|
||||
OpTester test("BitwiseXor", 18);
|
||||
std::vector<int64_t> dims{3};
|
||||
test.AddInput<int64_t>("A", dims, {-1, -2, 3});
|
||||
test.AddInput<int64_t>("B", dims, {1, 0, 4});
|
||||
test.AddOutput<int64_t>("C", dims, {-2, -2, 7});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseXor_int8) {
|
||||
OpTester test("BitwiseXor", 18);
|
||||
std::vector<int64_t> dims{3};
|
||||
test.AddInput<int8_t>("A", dims, {-1, -2, 3});
|
||||
test.AddInput<int8_t>("B", dims, {1, 0, 4});
|
||||
test.AddOutput<int8_t>("C", dims, {-2, -2, 7});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseXor_uint8) {
|
||||
OpTester test("BitwiseXor", 18);
|
||||
std::vector<int64_t> dims{4};
|
||||
test.AddInput<uint8_t>("A", dims, {1, 4, 5, 3});
|
||||
test.AddInput<uint8_t>("B", dims, {1, 2, 2, 1});
|
||||
test.AddOutput<uint8_t>("C", dims, {0, 6, 7, 2});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseXor_uint64) {
|
||||
OpTester test("BitwiseXor", 18);
|
||||
std::vector<int64_t> dims{4};
|
||||
test.AddInput<uint64_t>("A", dims, {10, 11, 12, 13});
|
||||
test.AddInput<uint64_t>("B", dims, {15, 7, 12, 9});
|
||||
test.AddOutput<uint64_t>("C", dims, {5, 12, 0, 4});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseXor_broadcastAB) {
|
||||
OpTester test("BitwiseXor", 18);
|
||||
test.AddInput<int32_t>("A", {4, 2}, {10, 11, 12, 13, 14, 15, 16, 17});
|
||||
test.AddInput<int32_t>("B", {2}, {15, 7});
|
||||
test.AddOutput<int32_t>("C", {4, 2}, {5, 12, 3, 10, 1, 8, 31, 22});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseXor_broadcastBA) {
|
||||
OpTester test("BitwiseXor", 18);
|
||||
test.AddInput<int32_t>("A", {2}, {15, 7});
|
||||
test.AddInput<int32_t>("B", {4, 2}, {10, 11, 12, 13, 14, 15, 16, 17});
|
||||
test.AddOutput<int32_t>("C", {4, 2}, {5, 12, 3, 10, 1, 8, 31, 22});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseXor_multidirectional_broadcastAB) {
|
||||
OpTester test("BitwiseXor", 18);
|
||||
test.AddInput<int32_t>("A", {4, 1}, {10, 11, 12, 13});
|
||||
test.AddInput<int32_t>("B", {2}, {15, 7});
|
||||
test.AddOutput<int32_t>("C", {4, 2}, {5, 13, 4, 12, 3, 11, 2, 10});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseXor_multidirectional_broadcastBA) {
|
||||
OpTester test("BitwiseXor", 18);
|
||||
test.AddInput<int32_t>("A", {2}, {15, 7});
|
||||
test.AddInput<int32_t>("B", {4, 1}, {10, 11, 12, 13});
|
||||
test.AddOutput<int32_t>("C", {4, 2}, {5, 13, 4, 12, 3, 11, 2, 10});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseNot) {
|
||||
OpTester test("BitwiseNot", 18);
|
||||
std::vector<int64_t> dims{3};
|
||||
test.AddInput<int32_t>("X", dims, {-1, -2, 3});
|
||||
test.AddOutput<int32_t>("Y", dims, {0, 1, -4});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseNot_int64) {
|
||||
OpTester test("BitwiseNot", 18);
|
||||
std::vector<int64_t> dims{3};
|
||||
test.AddInput<int64_t>("X", dims, {-1, -2, 3});
|
||||
test.AddOutput<int64_t>("Y", dims, {0, 1, -4});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseNot_int8) {
|
||||
OpTester test("BitwiseNot", 18);
|
||||
std::vector<int64_t> dims{3};
|
||||
test.AddInput<int8_t>("X", dims, {-1, -2, 3});
|
||||
test.AddOutput<int8_t>("Y", dims, {0, 1, -4});
|
||||
test.Run();
|
||||
}
|
||||
|
||||
TEST(MathOpTest, BitwiseNot_uint8) {
|
||||
OpTester test("BitwiseNot", 18);
|
||||
std::vector<int64_t> dims{4};
|
||||
test.AddInput<uint8_t>("X", dims, {1, 4, 5, 3});
|
||||
test.AddOutput<uint8_t>("Y", dims, {254, 251, 250, 252});
|
||||
test.Run();
|
||||
}
|
||||
} // namespace test
|
||||
} // namespace onnxruntime
|
||||
|
|
|
|||
|
|
@ -29,8 +29,8 @@ TEST(RoiAlignTest, AvgModePositive) {
|
|||
test.AddInput<float>("rois", {5, 4}, {7., 5., 7., 5., -15., -15., -15., -15., -10., 21., -10., 21., 13., 8., 13., 8., -14., 19., -14., 19.});
|
||||
test.AddInput<int64_t>("batch_indices", {5}, {0, 0, 0, 0, 0});
|
||||
test.AddOutput<float>("Y", {5, 3, 3, 4}, {2.95833f, 3.20833f, 3.45833f, 3.70833f, 4.625f, 4.875f, 5.125f, 5.375f, 6.29167f, 6.54167f, 6.79167f, 7.04167f, 27.9583f, 28.2083f, 28.4583f, 28.7083f, 29.625f, 29.875f, 30.125f, 30.375f, 31.2917f, 31.5417f, 31.7917f, 32.0417f, 52.9583f, 53.2083f, 53.4583f, 53.7083f, 54.625f, 54.875f, 55.125f, 55.375f, 56.2917f, 56.5417f, 56.7917f, 57.0417f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 25.f, 25.f, 25.f, 25.f, 25.f, 25.f, 25.f, 25.f, 25.f, 25.f, 25.f, 25.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 7.39583f, 7.39583f, 7.42708f, 7.64583f, 9.0625f, 9.0625f, 9.09375f, 9.3125f, 10.7292f, 10.7292f, 10.7604f, 10.9792f, 32.3958f, 32.3958f, 32.4271f, 32.6458f, 34.0625f, 34.0625f, 34.0938f, 34.3125f, 35.7292f, 35.7292f, 35.7604f, 35.9792f, 57.3958f, 57.3958f, 57.4271f, 57.6458f, 59.0625f, 59.0625f, 59.0938f, 59.3125f, 60.7292f, 60.7292f, 60.7604f, 60.9792f, 4.27083f, 4.52083f, 4.77083f, 5.02083f, 5.9375f, 6.1875f, 6.4375f, 6.6875f, 7.60417f, 7.85417f, 8.10417f, 8.35417f, 29.2708f, 29.5208f, 29.7708f, 30.0208f, 30.9375f, 31.1875f, 31.4375f, 31.6875f, 32.6042f, 32.8542f, 33.1042f, 33.3542f, 54.2708f, 54.5208f, 54.7708f, 55.0208f, 55.9375f, 56.1875f, 56.4375f, 56.6875f, 57.6042f, 57.8542f, 58.1042f, 58.3542f, 6.77083f, 6.77083f, 6.77083f, 6.80208f, 8.4375f, 8.4375f, 8.4375f, 8.46875f, 10.1042f, 10.1042f, 10.1042f, 10.1354f, 31.7708f, 31.7708f, 31.7708f, 31.8021f, 33.4375f, 33.4375f, 33.4375f, 33.4688f, 35.1042f, 35.1042f, 35.1042f, 35.1354f, 56.7708f, 56.7708f, 56.7708f, 56.8021f, 58.4375f, 58.4375f, 58.4375f, 58.4688f, 60.1042f, 60.1042f, 60.1042f, 60.1354f});
|
||||
// As per ORT issue https://github.com/microsoft/onnxruntime/issues/6921, the above output values are INCORRECT.
|
||||
// DML has the correct outputs, which are defined below.
|
||||
// These will replace the above outputs once https://github.com/microsoft/onnxruntime/issues/6921 is fixed.
|
||||
/*test.AddOutput<float>("Y", {5, 3, 3, 4}, {
|
||||
2.0000,
|
||||
2.0000,
|
||||
|
|
@ -499,8 +499,8 @@ TEST(RoiAlignTest, MaxModePositive) {
|
|||
test.AddInput<float>("rois", {5, 4}, {7., 5., 7., 5., -15., -15., -15., -15., -10., 21., -10., 21., 13., 8., 13., 8., -14., 19., -14., 19.});
|
||||
test.AddInput<int64_t>("batch_indices", {5}, {0, 0, 0, 0, 0});
|
||||
test.AddOutput<float>("Y", {5, 3, 3, 4}, {2.10938f, 2.95313f, 3.375f, 2.53125f, 3.35938f, 4.70313f, 5.375f, 4.03125f, 3.51563f, 4.92188f, 5.625f, 4.21875f, 10.8984f, 15.2578f, 17.4375f, 13.0781f, 17.3568f, 24.2995f, 27.7708f, 20.8281f, 18.1641f, 25.4297f, 29.0625f, 21.7969f, 19.6875f, 27.5625f, 31.5f, 23.625f, 31.3542f, 43.8958f, 50.1667f, 37.625f, 32.8125f, 45.9375f, 52.5f, 39.375f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 25.f, 25.f, 25.f, 25.f, 25.f, 25.f, 25.f, 25.f, 25.f, 25.f, 25.f, 25.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 50.f, 5.625f, 5.625f, 5.625f, 4.57031f, 8.95833f, 8.95833f, 8.95833f, 7.27865f, 9.375f, 9.375f, 9.375f, 7.61719f, 19.6875f, 19.6875f, 19.6875f, 15.9961f, 31.3542f, 31.3542f, 31.3542f, 25.4753f, 32.8125f, 32.8125f, 32.8125f, 26.6602f, 33.75f, 33.75f, 33.75f, 27.4219f, 53.75f, 53.75f, 53.75f, 43.6719f, 56.25f, 56.25f, 56.25f, 45.7031f, 4.5f, 3.9375f, 2.8125f, 3.9375f, 5.5f, 4.8125f, 3.4375f, 4.8125f, 4.58333f, 4.01042f, 2.86458f, 3.9375f, 23.25f, 20.3438f, 14.5313f, 18.f, 28.4167f, 24.86458f, 17.76042f, 22.f, 23.25f, 20.3437f, 14.5312f, 18.f, 42.f, 36.75f, 26.25f, 32.0625f, 51.3333f, 44.9167f, 32.08333f, 39.1875f, 42.f, 36.75f, 26.25f, 32.0625f, 4.375f, 4.375f, 4.375f, 4.375f, 7.70833f, 7.70833f, 7.70833f, 7.70833f, 9.375f, 9.375f, 9.375f, 9.375f, 21.875f, 21.875f, 21.875f, 21.875f, 26.9792f, 26.9792f, 26.9792f, 26.9792f, 32.8125f, 32.8125f, 32.8125f, 32.8125f, 40.1042f, 40.1042f, 40.1042f, 40.1042f, 46.25f, 46.25f, 46.25f, 46.25f, 56.25f, 56.25f, 56.25f, 56.25f});
|
||||
// As per ort issue #3428, the above output values are INCORRECT.
|
||||
// DML has the correct outputs, which are defined below.
|
||||
// These will replace the above outputs once https://github.com/microsoft/onnxruntime/issues/6921 is fixed.
|
||||
/*test.AddOutput<float>("Y",{5, 3, 3, 4}, {
|
||||
2.0000,
|
||||
2.0000,
|
||||
|
|
|
|||
Loading…
Reference in a new issue