[nnpackage] update spec for multiple layout (#5553)
author이상규/On-Device Lab(SR)/Principal Engineer/삼성전자 <sg5.lee@samsung.com>
Fri, 5 Jul 2019 01:15:45 +0000 (10:15 +0900)
committer오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Fri, 5 Jul 2019 01:15:45 +0000 (10:15 +0900)
Multiple layout is added in specification.

Signed-off-by: Sanggyu Lee <sg5.lee@samsung.com>
contrib/nnpackage/spec/20_model_and_operators.md

index 7deee8d..38d3600 100644 (file)
@@ -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`.