From 325fef46b3e521c3b5563bcd00ad16b52f13f610 Mon Sep 17 00:00:00 2001 From: eclipsess Date: Wed, 7 Nov 2018 20:26:20 +0800 Subject: [PATCH] add case in loader: dim[2] < 0 --- src/framework/loader.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/framework/loader.cpp b/src/framework/loader.cpp index eb07e9f615..5587d0698f 100644 --- a/src/framework/loader.cpp +++ b/src/framework/loader.cpp @@ -44,7 +44,12 @@ void Loader::InitMemoryFromProgram( } else { auto dim = var_desc->Tensor_desc().Dims(); PADDLE_MOBILE_ENFORCE(dim.size() > 0, "dim size is 0"); - dim[0] = 1; + // dim[0] = 1; + for (auto &d : dim) { + if (d < 0) { + d *= -1; + } + } auto tensor = var->GetMutable(); tensor->Resize(make_ddim(dim)); } -- GitLab