Please sign in to comment.
Add Layout field to Conv and Pool nodes and remove OCL specific versi…
…ons (#3367) Summary: For convolutions in glow we use NHWC layout, but it's more efficient to use NCHW on GPUS. To enable this the OCL backend adds some specific OCLConvolution, OCLMaxPool and OCLAvgPool nodes and transforms general Conv and Pool nodes into them by shuffling dimensions and adding TransposeNodes. This PR adds a field `Layout` to ConvolutionNode, MaxPoolNode and AvgPoolNode which can be either NHWC or NCHW. The OCL backend still transforms these nodes but into the same node type with the layout set to NCHW (we still add transposes). This will allow us to reuse this logic in other backends with the same NCHW preference without needing multiple identical BackendConvolutionNodes (etc). This **DOES NOT** add NCHW convolution support to any backends, or change any OCL kernels - it just removes OCL specific nodes in favour of more general ones. This was a consensus decision, but worth thinking about whether or no the code is clearer after this change or not too. Documentation: deleted the section in docs referencing these nodes. Pull Request resolved: #3367 Test Plan: ninja test in various modes (debug, release, asan). Ran resnet-runtime on OCL, ran image-classifier on OCL, tracing-compare across interp, cpu and ocl. Differential Revision: D16631421 Pulled By: nickgg fbshipit-source-id: 3005a0cfda474db95020f2c1f162aebe4b016a59
- Loading branch information...
Showing with 385 additions and 386 deletions.
- +0 −41 docs/NewBackendSpecificNode.md
- +28 −10 include/glow/Backends/LayoutConverter.h
- +32 −24 include/glow/Graph/Graph.h
- +3 −0 include/glow/Graph/Nodes.h
- +7 −4 include/glow/IR/IRBuilder.h
- +7 −0 lib/Backends/Interpreter/InterpreterNodes.cpp
- +68 −87 lib/Backends/OpenCL/OpenCL.cpp
- +3 −3 lib/Backends/OpenCL/OpenCL.h
- +17 −4 lib/Backends/OpenCL/Transforms.cpp
- +2 −35 lib/Exporter/ONNXModelWriter.cpp
- +34 −30 lib/Graph/Graph.cpp
- +94 −28 lib/Graph/Nodes.cpp
- +50 −19 lib/IR/IRBuilder.cpp
- +8 −7 lib/IR/IRGen.cpp
- +8 −0 lib/LLVMIRCodeGen/LLVMIRGen.cpp
- +3 −3 lib/Optimizer/IROptimizer/IROptimizer.cpp
- +1 −1 tests/unittests/BackendTestUtils.h
- +1 −1 tests/unittests/BackendTestUtils2.h
- +4 −4 tests/unittests/BasicIRTest.cpp
- +0 −32 tools/ClassGen/Backends/OpenCL/OpenCLSpecificInstrs.h
- +0 −36 tools/ClassGen/Backends/OpenCL/OpenCLSpecificNodes.h
- +0 −13 tools/ClassGen/Backends/OpenCL/OpenCLSpecificNodesVerification.h
- +4 −0 tools/ClassGen/InstrGen.cpp
- +11 −4 tools/ClassGen/NodeGen.cpp
Oops, something went wrong.