#include "gtest/gtest.h" #include "test/providers/provider_test_utils.h" namespace onnxruntime { namespace test { #ifdef USE_DNNL // The same as the default provider, but in this case with constant initializers to test optimization TEST(DequantizeLinearOpTest, DNNL_Uint8_ConstantInitializer) { OpTester test("DequantizeLinear", 10); std::vector dims{4}; test.AddInput("x", dims, {0, 3, 128, 255}); test.AddInput("x_scale", {}, {2.0f}); test.AddInput("x_zero_point", {}, {128}, true); test.AddOutput("y", dims, {-256.0f, -250.0f, 0.0f, 254.0f}); test.Run(); } // scalar zero & scale with int8 TEST(DequantizeLinearOpTest, DNNL_Int8_ConstantInitializer) { OpTester test("DequantizeLinear", 10); std::vector dims{4}; test.AddInput("x", dims, {-30, -3, 100, 127}); test.AddInput("x_scale", {}, {2.0f}); test.AddInput("x_zero_point", {}, {-10}, true); test.AddOutput("y", dims, {-40.0f, 14.0f, 220.0f, 274.0f}); // Disable Tensorrt EP due to error:node1_quantize_scale_node: out of bounds channel axis 1. Number of input dimensions is 1. test.Run(); } // scalar zero & scale with int8 TEST(DequantizeLinearOpTest, DNNL_Int32_ConstantInitializer) { OpTester test("DequantizeLinear", 10); std::vector dims{4}; test.AddInput("x", dims, {-30, -3, 100, 127}); test.AddInput("x_scale", {}, {2.0f}, true); test.AddOutput("y", dims, {-60.f, -6.f, 200.f, 254.f}); test.Run(); } // 2d inputs TEST(DequantizeLinearOpTest, DNNL_2D_ConstantInitializer) { OpTester test("DequantizeLinear", 10); std::vector dims{3, 4}; test.AddInput("X", dims, {0, 1, 2, 3, 0, 1, 2, 3, 0, 10, 20, 30}); test.AddInput("scale", {}, {1.0f}); test.AddInput("zero_point", {}, {0}, true); test.AddOutput("Y", dims, {0, 1, 2, 3, 0, 1, 2, 3, 0, 10, 20, 30}); test.Run(); } #endif // USE_DNNL } // namespace test } // namespace onnxruntime