Skip to content

Commit

Permalink
ci coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
jiweibo committed Sep 20, 2021
1 parent fdc70bb commit 6ed50e4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
9 changes: 1 addition & 8 deletions paddle/fluid/inference/api/analysis_predictor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -278,15 +278,8 @@ bool AnalysisPredictor::CreateExecutor() {
#endif
} else if (config_.NNAdapter().use_nnadapter) {
if (config_.lite_engine_enabled()) {
#ifdef LITE_SUBGRAPH_WITH_NNADAPTER
// Currently, Paddle-Lite's NNAdapter user interface only supports the
// transfer
// of Host data pointers. If it is currently used as a subgraph, execution
// efficiency will be sacrificed, so it is temporarily set to cpu place.
// And, the current lite engine of xpu must execute all parts of the
// model.
place_ = paddle::platform::CPUPlace();
#else
#ifndef LITE_SUBGRAPH_WITH_NNADAPTER
PADDLE_THROW(
platform::errors::Unavailable("You tried to use an NNAdapter lite "
"engine, but Paddle was not compiled "
Expand Down
18 changes: 18 additions & 0 deletions paddle/fluid/inference/api/analysis_predictor_tester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,24 @@ TEST(AnalysisPredictor, analysis_off) {
ASSERT_TRUE(predictor->Run(inputs, &outputs));
}

TEST(AnalysisPredictor, lite_nn_adapter_npu) {
AnalysisConfig config;
config.SetModel(FLAGS_dirname);
config.EnableLiteEngine();
config.NNAdapter()
.Disable()
.Enable()
.SetDeviceNames({"huawei_ascend_npu"})
.SetContextProperties("HUAWEI_ASCEND_NPU_SELECTED_DEVICE_IDS=0")
.SetModelCacheDir("cache_dirr")
.SetSubgraphPartitionConfigPath("")
.SetModelCacheBuffers("c1", {'c'});
#ifndef LITE_SUBGRAPH_WITH_NNADAPTER
EXPECT_THROW(CreatePaddlePredictor<AnalysisConfig>(config),
paddle::platform::EnforceNotMet);
#endif
}

TEST(AnalysisPredictor, analysis_on) {
AnalysisConfig config;
config.SetModel(FLAGS_dirname);
Expand Down

0 comments on commit 6ed50e4

Please sign in to comment.