diff --git a/onnxruntime/test/contrib_ops/rotary_embedding_op_test.cc b/onnxruntime/test/contrib_ops/rotary_embedding_op_test.cc index 0e964cf64fbbd..625c5ec35e20d 100644 --- a/onnxruntime/test/contrib_ops/rotary_embedding_op_test.cc +++ b/onnxruntime/test/contrib_ops/rotary_embedding_op_test.cc @@ -86,44 +86,48 @@ static void RunTest( return; } - OpTester test(op_type.c_str(), 1, onnxruntime::kMSDomain); - test.AddAttribute("interleaved", interleaved); - - if (rotary_embedding_dim > 0) { - test.AddAttribute("rotary_embedding_dim", rotary_embedding_dim); - test.AddAttribute("num_heads", num_heads); - } - - if (rotary_embedding_dim > 0) { - test.AddAttribute("is_packed_batching", is_packed_batching); + for (auto& ep : execution_providers) { + OpTester test(op_type.c_str(), 1, onnxruntime::kMSDomain); + test.AddAttribute("interleaved", interleaved); + + if (rotary_embedding_dim > 0) { + test.AddAttribute("rotary_embedding_dim", rotary_embedding_dim); + test.AddAttribute("num_heads", num_heads); + } + + if (rotary_embedding_dim > 0) { + test.AddAttribute("is_packed_batching", is_packed_batching); + } + + if (tensor_type == TensorType::kFloat) { + test.AddInput("input", input_dims, input_data); + test.AddInput("position_ids", pos_dims, position_ids); + test.AddInput("cos_cache", cache_dims, cos_cache); + test.AddInput("sin_cache", cache_dims, sin_cache); + test.AddOutput("output", input_dims, output_data); + } else if (tensor_type == TensorType::kFloat16) { + test.AddInput("input", input_dims, ToFloat16(input_data)); + test.AddInput("position_ids", pos_dims, position_ids); + test.AddInput("cos_cache", cache_dims, ToFloat16(cos_cache)); + test.AddInput("sin_cache", cache_dims, ToFloat16(sin_cache)); + test.AddOutput("output", input_dims, ToFloat16(output_data)); + } else { + test.AddInput("input", input_dims, FloatsToBFloat16s(input_data)); + test.AddInput("position_ids", pos_dims, position_ids); + test.AddInput("cos_cache", cache_dims, FloatsToBFloat16s(cos_cache)); + test.AddInput("sin_cache", cache_dims, FloatsToBFloat16s(sin_cache)); + test.AddOutput("output", input_dims, FloatsToBFloat16s(output_data)); + } + if (tensor_type == TensorType::kBFloat16) { + test.SetOutputAbsErr("output", 0.03f); + } else { + test.SetOutputAbsErr("output", 0.002f); + } + + std::vector> test_execution_providers; + test_execution_providers.push_back(std::move(ep)); + test.Run(OpTester::ExpectResult::kExpectSuccess, "", {}, nullptr, &test_execution_providers); } - - if (tensor_type == TensorType::kFloat) { - test.AddInput("input", input_dims, input_data); - test.AddInput("position_ids", pos_dims, position_ids); - test.AddInput("cos_cache", cache_dims, cos_cache); - test.AddInput("sin_cache", cache_dims, sin_cache); - test.AddOutput("output", input_dims, output_data); - } else if (tensor_type == TensorType::kFloat16) { - test.AddInput("input", input_dims, ToFloat16(input_data)); - test.AddInput("position_ids", pos_dims, position_ids); - test.AddInput("cos_cache", cache_dims, ToFloat16(cos_cache)); - test.AddInput("sin_cache", cache_dims, ToFloat16(sin_cache)); - test.AddOutput("output", input_dims, ToFloat16(output_data)); - } else { - test.AddInput("input", input_dims, FloatsToBFloat16s(input_data)); - test.AddInput("position_ids", pos_dims, position_ids); - test.AddInput("cos_cache", cache_dims, FloatsToBFloat16s(cos_cache)); - test.AddInput("sin_cache", cache_dims, FloatsToBFloat16s(sin_cache)); - test.AddOutput("output", input_dims, FloatsToBFloat16s(output_data)); - } - if (tensor_type == TensorType::kBFloat16) { - test.SetOutputAbsErr("output", 0.03f); - } else { - test.SetOutputAbsErr("output", 0.002f); - } - - test.Run(OpTester::ExpectResult::kExpectSuccess, "", {}, nullptr, &execution_providers); } static void RunTests(const std::vector& input_data,