MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / TEST

Function TEST

test/cpp/inference/api/paddle_infer_api_test.cc:23–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21namespace paddle_infer {
22
23TEST(Predictor, use_gpu) {
24 LOG(INFO) << GetVersion();
25 UpdateDllFlag("conv_workspace_size_limit", "4000");
26 std::string model_dir = FLAGS_infer_model + "/model";
27 Config config;
28 config.EnableNewIR(false);
29 config.SetModel(model_dir + "/model", model_dir + "/params");
30 config.EnableUseGpu(100, 0);
31
32 auto predictor = CreatePredictor(config);
33 auto pred_clone = predictor->Clone();
34
35 std::vector<int> in_shape = {1, 3, 318, 318};
36 int in_num =
37 std::accumulate(in_shape.begin(), in_shape.end(), 1, [](int &a, int &b) {
38 return a * b;
39 });
40
41 std::vector<float> input(in_num, 0);
42
43 auto input_names = predictor->GetInputNames();
44 auto input_t = predictor->GetInputHandle(input_names[0]);
45
46 input_t->Reshape(in_shape);
47 input_t->CopyFromCpu(input.data());
48 predictor->Run();
49
50 auto output_names = predictor->GetOutputNames();
51 auto output_t = predictor->GetOutputHandle(output_names[0]);
52 std::vector<int> output_shape = output_t->shape();
53 int out_num = std::accumulate(
54 output_shape.begin(), output_shape.end(), 1, std::multiplies<int>());
55
56 std::vector<float> out_data;
57 out_data.resize(out_num);
58 output_t->CopyToCpu(out_data.data());
59 predictor->ClearIntermediateTensor();
60}
61
62TEST(PredictorPool, basic) {
63 LOG(INFO) << GetVersion();

Callers

nothing calls this directly

Calls 15

GetVersionFunction · 0.85
CreatePredictorFunction · 0.85
GetNumBytesOfDataTypeFunction · 0.85
UpdateDllFlagFunction · 0.50
SetModelMethod · 0.45
EnableUseGpuMethod · 0.45
CloneMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
GetInputNamesMethod · 0.45
GetInputHandleMethod · 0.45
ReshapeMethod · 0.45

Tested by

no test coverage detected