diff --git a/lite/api/cxx_api_test.cc b/lite/api/cxx_api_test.cc index 4d711302cb5880247f4a7b7082185c500b9ad6e9..cab23cdb8724a7711644539fcb10f9a3aff5c13f 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 7d322530f624c43737018d8ece98fb24d48bc16a..143a65ff6821f92a32c5da561ee55bf20d71ad52 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++) {