未验证 提交 d6cdb1ec 编写于 作者: X xiebaiyuan 提交者: GitHub

[mobile][opencl] add test4 male2fe ,test=mobile (#2717)

* [mobile][opencl] suite model male2fe ,support a type element_mul ,test=mobile

* [mobile][opencl] add test4 male2fe ,test=mobile
上级 59d079e8
......@@ -551,6 +551,12 @@ if (ENABLE_ALL_TEST)
ADD_EXECUTABLE(test-inference-api-v2 net/test_inference_api_v2.cpp test_helper.h test_include.h executor_for_test.h)
target_link_libraries(test-inference-api-v2 paddle-mobile)
if (GPU_CL)
ADD_EXECUTABLE(test-net-male2fe net/test_mobilenet_male2fe.cpp test_helper.h test_include.h executor_for_test.h)
target_link_libraries(test-net-male2fe paddle-mobile)
endif()
endif ()
else ()
# gen test
......
/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License. */
#include <iostream>
#include "../../src/common/types.h"
#include "../test_helper.h"
#include "../test_include.h"
void feed(PaddleMobile<paddle_mobile::GPU_CL> *paddle_mobile, const DDim &dims,
std::string image_path, std::string feed_name) {
float *input_data_array = new float[product(dims)];
std::ifstream in(image_path, std::ios::in);
for (int i = 0; i < product(dims); i++) {
float num;
in >> num;
input_data_array[i] = num;
}
in.close();
framework::Tensor input_tensor(input_data_array, dims);
DLOG << feed_name << " : " << input_tensor;
paddle_mobile->Feed(feed_name, input_tensor);
}
int main() {
paddle_mobile::PaddleMobile<paddle_mobile::GPU_CL> paddle_mobile;
auto time1 = paddle_mobile::time();
#ifdef PADDLE_MOBILE_CL
paddle_mobile.SetCLPath("/data/local/tmp/bin");
#endif
if (paddle_mobile.Load(std::string("../models/nanbiannv") + "/model",
std::string("../models/nanbiannv") + "/params",
true)) {
auto time2 = paddle_mobile::time();
std::cout << "load cost :" << paddle_mobile::time_diff(time1, time2) << "ms"
<< std::endl;
std::vector<float> input;
feed(&paddle_mobile, {1, 3, 256, 256}, "../images/input_1_3_256_256",
"image");
auto time3 = paddle_mobile::time();
paddle_mobile.Predict();
auto time4 = paddle_mobile::time();
std::cout << "predict cost :" << paddle_mobile::time_diff(time3, time4)
<< "ms" << std::endl;
}
auto rgb = paddle_mobile.Fetch("rgb");
auto mask = paddle_mobile.Fetch("mask");
LOG(kLOG_INFO) << "rgb" << *rgb;
LOG(kLOG_INFO) << "mask" << *mask;
return 0;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册