@@ -271,4 +271,44 @@ TEST(InstanceNorm, nhwc) {
271271 std::vector<float > output (golden.size ());
272272 EXPECT_TRUE (infer_output->CopyDataFromTensor (output.data ()));
273273 EXPECT_TRUE (ArraysMatch (golden, output, 1e-5f ));
274+ }
275+
276+ TEST (Resize, bilinear_factor) {
277+ auto ctx = tim::vx::Context::Create ();
278+ auto graph = ctx->CreateGraph ();
279+
280+ tim::vx::ShapeType input_shape ({1 ,2 ,2 , 1 });
281+ tim::vx::ShapeType output_shape ({1 ,3 ,3 , 1 });
282+ tim::vx::TensorSpec input_spec (tim::vx::DataType::FLOAT32,
283+ input_shape, tim::vx::TensorAttribute::INPUT);
284+ tim::vx::TensorSpec output_spec (tim::vx::DataType::FLOAT32,
285+ output_shape, tim::vx::TensorAttribute::OUTPUT);
286+
287+ auto input_tensor = graph->CreateTensor (input_spec);
288+ auto output_tensor = graph->CreateTensor (output_spec);
289+
290+ std::vector<float > in_data = {1 .0f , 1 .0f , 2 .0f , 2 .0f };
291+ std::vector<float > golden = {1 .0f , 1 .0f , 1 .0f , 1 .6666666269302368f , 1 .6666666269302368f ,
292+ 1 .6666666269302368f , 2 .0f , 2 .0f , 2 .0f };
293+
294+ EXPECT_TRUE (input_tensor->CopyDataToTensor (in_data.data (), in_data.size () * sizeof (float )));
295+
296+ auto op = graph->CreateOperation <tim::vx::ops::Resize>(tim::vx::ResizeType::BILINEAR,
297+ 1 .7999999523162842f , false , false , 3 , 3 , tim::vx::DataLayout::CWHN);
298+ (*op).BindInputs ({input_tensor}).BindOutputs ({output_tensor});
299+
300+ auto transform = tim::transform::LayoutInference (graph, ctx);
301+ auto infer_graph = transform.first ;
302+ auto graph_io_map = transform.second ;
303+ infer_graph->Compile ();
304+
305+ auto infer_input = graph_io_map[graph->InputsTensor ()[0 ]];
306+ auto infer_output = graph_io_map[graph->OutputsTensor ()[0 ]];
307+
308+ infer_input->CopyDataToTensor (in_data.data (), in_data.size () * sizeof (float ));
309+ infer_graph->Run ();
310+
311+ std::vector<float > output (golden.size ());
312+ EXPECT_TRUE (infer_output->CopyDataFromTensor (output.data ()));
313+ EXPECT_TRUE (ArraysMatch (golden, output, 1e-5f ));
274314}
0 commit comments