diff options
author | Georgios Pinitas <georgios.pinitas@arm.com> | 2018-04-27 19:07:19 +0100 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:51:17 +0000 |
commit | cac13b1cfd593889271f8e2191be2039b8d88f36 (patch) | |
tree | d1c5196877d7fbd5dcfbb9f9003faf6035f82a33 /src/graph/Utils.cpp | |
parent | ad0c7388f6261989a268ffb2d042f2bd80736e3f (diff) | |
download | ComputeLibrary-cac13b1cfd593889271f8e2191be2039b8d88f36.tar.gz |
COMPMID-1097: Port mobilenet to NHWC
Change-Id: I789065bfa0d4ef133388e1904c5caf31e450f80f
Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/129495
Tested-by: Jenkins <bsgcomp@arm.com>
Reviewed-by: Anthony Barbier <anthony.barbier@arm.com>
Diffstat (limited to 'src/graph/Utils.cpp')
-rw-r--r-- | src/graph/Utils.cpp | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/src/graph/Utils.cpp b/src/graph/Utils.cpp index 8537bbfb2a..030fa2df59 100644 --- a/src/graph/Utils.cpp +++ b/src/graph/Utils.cpp @@ -89,10 +89,6 @@ PassManager create_default_pass_manager(Target target) return pm; } -/** Default setups a graph Context - * - * @param[in] ctx Context to default initialize - */ void setup_default_graph_context(GraphContext &ctx) { for(const auto &backend : backends::BackendRegistry::get().backends()) @@ -100,5 +96,40 @@ void setup_default_graph_context(GraphContext &ctx) backend.second->setup_backend_context(ctx); } } + +size_t get_dimension_size(const TensorDescriptor &descriptor, const DataLayoutDimension data_layout_dimension) +{ + ARM_COMPUTE_ERROR_ON_MSG(descriptor.layout == DataLayout::UNKNOWN, "Cannot retrieve the dimension index for an unknown layout!"); + return descriptor.shape[get_dimension_idx(descriptor, data_layout_dimension)]; +} + +size_t get_dimension_idx(const TensorDescriptor &descriptor, const DataLayoutDimension data_layout_dimension) +{ + ARM_COMPUTE_ERROR_ON_MSG(descriptor.layout == DataLayout::UNKNOWN, "Cannot retrieve the dimension index for an unknown layout!"); + + /* Return the index based on the data layout + * [N C H W] + * [3 2 1 0] + * [N H W C] + */ + switch(data_layout_dimension) + { + case DataLayoutDimension::CHANNEL: + return (descriptor.layout == DataLayout::NCHW) ? 2 : 0; + break; + case DataLayoutDimension::HEIGHT: + return (descriptor.layout == DataLayout::NCHW) ? 1 : 2; + break; + case DataLayoutDimension::WIDTH: + return (descriptor.layout == DataLayout::NCHW) ? 0 : 1; + break; + case DataLayoutDimension::BATCHES: + return 3; + break; + default: + ARM_COMPUTE_ERROR("Data layout index not supported!"); + break; + } +} } // namespace graph } // namespace arm_compute
\ No newline at end of file |