@@ -449,10 +449,43 @@ TEST(QuantizeLinearOpTest, Uint16) {
449449 65535 , 0 ,
450450 65535 , 0 });
451451
452+ std::unordered_set<std::string> excluded_providers;
452453 // Disable Tensorrt EP due to error: unsupported data type
453- test.Run (OpTester::ExpectResult::kExpectSuccess , " " , {kTensorrtExecutionProvider });
454+ excluded_providers.insert (kTensorrtExecutionProvider );
455+ // Disable OV EP due to different formulation for QuantizeLinear
456+ excluded_providers.insert (kOpenVINOExecutionProvider );
457+ test.ConfigExcludeEps (excluded_providers)
458+ .RunWithConfig ();
454459}
455460
461+ #ifdef USE_OPENVINO
462+ TEST (QuantizeLinearOpTest, OVEP_Uint16) {
463+ OpTester test (" QuantizeLinear" , 21 );
464+ std::vector<int64_t > dims{12 };
465+ test.AddInput <float >(" x" , dims, {
466+ 0 .f , -128 .f , 3 .f , -3 .f , // rounding half to even
467+ 2 .9f , -2 .9f , // round < .5
468+ 3 .1f , -3 .1f , // round > .5
469+ 65536 .f , -65534 .f , // critical point
470+ 70000 .f , -70000 .f // saturate case
471+ });
472+ test.AddInput <float >(" scale" , {}, {2 .0f }, true );
473+ test.AddInput <uint16_t >(" zero_point" , {}, {32767 }, true );
474+ test.AddOutput <uint16_t >(" y" , dims,
475+ {32767 , 32703 ,
476+ 32768 , 32766 ,
477+ 32768 , 32766 ,
478+ 32769 , 32765 ,
479+ 65535 , 0 ,
480+ 65535 , 0 });
481+
482+ std::vector<std::unique_ptr<IExecutionProvider>> execution_providers;
483+ execution_providers.emplace_back (DefaultOpenVINOExecutionProvider ());
484+ test.ConfigEps (std::move (execution_providers))
485+ .RunWithConfig ();
486+ }
487+ #endif // USE_OPENVINO
488+
456489// Test int16 QuantizeLinear (per tensor)
457490TEST (QuantizeLinearOpTest, Int16) {
458491 OpTester test (" QuantizeLinear" , 21 );
@@ -502,8 +535,40 @@ TEST(QuantizeLinearOpTest, Int4) {
502535 {Int4x2 (-8 , -7 ), Int4x2 (-1 , 1 ), Int4x2 (2 , 7 ),
503536 Int4x2 (7 , unused_val)});
504537
505- test.Run (OpTester::ExpectResult::kExpectSuccess , " " , {kTensorrtExecutionProvider });
538+ std::unordered_set<std::string> excluded_providers;
539+ excluded_providers.insert (kTensorrtExecutionProvider );
540+ // Disable OV EP due to different formulation for QuantizeLinear
541+ excluded_providers.insert (kOpenVINOExecutionProvider );
542+ test.ConfigExcludeEps (excluded_providers)
543+ .RunWithConfig ();
544+ }
545+
546+ #ifdef USE_OPENVINO
547+ TEST (QuantizeLinearOpTest, OVEP_Int4) {
548+ OpTester test (" QuantizeLinear" , 21 );
549+ std::vector<int64_t > dims{7 };
550+ constexpr int8_t unused_val = 0 ;
551+ test.AddInput <float >(" x" , dims, {
552+ -20 .0f , // Clamp to qmin
553+ -16 .0f , // Close to qmin
554+ -3 .0f , // round
555+ 0 .0f , // Zero-point
556+ 2 .9f , // round
557+ 12 .0f , // qmax
558+ 20 .0f , // Clamp to qmax
559+ });
560+ test.AddInput <float >(" scale" , {}, {2 .0f }, true );
561+ test.AddInput <Int4x2>(" zero_point" , {}, {Int4x2 (1 , unused_val)}, true );
562+ test.AddOutput <Int4x2>(" y" , dims,
563+ {Int4x2 (-8 , -7 ), Int4x2 (0 , 1 ), Int4x2 (2 , 7 ),
564+ Int4x2 (7 , unused_val)});
565+
566+ std::vector<std::unique_ptr<IExecutionProvider>> execution_providers;
567+ execution_providers.emplace_back (DefaultOpenVINOExecutionProvider ());
568+ test.ConfigEps (std::move (execution_providers))
569+ .RunWithConfig ();
506570}
571+ #endif // USE_OPENVINO
507572
508573// Test uint4 QuantizeLinear (per tensor)
509574TEST (QuantizeLinearOpTest, UInt4) {
@@ -569,7 +634,12 @@ TEST(QuantizeLinearOpTest, OddLarge_Int4) {
569634 test.AddInput <Int4x2>(" zero_point" , {}, {Int4x2 (zp, unused_val)}, true );
570635 test.AddOutput <Int4x2>(" y" , dims, output);
571636
572- test.Run (OpTester::ExpectResult::kExpectSuccess , " " , {kTensorrtExecutionProvider });
637+ std::unordered_set<std::string> excluded_providers;
638+ excluded_providers.insert (kTensorrtExecutionProvider );
639+ // Disable OV EP due to different formulation for QuantizeLinear
640+ excluded_providers.insert (kOpenVINOExecutionProvider );
641+ test.ConfigExcludeEps (excluded_providers)
642+ .RunWithConfig ();
573643}
574644
575645// Test uint4 QuantizeLinear (per tensor) with a "large" and odd number of input elements.
@@ -595,7 +665,12 @@ TEST(QuantizeLinearOpTest, OddLarge_UInt4) {
595665 test.AddInput <UInt4x2>(" zero_point" , {}, {UInt4x2 (zp, unused_val)}, true );
596666 test.AddOutput <UInt4x2>(" y" , dims, output);
597667
598- test.Run (OpTester::ExpectResult::kExpectSuccess , " " , {kTensorrtExecutionProvider });
668+ std::unordered_set<std::string> excluded_providers;
669+ excluded_providers.insert (kTensorrtExecutionProvider );
670+ // Disable OV EP due to different formulation for QuantizeLinear
671+ excluded_providers.insert (kOpenVINOExecutionProvider );
672+ test.ConfigExcludeEps (excluded_providers)
673+ .RunWithConfig ();
599674}
600675
601676// quantize with scalar zero point and scale
@@ -611,10 +686,31 @@ TEST(QuantizeLinearOpTest, Int8_NegativeZeroPoint) {
611686 test.AddInput <float >(" y_scale" , {}, {.039215686f });
612687 test.AddInput <int8_t >(" y_zero_point" , {}, {-23 });
613688 test.AddOutput <int8_t >(" y" , dims, {-23 , 28 , 53 , 104 , 127 , -74 , -128 , -128 });
689+ std::unordered_set<std::string> excluded_providers;
614690 // Disable Tensorrt EP due to the error, node1_quantize_scale_node: out of bounds channel axis 1. Number of input dimensions is 1.
615- test.Run (OpTester::ExpectResult::kExpectSuccess , " " , {kTensorrtExecutionProvider });
691+ excluded_providers.insert (kTensorrtExecutionProvider );
692+ // Disable OV EP due to different formulation for QuantizeLinear
693+ excluded_providers.insert (kOpenVINOExecutionProvider );
694+ test.ConfigExcludeEps (excluded_providers)
695+ .RunWithConfig ();
616696}
617697
698+ #ifdef USE_OPENVINO
699+ TEST (QuantizeLinearOpTest, OVEP_Int8_NegativeZeroPoint) {
700+
701+ OpTester test (" QuantizeLinear" , 10 );
702+ std::vector<int64_t > dims{8 };
703+ test.AddInput <float >(" x" , dims, {0 , 2 , 3 , 5 , 6 , -2 , -5 , -6 });
704+ test.AddInput <float >(" y_scale" , {}, {.039215686f });
705+ test.AddInput <int8_t >(" y_zero_point" , {}, {-23 });
706+ test.AddOutput <int8_t >(" y" , dims, {-23 , 28 , 54 , 105 , 127 , -74 , -128 , -128 });
707+ std::vector<std::unique_ptr<IExecutionProvider>> execution_providers;
708+ execution_providers.emplace_back (DefaultOpenVINOExecutionProvider ());
709+ test.ConfigEps (std::move (execution_providers))
710+ .RunWithConfig ();
711+ }
712+ #endif // USE_OPENVINO
713+
618714// quantize with scalar zero point and scale
619715TEST (QuantizeLinearOpTest, Int8_PositiveZeroPoint) {
620716 // TODO: Unskip when fixed #41968513
@@ -628,9 +724,34 @@ TEST(QuantizeLinearOpTest, Int8_PositiveZeroPoint) {
628724 test.AddInput <float >(" y_scale" , {}, {.039215686f });
629725 test.AddInput <int8_t >(" y_zero_point" , {}, {23 });
630726 test.AddOutput <int8_t >(" y" , dims, {23 , 74 , 99 , 127 , 127 , -28 , -104 , -128 });
727+ std::unordered_set<std::string> excluded_providers;
631728 // Disable Tensorrt EP due to error:node1_quantize_scale_node: out of bounds channel axis 1. Number of input dimensions is 1.
632- test.Run (OpTester::ExpectResult::kExpectSuccess , " " , {kTensorrtExecutionProvider });
729+ excluded_providers.insert (kTensorrtExecutionProvider );
730+ // Disable OV EP due to different formulation for QuantizeLinear
731+ excluded_providers.insert (kOpenVINOExecutionProvider );
732+ test.ConfigExcludeEps (excluded_providers)
733+ .RunWithConfig ();
734+ }
735+
736+ #ifdef USE_OPENVINO
737+ TEST (QuantizeLinearOpTest, OVEP_Int8_PositiveZeroPoint) {
738+ // TODO: Unskip when fixed #41968513
739+ if (DefaultDmlExecutionProvider ().get () != nullptr ) {
740+ GTEST_SKIP () << " Skipping because of the following error: Expected equality of these values: -104 and -105" ;
741+ }
742+
743+ OpTester test (" QuantizeLinear" , 10 );
744+ std::vector<int64_t > dims{8 };
745+ test.AddInput <float >(" x" , dims, {0 , 2 , 3 , 5 , 6 , -2 , -5 , -6 });
746+ test.AddInput <float >(" y_scale" , {}, {.039215686f });
747+ test.AddInput <int8_t >(" y_zero_point" , {}, {23 });
748+ test.AddOutput <int8_t >(" y" , dims, {23 , 74 , 100 , 127 , 127 , -28 , -104 , -128 });
749+ std::vector<std::unique_ptr<IExecutionProvider>> execution_providers;
750+ execution_providers.emplace_back (DefaultOpenVINOExecutionProvider ());
751+ test.ConfigEps (std::move (execution_providers))
752+ .RunWithConfig ();
633753}
754+ #endif // USE_OPENVINO
634755
635756// quantize with 2D data
636757TEST (QuantizeLinearOpTest, 2D) {
0 commit comments