Skip to content

Commit 7a2887d

Browse files
committed
add analyzer_face_tester
test=develop
1 parent 2ec65ae commit 7a2887d

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License. */
14+
15+
#include <fstream>
16+
#include <iostream>
17+
#include "paddle/fluid/inference/tests/api/tester_helper.h"
18+
19+
namespace paddle {
20+
namespace inference {
21+
namespace analysis {
22+
23+
void SetConfig(AnalysisConfig *cfg) {
24+
cfg->param_file = FLAGS_infer_model + "/params";
25+
cfg->prog_file = FLAGS_infer_model + "/model";
26+
cfg->use_gpu = false;
27+
cfg->device = 0;
28+
cfg->enable_ir_optim = true;
29+
cfg->specify_input_name = true;
30+
}
31+
32+
void SetInput(std::vector<std::vector<PaddleTensor>> *inputs) {
33+
SetFakeImageInput(inputs, FLAGS_infer_model);
34+
}
35+
36+
// Easy for profiling independently.
37+
TEST(Analyzer_face, profile) {
38+
AnalysisConfig cfg;
39+
SetConfig(&cfg);
40+
std::vector<PaddleTensor> outputs;
41+
42+
std::vector<std::vector<PaddleTensor>> input_slots_all;
43+
SetInput(&input_slots_all);
44+
TestPrediction(cfg, input_slots_all, &outputs, FLAGS_num_threads);
45+
}
46+
47+
// Check the fuse status
48+
TEST(Analyzer_face, fuse_statis) {
49+
AnalysisConfig cfg;
50+
SetConfig(&cfg);
51+
int num_ops;
52+
auto predictor = CreatePaddlePredictor<AnalysisConfig>(cfg);
53+
auto fuse_statis = GetFuseStatis(
54+
static_cast<AnalysisPredictor *>(predictor.get()), &num_ops);
55+
}
56+
57+
// Compare result of NativeConfig and AnalysisConfig
58+
TEST(Analyzer_face, compare) {
59+
AnalysisConfig cfg;
60+
SetConfig(&cfg);
61+
62+
std::vector<std::vector<PaddleTensor>> input_slots_all;
63+
SetInput(&input_slots_all);
64+
CompareNativeAndAnalysis(cfg, input_slots_all);
65+
}
66+
67+
} // namespace analysis
68+
} // namespace inference
69+
} // namespace paddle

0 commit comments

Comments
 (0)