@@ -797,7 +797,61 @@ TEST(ArrayOps, QuantizeAndDequantizeV2x8xtruexfalse) {
797797 output_datatypes, sess_run_fetchoutputs);
798798
799799 opexecuter.RunTest ();
800- } // end of test op QuantizeAndDequantizeV2x8xtruexfalse
800+ }
801+
802+ TEST (ArrayOps, QuantizeAndDequantizeV2RoundingMode1) {
803+ Scope root = Scope::NewRootScope ();
804+ int dim1 = 2 ;
805+ int dim2 = 3 ;
806+
807+ Tensor A (DT_FLOAT, TensorShape ({dim1, dim2}));
808+ AssignInputValues<float >(A, {0.9 , 3.4 , 2.6 , 5.4 , 4.2 , 4.5 });
809+
810+ auto attrs = ops::QuantizeAndDequantizeV2::Attrs ();
811+ attrs.num_bits_ = 8 ;
812+ attrs.range_given_ = true ;
813+ attrs.signed_input_ = true ;
814+ attrs.round_mode_ = " HALF_UP" ;
815+
816+ vector<int > static_input_indexes = {1 , 2 };
817+ ops::QuantizeAndDequantizeV2 R =
818+ ops::QuantizeAndDequantizeV2 (root, A, 0 .0f , 127 .0f , attrs);
819+
820+ vector<DataType> output_datatypes = {DT_FLOAT};
821+
822+ std::vector<Output> sess_run_fetchoutputs = {R.output };
823+ OpExecuter opexecuter (root, " QuantizeAndDequantizeV2" , static_input_indexes,
824+ output_datatypes, sess_run_fetchoutputs);
825+
826+ opexecuter.RunTest ();
827+ }
828+
829+ TEST (ArrayOps, QuantizeAndDequantizeV2RoundingMode2) {
830+ Scope root = Scope::NewRootScope ();
831+ int dim1 = 2 ;
832+ int dim2 = 3 ;
833+
834+ Tensor A (DT_FLOAT, TensorShape ({dim1, dim2}));
835+ AssignInputValues<float >(A, {0.9 , 3.4 , 2.6 , 5.4 , 4.2 , 4.5 });
836+
837+ auto attrs = ops::QuantizeAndDequantizeV2::Attrs ();
838+ attrs.num_bits_ = 8 ;
839+ attrs.range_given_ = true ;
840+ attrs.signed_input_ = true ;
841+ attrs.round_mode_ = " HALF_TO_EVEN" ;
842+
843+ vector<int > static_input_indexes = {1 , 2 };
844+ ops::QuantizeAndDequantizeV2 R =
845+ ops::QuantizeAndDequantizeV2 (root, A, 0 .0f , 127 .0f , attrs);
846+
847+ vector<DataType> output_datatypes = {DT_FLOAT};
848+
849+ std::vector<Output> sess_run_fetchoutputs = {R.output };
850+ OpExecuter opexecuter (root, " QuantizeAndDequantizeV2" , static_input_indexes,
851+ output_datatypes, sess_run_fetchoutputs);
852+
853+ opexecuter.RunTest ();
854+ } // end of test op QuantizeAndDequantizeV2x8xtruextrue
801855
802856// CPU only supports QuantizedConcat with DT_QINT32 and DT_QUINT8
803857TEST (ArrayOps, QuantizedConcat) {
0 commit comments