diff --git a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlOperatorRecurrentNeuralNetwork.cpp b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlOperatorRecurrentNeuralNetwork.cpp index 88b827f61f..ad7c77510d 100644 --- a/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlOperatorRecurrentNeuralNetwork.cpp +++ b/onnxruntime/core/providers/dml/DmlExecutionProvider/src/Operators/DmlOperatorRecurrentNeuralNetwork.cpp @@ -127,51 +127,51 @@ public: DML_OPERATOR_DESC& desc = descs[i]; ActivationOperatorDescUnion& activationDesc = m_activationDescs[i]; desc.Desc = &activationDesc; - - if (activationName == AttrValue::ActivationRelu) + + if (CompareActivationName(activationName, AttrValue::ActivationRelu)) { desc.Type = DML_OPERATOR_ACTIVATION_RELU; - } - else if (activationName == AttrValue::ActivationLeakyRelu) + } + else if (CompareActivationName(activationName, AttrValue::ActivationLeakyRelu)) { desc.Type = DML_OPERATOR_ACTIVATION_LEAKY_RELU; activationDesc.leakyRelu.Alpha = NextAlpha(desc.Type); } - else if (activationName == AttrValue::ActivationThresholdedRelu) + else if (CompareActivationName(activationName, AttrValue::ActivationThresholdedRelu)) { desc.Type = DML_OPERATOR_ACTIVATION_THRESHOLDED_RELU; activationDesc.thresholdedRelu.Alpha = NextAlpha(desc.Type); - } - else if (activationName == AttrValue::ActivationTanh) + } + else if (CompareActivationName(activationName, AttrValue::ActivationTanh)) { desc.Type = DML_OPERATOR_ACTIVATION_TANH; - } - else if (activationName == AttrValue::ActivationScaledTanh) + } + else if (CompareActivationName(activationName, AttrValue::ActivationScaledTanh)) { desc.Type = DML_OPERATOR_ACTIVATION_SCALED_TANH; activationDesc.scaledTanh.Alpha = NextAlpha(desc.Type); activationDesc.scaledTanh.Beta = NextBeta(desc.Type); - } - else if (activationName == AttrValue::ActivationSigmoid) + } + else if (CompareActivationName(activationName, AttrValue::ActivationSigmoid)) { desc.Type = DML_OPERATOR_ACTIVATION_SIGMOID; - } - else if (activationName == AttrValue::ActivationSigmoidHard) + } + else if (CompareActivationName(activationName, AttrValue::ActivationSigmoidHard)) { desc.Type = DML_OPERATOR_ACTIVATION_HARD_SIGMOID; activationDesc.hardSigmoid.Alpha = NextAlpha(desc.Type); activationDesc.hardSigmoid.Beta = NextBeta(desc.Type); - } - else if (activationName == AttrValue::ActivationElu) + } + else if (CompareActivationName(activationName, AttrValue::ActivationElu)) { desc.Type = DML_OPERATOR_ACTIVATION_ELU; activationDesc.elu.Alpha = NextAlpha(desc.Type); - } - else if (activationName == AttrValue::ActivationSoftsign) + } + else if (CompareActivationName(activationName, AttrValue::ActivationSoftsign)) { desc.Type = DML_OPERATOR_ACTIVATION_SOFTSIGN; - } - else if (activationName == AttrValue::ActivationSoftplus) + } + else if (CompareActivationName(activationName, AttrValue::ActivationSoftplus)) { desc.Type = DML_OPERATOR_ACTIVATION_SOFTPLUS; } @@ -182,6 +182,12 @@ public: } } + bool CompareActivationName(std::string_view activationName, std::string_view attrValue) + { + auto comparer = [](char a, char b) {return std::tolower(a) == std::tolower(b);}; + return std::equal(activationName.begin(), activationName.end(), attrValue.begin(), attrValue.end(), comparer); + } + void Compute(const MLOperatorKernelContext& kernelContext) override { // Assume that enough GPU work has been queued up after the RNN operator that it is worth diff --git a/onnxruntime/test/providers/cpu/rnn/deep_cpu_gru_op_test.cc b/onnxruntime/test/providers/cpu/rnn/deep_cpu_gru_op_test.cc index 30960e71c5..de2aceda17 100644 --- a/onnxruntime/test/providers/cpu/rnn/deep_cpu_gru_op_test.cc +++ b/onnxruntime/test/providers/cpu/rnn/deep_cpu_gru_op_test.cc @@ -13,7 +13,7 @@ using namespace std; namespace onnxruntime { namespace test { -static const std::vector default_activations = {"sigmoid", "tanh"}; +static const std::vector default_activations = {"Sigmoid", "Tanh"}; static void RunGruTest(const std::vector& X_data, const std::vector& W_data, @@ -150,11 +150,6 @@ void DefaultActivationsSimpleWeightsNoBias(std::string direction, } TEST(GRUTest, ForwardDefaultActivationsSimpleWeightsNoBiasTwoRows) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - std::vector Y_data{ 0.4750208f, 0.450166f, 0.4255575f, 0.45016602f, 0.40131235f, 0.35434368f, @@ -173,11 +168,6 @@ TEST(GRUTest, ForwardDefaultActivationsSimpleWeightsNoBiasTwoRows) { } TEST(GRUTest, ReverseDefaultActivationsSimpleWeightsNoBiasTwoRows) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - std::vector Y_data{ 0.6082785f, 0.50623393f, 0.4426924f, 0.5803454f, 0.4527356f, 0.36886263f, @@ -193,11 +183,6 @@ TEST(GRUTest, ReverseDefaultActivationsSimpleWeightsNoBiasTwoRows) { } TEST(GRUTest, BidirectionalDefaultActivationsSimpleWeightsNoBias) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - std::vector Y_data{ // forward output for input sequence 0 0.4750208f, 0.450166f, 0.4255575f, @@ -228,11 +213,6 @@ TEST(GRUTest, BidirectionalDefaultActivationsSimpleWeightsNoBias) { } TEST(GRUTest, BidirectionalDefaultActivationsSimpleWeightsNoBiasLinearBeforeReset) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - std::vector Y_data{ // forward output for input sequence 0 0.4750208f, 0.450166f, 0.4255575f, @@ -317,11 +297,6 @@ void DefaultActivationsSimpleWeightsWithBias(std::string direction, } TEST(GRUTest, ForwardDefaultActivationsSimpleWeightsWithBiasBatchParallel) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - std::vector Y_data{ 0.16783132f, -0.11754231f, 0.11977843f, 0.2046872f, -0.10372487f, 0.15365849f, @@ -333,11 +308,6 @@ TEST(GRUTest, ForwardDefaultActivationsSimpleWeightsWithBiasBatchParallel) { } TEST(GRUTest, ForwardDefaultActivationsSimpleWeightsWithBiasBatchParallelLinearBeforeReset) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - std::vector Y_data{ 0.15024948f, -0.11097029f, -0.02121867f, 0.18887489f, -0.09747667f, 0.02093463f, @@ -350,11 +320,6 @@ TEST(GRUTest, ForwardDefaultActivationsSimpleWeightsWithBiasBatchParallelLinearB } TEST(GRUTest, ReverseDefaultActivationsSimpleWeightsWithBiasBatchParallelLinearBeforeReset) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - std::vector Y_data{ 0.20910699f, -0.18880953f, -0.04005555f, 0.29700265f, -0.15308119f, 0.04537245f, @@ -368,11 +333,6 @@ TEST(GRUTest, ReverseDefaultActivationsSimpleWeightsWithBiasBatchParallelLinearB // test forward !batch_parallel_ path with linear_before_reset TEST(GRUTest, ForwardDefaultActivationsSimpleWeightsWithBiasLinearBeforeReset) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - std::vector Y_data{ 0.15024948f, -0.11097029f, -0.02121867f, 0.19538902f, -0.19016478f, -0.05644283f}; @@ -384,11 +344,6 @@ TEST(GRUTest, ForwardDefaultActivationsSimpleWeightsWithBiasLinearBeforeReset) { // test reverse !batch_parallel_ path with linear_before_reset TEST(GRUTest, ReverseDefaultActivationsSimpleWeightsWithBiasLinearBeforeReset) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - std::vector Y_data{ 0.20910699f, -0.18880953f, -0.04005555f, 0.12252139f, -0.12032216f, -0.05064924f}; @@ -588,13 +543,8 @@ void DeepCpuGruOpTestContext::RunTest(const std::vector& X, } TEST(GRUTest, ONNXRuntime_TestGRUOpForwardBasic) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - const std::string direction = "forward"; - const std::vector activations = {"sigmoid", "tanh"}; + const std::vector activations = {"Sigmoid", "Tanh"}; DeepCpuGruOpTestContext ctx(direction, activations); @@ -611,13 +561,8 @@ TEST(GRUTest, ONNXRuntime_TestGRUOpForwardBasic) { } TEST(GRUTest, ONNXRuntime_TestGRUOpBackwardBasic) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - const std::string direction = "reverse"; - const std::vector activations = {"sigmoid", "tanh"}; + const std::vector activations = {"Sigmoid", "Tanh"}; DeepCpuGruOpTestContext ctx(direction, activations); @@ -635,13 +580,8 @@ TEST(GRUTest, ONNXRuntime_TestGRUOpBackwardBasic) { } TEST(GRUTest, ONNXRuntime_TestGRUOpBidirectionalBasic) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - const std::string direction = "bidirectional"; - const std::vector activations = {"sigmoid", "tanh", "sigmoid", "tanh"}; + const std::vector activations = {"Sigmoid", "Tanh", "Sigmoid", "Tanh"}; DeepCpuGruOpTestContext ctx(direction, activations); @@ -663,13 +603,8 @@ TEST(GRUTest, ONNXRuntime_TestGRUOpBidirectionalBasic) { } TEST(GRUTest, ONNXRuntime_TestGRUOpForwardActivation) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - const std::string direction = "forward"; - const std::vector activations = {"tanh", "sigmoid"}; + const std::vector activations = {"Tanh", "Sigmoid"}; DeepCpuGruOpTestContext ctx(direction, activations); @@ -687,13 +622,8 @@ TEST(GRUTest, ONNXRuntime_TestGRUOpForwardActivation) { } TEST(GRUTest, ONNXRuntime_TestGRUOpForwardInitialHiddenState) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - const std::string direction = "forward"; - const std::vector activations = {"sigmoid", "tanh"}; + const std::vector activations = {"Sigmoid", "Tanh"}; DeepCpuGruOpTestContext ctx(direction, activations); @@ -711,13 +641,8 @@ TEST(GRUTest, ONNXRuntime_TestGRUOpForwardInitialHiddenState) { } TEST(GRUTest, ONNXRuntime_TestGRUOpForwardBatch) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - const std::string direction = "forward"; - const std::vector activations = {"sigmoid", "tanh"}; + const std::vector activations = {"Sigmoid", "Tanh"}; DeepCpuGruOpTestContext ctx(direction, activations); @@ -743,13 +668,8 @@ TEST(GRUTest, ONNXRuntime_TestGRUOpForwardBatch) { } TEST(GRUTest, ONNXRuntime_TestGRUOpForwardBatchLinearBeforeReset) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - const std::string direction = "forward"; - const std::vector activations = {"sigmoid", "tanh"}; + const std::vector activations = {"Sigmoid", "Tanh"}; DeepCpuGruOpTestContext ctx(direction, activations); @@ -775,13 +695,8 @@ TEST(GRUTest, ONNXRuntime_TestGRUOpForwardBatchLinearBeforeReset) { } TEST(GRUTest, ONNXRuntime_TestGRUOpGrowBatchSequenceLength) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - const std::string direction = "forward"; - const std::vector activations = {"sigmoid", "tanh"}; + const std::vector activations = {"Sigmoid", "Tanh"}; DeepCpuGruOpTestContext ctx(direction, activations); @@ -820,13 +735,8 @@ TEST(GRUTest, ONNXRuntime_TestGRUOpGrowBatchSequenceLength) { } TEST(GRUTest, ONNXRuntime_TestGRUOpGrowBatchSequenceLengthLinearBeforeReset) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - const std::string direction = "forward"; - const std::vector activations = {"sigmoid", "tanh"}; + const std::vector activations = {"Sigmoid", "Tanh"}; DeepCpuGruOpTestContext ctx(direction, activations); @@ -865,13 +775,8 @@ TEST(GRUTest, ONNXRuntime_TestGRUOpGrowBatchSequenceLengthLinearBeforeReset) { } TEST(GRUTest, ONNXRuntime_TestGRUOpSequenceLengthWithBidirectionalLinearBeforeResetB1) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - const std::string direction = "bidirectional"; - const std::vector activations = {"sigmoid", "tanh", "sigmoid", "tanh"}; + const std::vector activations = {"Sigmoid", "Tanh", "Sigmoid", "Tanh"}; DeepCpuGruOpTestContext ctx(direction, activations); @@ -891,13 +796,8 @@ TEST(GRUTest, ONNXRuntime_TestGRUOpSequenceLengthWithBidirectionalLinearBeforeRe } TEST(GRUTest, ONNXRuntime_TestGRUOpSequenceLengthWithBidirectionalLinearBeforeResetB2) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - const std::string direction = "bidirectional"; - const std::vector activations = {"sigmoid", "tanh", "sigmoid", "tanh"}; + const std::vector activations = {"Sigmoid", "Tanh", "Sigmoid", "Tanh"}; DeepCpuGruOpTestContext ctx(direction, activations); @@ -916,13 +816,8 @@ TEST(GRUTest, ONNXRuntime_TestGRUOpSequenceLengthWithBidirectionalLinearBeforeRe } TEST(GRUTest, ONNXRuntime_TestGRUOpSequenceLengthWithBidirectionalLinearBeforeReset) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - const std::string direction = "bidirectional"; - const std::vector activations = {"sigmoid", "tanh", "sigmoid", "tanh"}; + const std::vector activations = {"Sigmoid", "Tanh", "Sigmoid", "Tanh"}; DeepCpuGruOpTestContext ctx(direction, activations); @@ -949,13 +844,8 @@ TEST(GRUTest, ONNXRuntime_TestGRUOpSequenceLengthWithBidirectionalLinearBeforeRe } TEST(GRUTest, ONNXRuntime_TestGRUOpShorterSeqInMiddle) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - const std::string direction = "bidirectional"; - const std::vector activations = {"sigmoid", "tanh", "sigmoid", "tanh"}; + const std::vector activations = {"Sigmoid", "Tanh", "Sigmoid", "Tanh"}; DeepCpuGruOpTestContext ctx(direction, activations); @@ -987,13 +877,8 @@ TEST(GRUTest, ONNXRuntime_TestGRUOpShorterSeqInMiddle) { } TEST(GRUTest, ONNXRuntime_TestGRUOpZeroSeqInMiddle) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - const std::string direction = "bidirectional"; - const std::vector activations = {"sigmoid", "tanh", "sigmoid", "tanh"}; + const std::vector activations = {"Sigmoid", "Tanh", "Sigmoid", "Tanh"}; DeepCpuGruOpTestContext ctx(direction, activations); @@ -1025,13 +910,8 @@ TEST(GRUTest, ONNXRuntime_TestGRUOpZeroSeqInMiddle) { } TEST(GRUTest, ONNXRuntime_TestGRUOpSequenceLengthWithPartialZero) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - const std::string direction = "bidirectional"; - const std::vector activations = {"sigmoid", "tanh", "sigmoid", "tanh"}; + const std::vector activations = {"Sigmoid", "Tanh", "Sigmoid", "Tanh"}; DeepCpuGruOpTestContext ctx(direction, activations); @@ -1058,13 +938,8 @@ TEST(GRUTest, ONNXRuntime_TestGRUOpSequenceLengthWithPartialZero) { } TEST(GRUTest, ONNXRuntime_TestGRUOpSequenceLengthShorterThanInputSequenceLength) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - const std::string direction = "bidirectional"; - const std::vector activations = {"sigmoid", "tanh", "sigmoid", "tanh"}; + const std::vector activations = {"Sigmoid", "Tanh", "Sigmoid", "Tanh"}; DeepCpuGruOpTestContext ctx(direction, activations); @@ -1092,13 +967,8 @@ TEST(GRUTest, ONNXRuntime_TestGRUOpSequenceLengthShorterThanInputSequenceLength) } TEST(GRUTest, ONNXRuntime_TestGRUOpSequenceLengthAllZeros) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - const std::string direction = "forward"; - const std::vector activations = {"sigmoid", "tanh"}; + const std::vector activations = {"Sigmoid", "Tanh"}; DeepCpuGruOpTestContext ctx(direction, activations); @@ -1125,13 +995,8 @@ TEST(GRUTest, ONNXRuntime_TestGRUOpSequenceLengthAllZeros) { } TEST(GRUTest, ONNXRuntime_TestGRUOpSingleBatchMultipleHiddenThreads) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - const std::string direction = "forward"; - const std::vector activations = {"sigmoid", "tanh"}; + const std::vector activations = {"Sigmoid", "Tanh"}; DeepCpuGruOpTestContext ctx(direction, activations, true, {}, {}, /*large_hidden*/ true); @@ -1160,13 +1025,8 @@ TEST(GRUTest, ONNXRuntime_TestGRUOpSingleBatchMultipleHiddenThreads) { } TEST(GRUTest, ONNXRuntime_TestGRUPositiveActivationClipping) { - // TODO: Unskip when fixed #41968513 - if (DefaultDmlExecutionProvider().get() != nullptr) { - GTEST_SKIP() << "Skipping because of the following error: MLOperatorAuthorImpl.cpp(1817): The parameter is incorrect."; - } - const std::string direction = "forward"; - const std::vector activations = {"sigmoid", "tanh"}; + const std::vector activations = {"Sigmoid", "Tanh"}; DeepCpuGruOpTestContext ctx(direction, activations, true, {}, {}, /*large_hidden*/ true);