From c0d588719174b22292429336d08f61c07e1ac50e Mon Sep 17 00:00:00 2001 From: Joe Shajrawi <17753158+shajrawi@users.noreply.github.com> Date: Mon, 30 Dec 2019 10:39:37 -0800 Subject: [PATCH] [OpenCL] Fix a bug when running an external model with the image-loader transposing the input to NCHW --- lib/Backends/OpenCL/OpenCLTensorLayout.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/Backends/OpenCL/OpenCLTensorLayout.cpp b/lib/Backends/OpenCL/OpenCLTensorLayout.cpp index 6bd60da173..6377ab410c 100644 --- a/lib/Backends/OpenCL/OpenCLTensorLayout.cpp +++ b/lib/Backends/OpenCL/OpenCLTensorLayout.cpp @@ -44,6 +44,14 @@ static std::string returnBaseReqOrNHWC(TensorLayoutDescription &baseReq, // These nodes accept any 4-D layout. return baseReq.getSerializedLayout(); } + // For Placeholders and Constants that were loaded from another tool, we don't + // have the layout information in during load time. This makes us assume they + // are in Glow's Canonical NHWC format, which is not correct if we are loading + // an image with NCHW such as in resent loader. Weaken the verifier to avoid a + // runtime crash: if this is a storage location, return the baseReq. + if (llvm::dyn_cast(node)) { + return baseReq.getSerializedLayout(); + } return CanonicalTensorLayout::getInstance().getDefaultNDLayout(4); }