[nnpkg-spec] Add instance_norm and revise structure and level (#8148)
author이상규/On-Device Lab(SR)/Principal Engineer/삼성전자 <sg5.lee@samsung.com>
Thu, 17 Oct 2019 04:41:16 +0000 (13:41 +0900)
committer오형석/On-Device Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Thu, 17 Oct 2019 04:41:16 +0000 (13:41 +0900)
It updates nnpackage specification to define `instance_norm` operator.
Also, it updates the document structure since it begin to have additional
operator. I move operators to same level of model for user to find them easily.

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

index fa41316..cc4c992 100644 (file)
@@ -29,11 +29,19 @@ Running pre-trained models on a device, which has relatively low computing power
 TFLite's solution is acceptable, we don't need to create same thing again.
 - We can use several infra-structures and tools from TFLite.
 
+## Schema Source
+
+nnpackage supports two kinds of models: `tflite` and `circle`
+
+- For tflite, see `schema.fbs` from tensorflow lite `v1.13.1` source.
+
+- For circle, see [`../schema/circle_schema.fbs`](../schema/circle_schema.fbs).
+
 ## Extensions
 
 `nnpackage` model has some extensions that are different or missing from TFLite.
 
-### Multiple Layout
+### A. Multiple Layout
 
 `nnpackage` can support multiple layouts.
 
@@ -64,7 +72,7 @@ Under this assumption, We expect to
 - accelerate the performance
 - reduce the memory usage
 
-### Unspecified Dimension
+### B. Unspecified Dimension
 
 `nnpackage` represents unspecified dimension with `-1`.
 
@@ -75,16 +83,52 @@ Rationale:
 However, we would like to reserve `0` because `0` could be a valid dimension for a certain
 operator (e.g. `tflite.slice`).
 
-## Operator Reference
+### C. Additional operators
 
-All operators use same semantics of tensorflow lite operators.
-Refer tensorflow lite source code to understand what inputs, outputs and attributes
-are required and how they are interpretered.
+`circle` has additional operators that are not available in `tflite`.
+See operator reference below.
 
-## Schema Source
+# Operator Reference
 
-nnpackage supports two kinds of models: `tflite` and `circle`
+## TensorFlow Lite operators
 
-- For tflite, see `schema.fbs` from tensorflow lite source.
+All operators (except for additional operators) in `tflite` and `circle` use same semantics of tensorflow lite operators.
+Refer tensorflow lite source code (our baseline: `v1.13.1`) to understand what inputs, outputs and attributes are required and how they are interpretered.
 
-- For circle, see [`../schema/circle_schema.fbs`](../schema/circle_schema.fbs).
+## Additional operators
+
+### instance_norm
+
+Applies instance normalization
+
+y = `gamma` * (x - mean) / sqrt(variance + `epsilon`) + `beta`, where mean and variance are computed per instance per channel.
+
+#### attributes
+
+- `epsilon` : float (default is 1e-05)
+
+The epsilon value is added to variance to avoid division by zero.
+
+- `fused_activation_function` : enumeration for `fused activation function type`.
+
+`fused activation function type` can be `NONE`, `RELU`, `RELU6` and `TANH` to name a few.
+For complete list, see `circle_schema.fbs`.
+
+The epsilon value is added to variance to avoid division by zero.
+
+#### inputs
+
+- `input` : 4-dimensional tensor
+  - Input data tensor; dimensions are determined by `DataFormat`. See `DataFormat` for further information.
+  - If `DataFormat` is `CHANNELS_FIRST`, layout will be (N x C x H x W), where N is the batch size, C is the number of channels, and H and W are the height and the width of the data.
+
+- `gamma` : 1-dimensional tensor of size C
+  - The gamma value is the scale applied to the normalized tensor
+
+- `beta` : 1-dimensional tensor of size C
+  - The beta value is the offset applied to the normalized tensor
+
+#### outputs
+
+- `output` : 4-dimensional tensor
+  - The output tensor is the normalized tensor of the same shape and type of `input`.