提交 f32e2164 编写于 作者: L liuruilong

modify test conv op

上级 a4385039
...@@ -224,6 +224,18 @@ const framework::Program<Dtype, P> Loader<Dtype, P>::Load( ...@@ -224,6 +224,18 @@ const framework::Program<Dtype, P> Loader<Dtype, P>::Load(
} }
for (const auto &var : block.vars()) { for (const auto &var : block.vars()) {
if (var.type().type() == framework::proto::VarType::LOD_TENSOR) {
LOG(kLOG_DEBUG1) << "var name: " << var.name();
const framework::proto::VarType::TensorDesc &tensor_desc =
var.type().lod_tensor().tensor();
LOG(kLOG_DEBUG2) << "in var tensor desc dims size: "
<< tensor_desc.dims().size();
for (int l = 0; l < tensor_desc.dims().size(); ++l) {
LOG(kLOG_DEBUG3) << "var tensor desc dim " << l
<< " value: " << tensor_desc.dims()[l];
}
}
if (var.persistable() && if (var.persistable() &&
var.type().type() != framework::proto::VarType::FEED_MINIBATCH && var.type().type() != framework::proto::VarType::FEED_MINIBATCH &&
var.type().type() != framework::proto::VarType::FETCH_LIST) { var.type().type() != framework::proto::VarType::FETCH_LIST) {
......
...@@ -28,9 +28,9 @@ int main() { ...@@ -28,9 +28,9 @@ int main() {
executor(program, "conv2d"); executor(program, "conv2d");
paddle_mobile::framework::Tensor input; paddle_mobile::framework::Tensor input;
SetupTensor<float>(&input, {1, 3, 32, 32}, static_cast<float>(0), GetInput<float>(g_test_image_1x3x224x224, &input, {1, 3, 224, 224});
static_cast<float>(1));
auto out_ddim = paddle_mobile::framework::make_ddim({1, 64, 56, 56}); auto out_ddim = paddle_mobile::framework::make_ddim({1, 64, 112, 112});
auto output = executor.predict(input, "data", "conv2d_0.tmp_0", out_ddim); auto output = executor.predict(input, "data", "conv2d_0.tmp_0", out_ddim);
auto output_ptr = output->data<float>(); auto output_ptr = output->data<float>();
......
...@@ -60,3 +60,14 @@ void GetInput(const std::string &input_name, std::vector<T> *input, ...@@ -60,3 +60,14 @@ void GetInput(const std::string &input_name, std::vector<T> *input,
} }
free(input_ptr); free(input_ptr);
} }
template <typename T>
void GetInput(const std::string &input_name, paddle_mobile::framework::Tensor *input,
paddle_mobile::framework::DDim dims) {
T *input_ptr = input->mutable_data<T>(dims);
std::ifstream in(input_name, std::ios::in | std::ios::binary);
in.read((char *)(input_ptr), input->numel() * sizeof(T));
in.close();
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册