From a2c4c6b69a83291320181714ea68a74de35d18a7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?=EC=9D=B4=EC=83=81=EA=B7=9C/On-Device=20Lab=28SR=29/Princip?= =?utf8?q?al=20Engineer/=EC=82=BC=EC=84=B1=EC=A0=84=EC=9E=90?= Date: Fri, 5 Jul 2019 10:15:45 +0900 Subject: [PATCH] [nnpackage] update spec for multiple layout (#5553) Multiple layout is added in specification. Signed-off-by: Sanggyu Lee --- contrib/nnpackage/spec/20_model_and_operators.md | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/contrib/nnpackage/spec/20_model_and_operators.md b/contrib/nnpackage/spec/20_model_and_operators.md index 7deee8d..38d3600 100644 --- a/contrib/nnpackage/spec/20_model_and_operators.md +++ b/contrib/nnpackage/spec/20_model_and_operators.md @@ -33,6 +33,37 @@ TFLite's solution is acceptable, we don't need to create same thing again. `nnpackage` model has some extensions that are different or missing from TFLite. +### Multiple Layout + +`nnpackage` can support multiple layouts. + +1. The layout is presented using `DataFormat` enumeration. + +`DataFormat` must be one of the enumeration defined in `nnpackage_schema.fbs`. + +For example, `CHANNELS_FIRST` or `CHANNELS_LAST` can be used. + +``` + // For 2D data, NHWC(batch, height, width, channels) + // For 3D data, NDHWC(batch, depth, height, width, channels) + CHANNELS_LAST = 0, + // For 2D data, NCHW(batch, channels, height, width) + // For 3D data, NCDHW(batch, channels, depth, height, width) + CHANNELS_FIRST = 1, +``` + +2. `DataFormat` must be same within a submodel. + +Rationale: + +- frequent switching between different layout degrades the performance + +Under this assumption, We expect to + +- simplify the runtime implementation +- accelerate the performance +- reduce the memory usage + ### Unspecified Dimension `nnpackage` represents unspecified dimension with `-1`. -- 2.7.4