From f32e21646ec6452daad50909f19d3448e3fc8e49 Mon Sep 17 00:00:00 2001 From: liuruilong Date: Sat, 26 May 2018 15:54:17 +0800 Subject: [PATCH] modify test conv op --- src/io.cpp | 12 ++++++++++++ test/operators/test_cov_op.cpp | 6 +++--- test/test_helper.h | 11 +++++++++++ 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/io.cpp b/src/io.cpp index bf632cf1db..eaab40b519 100644 --- a/src/io.cpp +++ b/src/io.cpp @@ -224,6 +224,18 @@ const framework::Program Loader::Load( } 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() && var.type().type() != framework::proto::VarType::FEED_MINIBATCH && var.type().type() != framework::proto::VarType::FETCH_LIST) { diff --git a/test/operators/test_cov_op.cpp b/test/operators/test_cov_op.cpp index a1fc543a4a..260cdfa04c 100644 --- a/test/operators/test_cov_op.cpp +++ b/test/operators/test_cov_op.cpp @@ -28,9 +28,9 @@ int main() { executor(program, "conv2d"); paddle_mobile::framework::Tensor input; - SetupTensor(&input, {1, 3, 32, 32}, static_cast(0), - static_cast(1)); - auto out_ddim = paddle_mobile::framework::make_ddim({1, 64, 56, 56}); + GetInput(g_test_image_1x3x224x224, &input, {1, 3, 224, 224}); + + 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_ptr = output->data(); diff --git a/test/test_helper.h b/test/test_helper.h index c4a6565bd2..3f298c5908 100644 --- a/test/test_helper.h +++ b/test/test_helper.h @@ -60,3 +60,14 @@ void GetInput(const std::string &input_name, std::vector *input, } free(input_ptr); } + +template +void GetInput(const std::string &input_name, paddle_mobile::framework::Tensor *input, + paddle_mobile::framework::DDim dims) { + + T *input_ptr = input->mutable_data(dims); + + std::ifstream in(input_name, std::ios::in | std::ios::binary); + in.read((char *)(input_ptr), input->numel() * sizeof(T)); + in.close(); +} -- GitLab