tensorflow/core/kernels/quantized_matmul_op_test.cc
// This test multiplies two 1x1 8bit matrices, but sets an invalid quantization
// range, so we expect to get an error
This test multiplies two 1x1 8bit matrices, but sets an invalid quantization
range, so we expect to get an error
This test multiplies two 1x1 8bit matrices but sets an invalid quantization range so we expect to get an error
TEST_F(QuantizedMatMulTest, VerySmall_BadRange) {
  const bool transpose_a = true;
  const int a_rows = 1;
  const int a_cols = 1;
  const int b_rows = 1;
  const int b_cols = 1;
  const bool transpose_b = false;
  TF_ASSERT_OK(NodeDefBuilder("quantized_mat_mul_op", "QuantizedMatMul")
                   .Input(FakeInput(DT_QUINT8))
                   .Input(FakeInput(DT_QUINT8))
                   .Input(FakeInput(DT_FLOAT))
                   .Input(FakeInput(DT_FLOAT))
                   .Input(FakeInput(DT_FLOAT))
                   .Input(FakeInput(DT_FLOAT))
                   .Attr("Toutput", DataTypeToEnum<qint32>::v())
                   .Attr("transpose_a", transpose_a)
                   .Attr("transpose_b", transpose_b)
                   .Finalize(node_def()));
  TF_ASSERT_OK(InitOp());
  AddInputFromArray<quint8>(TensorShape({a_rows, a_cols}), {11});
  AddInputFromArray<quint8>(TensorShape({b_rows, b_cols}), {0});
  AddInputFromArray<float>(TensorShape({1}), {-12.0f});
  AddInputFromArray<float>(TensorShape({1}), {243.0f});
  AddInputFromArray<float>(TensorShape({1}), {1.0f});
  AddInputFromArray<float>(TensorShape({1}), {1.0f});
  EXPECT_EQ(::tensorflow::error::INVALID_ARGUMENT, RunOpKernel().code());
}
TEST_F ( QuantizedMatMulTest , VerySmall_BadRange ) { const bool transpose_a = true ; const int a_rows = 1 ; const int a_cols = 1 ; const int b_rows = 1 ; const int b_cols = 1 ; const bool transpose_b = false ; TF_ASSERT_OK ( NodeDefBuilder ( " " , " " ) . Input ( FakeInput ( DT_QUINT8 ) ) . Input ( FakeInput ( DT_QUINT8 ) ) . Input ( FakeInput ( DT_FLOAT ) ) . Input ( FakeInput ( DT_FLOAT ) ) . Input ( FakeInput ( DT_FLOAT ) ) . Input ( FakeInput ( DT_FLOAT ) ) . Attr ( " " , DataTypeToEnum < qint32 > :: v ( ) ) . Attr ( " " , transpose_a ) . Attr ( " " , transpose_b ) . Finalize ( node_def ( ) ) ) ; TF_ASSERT_OK ( InitOp ( ) ) ; AddInputFromArray < quint8 > ( TensorShape ( { a_rows , a_cols } ) , { 11 } ) ; AddInputFromArray < quint8 > ( TensorShape ( { b_rows , b_cols } ) , { 0 } ) ; AddInputFromArray < float > ( TensorShape ( { 1 } ) , { -12.0f } ) ; AddInputFromArray < float > ( TensorShape ( { 1 } ) , { 243.0f } ) ; AddInputFromArray < float > ( TensorShape ( { 1 } ) , { 1.0f } ) ; AddInputFromArray < float > ( TensorShape ( { 1 } ) , { 1.0f } ) ; EXPECT_EQ ( :: tensorflow :: error :: INVALID_ARGUMENT , RunOpKernel ( ) . code ( ) ) ; }
This test multiplies two 1x1 8bit matrices, but sets an invalid quantization
range, so we expect to get an error
This test multiplies two 1x1 8bit matrices but sets an invalid quantization range so we expect to get an error
// These parameters reflect a typical production usage of eight-bit matmuls // in an Inception-style network. // The A matrix is: // |  -1 | // The B matrix is: // |   1 | // Here we set the range so that the min and max are equal, so we expect to // see an error when we run.