From 8fe95762b1db6ef5e2806fdd4d6beb7745664de2 Mon Sep 17 00:00:00 2001 From: "ysh329@sina.com" Date: Tue, 26 Nov 2019 04:28:15 +0000 Subject: [PATCH] add test for cxx and light api of getoutput. test=develop --- lite/api/cxx_api_test.cc | 6 ++++++ lite/api/light_api_test.cc | 2 ++ 2 files changed, 8 insertions(+) diff --git a/lite/api/cxx_api_test.cc b/lite/api/cxx_api_test.cc index 4d711302cb..cab23cdb87 100644 --- a/lite/api/cxx_api_test.cc +++ b/lite/api/cxx_api_test.cc @@ -129,6 +129,12 @@ TEST(CXXApi, load_model_naive) { 0.8938774}); auto* output_tensor = predictor.GetOutput(0); + const std::vector output_names = predictor.GetOutputNames(); + for (int i = 0; i < outputs.size(); i++) { + LOG(INFO) << "output_names[" << i << "]:" << output_names[i]; + } + auto* output_tensor_by_name = predictor.GetOutput(output_names[0]); + CHECK(output_tensor == output_tensor_by_name); auto output_shape = output_tensor->dims().Vectorize(); ASSERT_EQ(output_shape.size(), 2); ASSERT_EQ(output_shape[0], 1); diff --git a/lite/api/light_api_test.cc b/lite/api/light_api_test.cc index 7d322530f6..143a65ff68 100644 --- a/lite/api/light_api_test.cc +++ b/lite/api/light_api_test.cc @@ -51,6 +51,8 @@ TEST(LightAPI, load) { predictor.Run(); const auto* output = predictor.GetOutput(0); + const auto* output_by_name = predictor.GetOutput(outputs[0]); + CHECK(output == output_by_name); const float* raw_output = output->data(); for (int i = 0; i < 10; i++) { -- GitLab