tensorflow/lite/delegates/gpu/common/transformations/add_quant_adjustments_test.cc
// Scenario:
// -> Add ->
//
// Since there is only one node output with no consumers, no new node should be
// added.


Since there is only one node output with no consumers, no new node should be
added.
Since there is only one node output with no consumers no new node should be added .
TEST(AddQuantAdjustments, OneNode) {
  GraphFloat32 graph;
  auto input = graph.NewValue();
  input->tensor.shape = BHWC(1, 4, 4, 8);
  AddQuantParams(&input->quant_params, 0.0, 1.0,
                 0.004);
  Tensor<Linear, DataType::FLOAT32> add_tensor;
  add_tensor.shape = Linear(8);
  add_tensor.data.resize(8);
  ElementwiseAttributes add_attr;
  add_attr.param = add_tensor;
  auto add_node = graph.NewNode();
  add_node->operation.type = ToString(OperationType::ADD);
  add_node->operation.attributes = add_attr;
  ASSERT_TRUE(graph.AddConsumer(add_node->id, input->id).ok());
  Value* output = nullptr;
  AddQuantParams(&input->quant_params, 0.0, 2.0,
                 0.008);
  ASSERT_TRUE(AddOutput(&graph, add_node, &output).ok());
  output->tensor.shape = BHWC(1, 4, 4, 8);
  ASSERT_EQ(1, graph.nodes().size());
  ASSERT_EQ(2, graph.values().size());
  auto transformation = NewAddQuantAdjustments();
  ModelTransformer transformer(&graph);
  transformer.Apply("add_quant_adjustments", transformation.get());
  EXPECT_EQ(1, graph.nodes().size());
  EXPECT_EQ(2, graph.values().size());
}
TEST ( AddQuantAdjustments , OneNode ) { GraphFloat32 graph ; auto input = graph . NewValue ( ) ; input -> tensor . shape = BHWC ( 1 , 4 , 4 , 8 ) ; AddQuantParams ( & input -> quant_params , 0.0 , 1.0 , 0.004 ) ; Tensor < Linear , DataType :: FLOAT32 > add_tensor ; add_tensor . shape = Linear ( 8 ) ; add_tensor . data . resize ( 8 ) ; ElementwiseAttributes add_attr ; add_attr . param = add_tensor ; auto add_node = graph . NewNode ( ) ; add_node -> operation . type = ToString ( OperationType :: ADD ) ; add_node -> operation . attributes = add_attr ; ASSERT_TRUE ( graph . AddConsumer ( add_node -> id , input -> id ) . ok ( ) ) ; Value * output = nullptr ; AddQuantParams ( & input -> quant_params , 0.0 , 2.0 , 0.008 ) ; ASSERT_TRUE ( AddOutput ( & graph , add_node , & output ) . ok ( ) ) ; output -> tensor . shape = BHWC ( 1 , 4 , 4 , 8 ) ; ASSERT_EQ ( 1 , graph . nodes ( ) . size ( ) ) ; ASSERT_EQ ( 2 , graph . values ( ) . size ( ) ) ; auto transformation = NewAddQuantAdjustments ( ) ; ModelTransformer transformer ( & graph ) ; transformer . Apply ( " " , transformation . get ( ) ) ; EXPECT_EQ ( 1 , graph . nodes ( ) . size ( ) ) ; EXPECT_EQ ( 2 , graph . values ( ) . size ( ) ) ; }
Scenario:
> Add ->
Scenario : > Add - >
/*min=*/ /*max=*/ /*scale=*/ /*min=*/ /*max=*/ /*scale=*/