From fda4d42c55fa3e4a68d62031f43c417433f3b156 Mon Sep 17 00:00:00 2001 From: Jiaying Zhao Date: Mon, 21 Oct 2019 19:25:39 +0800 Subject: [PATCH] add GetExceptionMsg for paddle_inference_api. test=develop (#2231) --- mobile/src/io/api_paddle_mobile.cc | 13 +++++++++++-- mobile/src/io/api_paddle_mobile.h | 1 + mobile/src/io/paddle_inference_api.h | 1 + mobile/test/CMakeLists.txt | 6 ++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/mobile/src/io/api_paddle_mobile.cc b/mobile/src/io/api_paddle_mobile.cc index d1e665ed32..4c6acb2567 100644 --- a/mobile/src/io/api_paddle_mobile.cc +++ b/mobile/src/io/api_paddle_mobile.cc @@ -111,10 +111,14 @@ bool PaddleMobilePredictor::Run( if (input.dtype == UINT8) { framework::Tensor input_tensor(static_cast(input.data.data()), ddim); - paddle_mobile_->Predict(input_tensor); + if (paddle_mobile_->Predict(input_tensor) != PMStatus::PMSuccess) { + return false; + } } else { framework::Tensor input_tensor(static_cast(input.data.data()), ddim); - paddle_mobile_->Predict(input_tensor); + if (paddle_mobile_->Predict(input_tensor) != PMStatus::PMSuccess) { + return false; + } } } @@ -153,6 +157,11 @@ bool PaddleMobilePredictor::Run( return true; } +template +std::string PaddleMobilePredictor::GetExceptionMsg() { + return paddle_mobile_->GetExceptionMsg(); +} + #ifdef PADDLE_MOBILE_FPGA void ConvertPaddleTensors(const PaddleTensor &src, framework::Tensor *des) { des->Resize(framework::make_ddim(src.shape)); diff --git a/mobile/src/io/api_paddle_mobile.h b/mobile/src/io/api_paddle_mobile.h index 11c993b3f8..63718acd99 100644 --- a/mobile/src/io/api_paddle_mobile.h +++ b/mobile/src/io/api_paddle_mobile.h @@ -32,6 +32,7 @@ class PaddleMobilePredictor : public PaddlePredictor { bool Run(const std::vector& inputs, std::vector* output_data, int batch_size = -1) override; + std::string GetExceptionMsg(); #ifdef PADDLE_MOBILE_FPGA void Predict_From_To(int start, int end) override; void FeedPaddleTensors(const std::vector& inputs) override; diff --git a/mobile/src/io/paddle_inference_api.h b/mobile/src/io/paddle_inference_api.h index dccfd1ceca..001b2c9bf0 100644 --- a/mobile/src/io/paddle_inference_api.h +++ b/mobile/src/io/paddle_inference_api.h @@ -174,6 +174,7 @@ class PaddlePredictor { virtual bool Run(const std::vector& inputs, std::vector* output_data, int batch_size = -1) = 0; + virtual std::string GetExceptionMsg() { return ""; } // Destroy the Predictor. virtual ~PaddlePredictor() = default; diff --git a/mobile/test/CMakeLists.txt b/mobile/test/CMakeLists.txt index faf0b6a6c6..d81b08ef0b 100644 --- a/mobile/test/CMakeLists.txt +++ b/mobile/test/CMakeLists.txt @@ -540,6 +540,12 @@ else() ADD_EXECUTABLE(test-net net/test_net.cpp test_helper.h test_include.h executor_for_test.h) target_link_libraries(test-net paddle-mobile) + ADD_EXECUTABLE(test-super net/test_super.cpp test_helper.h test_include.h executor_for_test.h) + target_link_libraries(test-super paddle-mobile) + ADD_EXECUTABLE(test-inference-pre-post net/test_inference_pre_post.cpp) target_link_libraries(test-inference-pre-post paddle-mobile) + + ADD_EXECUTABLE(test-inference-super net/test_inference_super.cpp) + target_link_libraries(test-inference-super paddle-mobile) endif() -- GitLab