Move High-Level Design Documentation to contrib/nnc (#1216)
authorРоман Михайлович Русяев/AI Tools Lab /SRR/Staff Engineer/삼성전자 <r.rusyaev@samsung.com>
Tue, 28 Aug 2018 15:29:32 +0000 (18:29 +0300)
committerSergey Vostokov/AI Tools Lab /SRR/Staff Engineer/삼성전자 <s.vostokov@samsung.com>
Tue, 28 Aug 2018 15:29:31 +0000 (18:29 +0300)
* Move High-Level Design Document to contrib/nnc
* Move SW Requirement Specification Document to contrib/nnc
* Move all their dependencies to contrib/nnc

Signed-off-by: Roman Rusyaev <r.rusyaev@samsung.com>
contrib/nnc/doc/project/18_NN_Compiler_and_Optimizer_HLD.rst [new file with mode: 0644]
contrib/nnc/doc/project/18_NN_Compiler_and_Optimizer_SRS.rst [new file with mode: 0644]
contrib/nnc/doc/project/images/nncc_components.png [new file with mode: 0644]
contrib/nnc/doc/project/images/nncc_idef0_a0.png [new file with mode: 0644]
contrib/nnc/doc/project/images/nncc_idef0_a1.png [new file with mode: 0644]
contrib/nnc/doc/project/images/nncc_idef0_a12.png [new file with mode: 0644]
contrib/nnc/doc/project/project_purpose_and_scope.rst [new file with mode: 0644]
contrib/nnc/doc/project/project_sw_hw_constraints.rst [new file with mode: 0644]
contrib/nnc/doc/project/project_target_model.rst [new file with mode: 0644]
contrib/nnc/doc/project/project_terms_and_abbreviation.rst [new file with mode: 0644]

diff --git a/contrib/nnc/doc/project/18_NN_Compiler_and_Optimizer_HLD.rst b/contrib/nnc/doc/project/18_NN_Compiler_and_Optimizer_HLD.rst
new file mode 100644 (file)
index 0000000..7b25332
--- /dev/null
@@ -0,0 +1,441 @@
+====================
+SW High Level Design
+====================
+
+.. contents::
+
+.. section-numbering::
+
+.. raw:: pdf
+
+   PageBreak oneColumn
+
+
+**Revision history**
+
++-------+-------------+----------------------------+--------------------------+---------------------+
+| Ver.  | Date        | Contents                   | Author                   | Approver            |
++=======+=============+============================+==========================+=====================+
+| 0.1   | 2018.05.25  | Initial version            | Vostokov Sergey          | Sung-Jae Lee        |
++-------+-------------+----------------------------+--------------------------+---------------------+
+| 0.2   | 2018.06.21  | SE member review           | Alexey Kondrashov        |                     |
++-------+-------------+----------------------------+--------------------------+---------------------+
+| 1.0   | 2018.06.22  | Final DR1 version          | Vostokov Sergey          | Sung-Jae Lee        |
++-------+-------------+----------------------------+--------------------------+---------------------+
+
+.. include:: project_terms_and_abbreviation.rst
+
+|
+
+**References**
+
+[1] Vostokov Sergey, `SW Requirements Specification <18_NN_Compiler_and_Optimizer_SRS.rst>`_
+
+
+Overview
+========
+
+Scope
+-----
+
+.. include:: project_purpose_and_scope.rst
+.. include:: project_target_model.rst
+
+
+Design Consideration
+--------------------
+
+Deep learning software demands reliability and performance. The common approach which comes from the history is to develop
+a SW framework (machine learning framework) which would compute each step of the neural network inference process using
+supported hardware. This approach is used in many popular solutions like Google Tensorflow/Tensorflow Lite, Caffe/2, etc.
+Traditionally, neural network developers build a computation graph and then an appropriate machine
+learning framework interprets it. The latest discoveries in AI field show that the node-visitor method of execution is inefficient. As a result,
+a second approach has been worked out by the industry, which is a neural network compiler that executes code more efficiently.
+
+This document presents the design of the *nncc*, a neural network compiler collection. The design should provide the easiest
+way to extend the functionality of the *nncc* by adding new modules with the following features:
+
+ - Support neural networks produced by various machine learning frameworks;
+ - Produce an artefact taking advantages of various hardware including specialized processors like NPU;
+ - Apply new domain specific optimization techniques over given NN.
+
+
+Constraints
+-----------
+
+See constraints in SW Requirements Specification.
+
+.. include:: project_sw_hw_constraints.rst
+
+
+SW System Architecture Design
+=============================
+
+Overall Architecture
+--------------------
+
+The picture below presents the result of high-level analysis of the requirements which **nncc** should satisfy. It describes the
+main function **Compilation** of the compiler collection using IDEF0 (functional modeling) notation. The full information on IDEF
+family of modeling languages is available at this link on `Wikipedia: IDEF <https://en.wikipedia.org/wiki/IDEF>`_.
+
+
+.. image:: images/nncc_idef0_a0.png
+   :scale: 100%
+
+Figure 1. Top-Level Context Diagram of compilation function.
+
+|
+| The short explanation of the **Figure 1**:
+|
+
+**1. Input entities:**
+
+   - *NN Model instance:* It is the main input of *nncc*. The compiler takes from a user information describing a neural network which should be compiled. In most cases, this NN is produced by a machine learning framework and stored in one or many files. The contents of these files constitute the essence of the neural network. Here it is denoted as an instance of NN model.
+   - *Command line options:* In order to provide the most convenient way to use the compiler, it should be configurable. Current design presents a tool which has a Command Line Interface (CLI). Command line options are a symbolic representation of directions instructing the compiler how to set up a working session to get the desired result.
+
+|
+
+**2. Output:**
+
+   - *Target binaries:* Everything that is produced by the compilation operation. In general case the result may consist of one or more files. Each of them may be one of the following: an executable, a source code file, a log/verification/error report. For example, when we require the compiler to compile a neural network for execution on GPU, the output artefact may be OpenCL/C/C++ source code, or a binary containing invocation of the procedures delegating the calculations to GPU.
+
+|
+
+**3. Rules and notations:**
+
+   - *NN Model specification:* Each machine learning framework has its own architecture design and uses its own format to serialize/deserialize computation graphs which represent neural networks. On a storage device, it may be saved as a file or many files using a unique markup of binary data. To enable *nncc* to read such data and process it, in the future it should recognize the format of the container. Importer/parser subsystem of *nncc* stores the full knowledge of the NN specifications and is responsible for reading and parsing NN models (see `Import NN model`_).
+   - *High-Level and Low-Level Optimization techniques:* Before deployment, a neural network developer might want to verify their product and optimize it by size and performance. There are many techniques for reducing the common size of neural network weights and improving performance of the inference. NN optimization activity can be automated by implementing each technique in the middleend according to its specifications (see `Apply Optimizations`_).
+   - *Target Runtime Environment (TRE):* In the case when the compiler produces the binary for execution on a specific SW platform, it should take into account the common API of this SW Platform. It includes the full public API of a chosen OS available to the 3rd party developers.
+   - *Target Instruction Set Architecture (Target ISA):* Resulting artefact is always executed on a SW Platform using some specified API. The user may want to generate the artefact that would use OpenBlas or Arm Compute Library or something else (if supported by the compiler), to perform calculations. In order to provide such possibility, *nncc* should be aware of the API to the specified 3rd party libraries.
+   - *Device specifications:* Some of the optimization techniques may take into account the technological features of the computing device, like the time to perform some specific calculations. Such information is very helpful during optimization of the final code of the compiled artefact because it may be used to select an optimal sequence of command invocations in order to achieve the best performance.
+
+|
+
+**4. Mechanism:**
+
+   - *Optimizing NN Compiler:* The implemented compiler itself. Since *nncc* is dedicated to producing the code for the most efficient execution, we may regard the tool as optimizing.
+   - *Host OS:* Since the compiler is a tool that works in some SW Environment, the main Top-Level SW system is an Operating System. In the SW Requirements specification it may be defined as a Linux-like OS, for example Ubuntu, Archlinux, etc.
+
+|
+
+Composition of Architecture
+---------------------------
+
+The compiler consists of three main parts: frontend, middleend, backend. Together they form a Neural Network instance processing pipeline. Moreover, there is one additional part that is in charge of the compiler configuration.
+
+
+|
+
+.. image:: images/nncc_components.png
+   :scale: 50%
+
+Figure 2. Top-Level Components of the *nncc*.
+
+|
+
+.. list-table::
+   :widths: 20 50
+   :header-rows: 1
+
+   * - Layer or Subsystem Name
+     - Description
+
+   * - Frontend
+     - Imports a specified Neural Network, presents it as a computation graph
+
+   * - Middleend
+     - Provides various optimizations over the computation graph; at the end transforms it to internal IR
+
+   * - Backend
+     - Produces the specified artefact as a result of compilation procedure using specified parameters describing the target OS, target HW, etc
+
+   * - Configuration system
+     - Accepts command line options and configures *nncc* according to their contents
+
+|
+| The detailed decomposition of the main function **Compilation** is presented on the diagram A1 below.
+|
+
+Interface
+---------
+
+Similar to any console application the *nncc* CLI accepts two types of options:
+
+  - Options that have values, for example, a name of the output executable
+  - Options that don't have values (switches) that turn various features on and off
+
+Additionally, options can be general and subsystem-specific.
+
+General options direct the process of the neural network compilation as a whole, and also control the utility functions like the verbosity of the messages that *nncc* outputs during the compilation process.
+
+Subsystem-specific options control each respective subsystem:
+
+  - Frontend subsystem takes options that point to the NN model to compile, which format it has, which version of the format and so on.
+  - Middleend subsystem takes options that either turn on specific optimizations for the NN model, or just point at the more desired outcome, for example "target performance efficiency" or "target memory efficiency".
+  - Backend subsystem takes options that describe the desired target device or architecture and so on.
+
+For better usability, high-level options are also supported. A single high-level option is mapped to a group of lower level options, similarly to how it is done with conventional compiler drivers, like gcc. This way by choosing a single Middleend option "target performance", nncc will automatically choose a number of performance optimizations by itself.
+
+SW System Operation Design
+==========================
+
+The Figure 3 presents a more detailed composition of the main function **Compilation**. As it was shown in previous section `Composition of Architecture`_ it is composed of 5 subfunctions:
+
+- Setup and configure each module - *Block 1* (See `Initialization`_ section)
+- Import the specified neural network - *Block 2* (See `Import NN model`_ section)
+- Apply High-Level optimizations - *Block 3* (See `Apply Optimizations`_ section)
+- Apply Low-Level optimizations - *Block 4* (See `Apply Optimizations`_ section)
+- Generate the output code for specified target - *Block 5* (See `Generate the code`_ section)
+
+
+|
+
+.. image:: images/nncc_idef0_a1.png
+   :scale: 100%
+
+Figure 3. Decomposition of top-Level function **Compilation**.
+
+
+Initialization
+--------------
+
+At this stage the initialization of all submodules of the *nncc* happens. This procedure starts from command line option processing till selection of all required and correctly configured modules.
+At the parsing stage the configuration system checks its own consistency. If command line option set is not enought to establish a valid configuration the environment variables will be used. Also, almost all configuration options can be read from config file if it is specified in command line.
+
+
+
+Import NN model
+---------------
+
+The major function of the *nncc* frontend is to import specified NN model. It means that frontend should recognize the format of given NN model, parse all internal structures (load computation graph using framework specific IR: NN topology, NN ops, weights), verify their correctness and convert to Model IR.
+
+
+Apply Optimizations
+-------------------
+
+There are two levels of neural network optimizations in *nncc*.
+
+First one is High-Level Optimizations, they are applied to the Model IR, which is output by the NN Import subsystem.
+
+High-Level Optimizations
+````````````````````````
+High-Level optimizations can be divided into two groups:
+
+  - optimizations aimed at reducing the size of the resulting model - *size optimizations*
+  - optimizations aimed at reducing the inference time of the model - *performance optimizations*
+
+These two groups are not mutually exclusive. Some optimization techniques positively affect both size and performance, while some of them might reduce the size of the model at some performance cost.
+
+High-Level Optimizations in this sense are purely neural-network-specific, as they attempt to improve the model by manipulating the computation graph and the weights. For example, some techniques search for unused parts of the computation graph and remove them, or they search for the parts of the graph that can be merged together and thus gain some performance. Other techniques manipulate the neural network weights - either reduce their amount or modify their values in a way that allows for the reduced storage consumption.
+
+Currently, High-Level Optimizations are out of scope of the project.
+
+
+Low-Level Optimization
+``````````````````````
+
+The Low-Level Optimizations are applied by the compiler closer to the end of the whole compilation process, before the executable generation. The input for this stage of *nncc* is the Coarse-Grained IR, which is output but High-Level Optimization subsystem.
+
+Generate the code
+-----------------
+
+
+Present architecture allows for several backend solutions, depending on target specified. Those solutions can be divided into 3 types:
+
+  - *Interpretation.*
+    At every step inference can be carried out by interpreting IR produced after that step.
+  - *Soft backend.*
+    Resulting program can be generated as source code in high-level programming language (e.g., C/C++) that does not depend on libraries outside of itself, with the exception of system libraries.
+  - *Hardware (Binary) backend.*
+    This type refers to generating binary code that can be executed on target device. NN compiler can generate code that is either executed solely on CPU, or takes advantage of the GPU when possible if corresponding target was specified.
+
+Third-party libraries incorporation can be done either in form of source code or by compiling a binary artefact.
+
+
+
+
+Appendix 1. Traceability Matrix
+===============================
+
+The following table shows mapping between SW Requirements Specification and SW High-Level Design Document.
+
+.. list-table::
+   :widths: 15 40 15
+   :header-rows: 1
+
+   * - Requirement
+     - Description
+     - Section
+
+   * - RF-1 (Frontend: Tensorflow Lite)
+     - The compiler should support import of NN model in Tensorflow Lite format (parsing & verification of data scheme v0-v3, 50 NN ops)
+     - `Import NN model`_
+
+   * - RF-2 (Frontend: Caffe)
+     - The compiler should support import of NN model in Caffe format (parsing & verification)
+     - `Import NN model`_
+
+   * - RF-3 (Frontend: Caffe2 (Optional))
+     - The compiler should support import of NN model in Caffe2 format (parsing & verification)
+     - `Import NN model`_
+
+   * - RF-4 (Frontend: lossless import)
+     - The frontend should use the lossless approach while it is converting any NN model to IR
+     - `Import NN model`_
+
+   * - RF-5 (Frontend: Inception_v3)
+     - The frontend should successful import the Inception V3 NN model
+     - `Import NN model`_
+
+   * - RF-6 (Frontend: MobileNet)
+     - The frontend should successful import the MobileNet NN model
+     - `Import NN model`_
+
+   * - RF-7 (Backend: ARM CPU)
+     - The compiler should produce executable for ARM CPU
+     - `Generate the code`_
+
+   * - RF-8 (Backend: ARM GPU)
+     - The compiler should produce the binary that takes advantages of GPU when it was specified before compilation
+     - `Generate the code`_
+
+   * - RF-9 (Backend: Artefact type)
+     - The compiler should produce executable as a shared library or as a static library
+     - `Generate the code`_
+
+   * - RF-10 (Backend: Inception_v3)
+     - The compiler should produce the valid compiled artefact for Inception v3 NN model
+     - `Generate the code`_
+
+   * - RF-11 (Backend: MobileNet)
+     - The compiler should produce the valid compiled artefact for MobileNet NN model
+     - `Generate the code`_
+
+   * - RF-12 (Config: command line)
+     - The compiler should get configuration parameters from command line
+     - `Initialization`_
+
+   * - RF-13 (Config: config file (Optional))
+     - The compiler should get configuration parameters from config file
+     - `Initialization`_
+
+   * - RF-14 (Config: environment variable (Optional))
+     - The compiler should get configuration parameters from environment variables
+     - `Initialization`_
+
+   * - RF-15 (Artefact: result)
+     - The artefact should provide comparable result to the original NN model for the same input data
+     - `Generate the code`_
+
+   * - RF-16 (Artefact: input verifications)
+     - The artefact should verify any input data and check consistency
+     - `Generate the code`_
+
+   * - RF-17 (Artefact: GPU)
+     - The artefact should take advantage of the GPU for GPU-enabled operations
+     - `Generate the code`_
+
+   * - RF-18 (Artefact: CPU)
+     - The artefact should take advantage of CPU if it was specified
+     - `Generate the code`_
+
+
+.. list-table:: Design Module of S/W Architecture
+   :widths: 40 10 15 15
+   :header-rows: 1
+
+   * - Requirement
+     - Import NN model
+     - Generate the code
+     - Initialization
+
+
+   * - RF-1 (Frontend: Tensorflow Lite)
+     - O
+     -
+     -
+
+   * - RF-2 (Frontend: Caffe)
+     - O
+     -
+     -
+
+   * - RF-3 (Frontend: Caffe2 (Optional))
+     - O
+     -
+     -
+
+   * - RF-4 (Frontend: lossless import)
+     - O
+     -
+     -
+
+   * - RF-5 (Frontend: Inception_v3)
+     - O
+     -
+     -
+
+   * - RF-6 (Frontend: MobileNet)
+     - O
+     -
+     -
+
+   * - RF-7 (Backend: ARM CPU)
+     -
+     - O
+     -
+
+   * - RF-8 (Backend: ARM GPU)
+     -
+     - O
+     -
+
+   * - RF-9 (Backend: Artefact type)
+     -
+     - O
+     -
+
+   * - RF-10 (Backend: Inception_v3)
+     -
+     - O
+     -
+
+   * - RF-11 (Backend: MobileNet)
+     -
+     - O
+     -
+
+   * - RF-12 (Config: command line)
+     -
+     -
+     - O
+
+   * - RF-13 (Config: config file (Optional))
+     -
+     -
+     - O
+
+   * - RF-14 (Config: environment variable (Optional))
+     -
+     -
+     - O
+
+   * - RF-15 (Artefact: result)
+     -
+     - O
+     -
+
+   * - RF-16 (Artefact: input verifications)
+     -
+     - O
+     -
+
+   * - RF-17 (Artefact: GPU)
+     -
+     - O
+     -
+
+   * - RF-18 (Artefact: CPU)
+     -
+     - O
+     -
diff --git a/contrib/nnc/doc/project/18_NN_Compiler_and_Optimizer_SRS.rst b/contrib/nnc/doc/project/18_NN_Compiler_and_Optimizer_SRS.rst
new file mode 100644 (file)
index 0000000..e42f77a
--- /dev/null
@@ -0,0 +1,503 @@
+=============================
+SW Requirements Specification
+=============================
+
+.. contents::
+
+.. section-numbering::
+
+.. raw:: pdf
+
+   PageBreak oneColumn
+
+**Revision history**
+
++-------+-------------+----------------------------+--------------------------+---------------------+
+| Ver.  | Date        | Contents                   | Author                   | Approver            |
++=======+=============+============================+==========================+=====================+
+| 0.1   | 2018.04.11  | Initial version            | Vostokov Sergey          | Sung-Jae Lee        |
++-------+-------------+----------------------------+--------------------------+---------------------+
+| 0.2   | 2018.04.11  | SE member in-charge review | Aleksei Kondrashov       |                     |
++-------+-------------+----------------------------+--------------------------+---------------------+
+| 1.0   | 2018.04.13  | Final Execution DR version | Vostokov Sergey          | Sung-Jae Lee        |
++-------+-------------+----------------------------+--------------------------+---------------------+
+| 1.1   | 2018.05.24  | Add new requirement in     | Vostokov Sergey          | Sung-Jae Lee        |
+|       |             | Source code section        |                          |                     |
++-------+-------------+----------------------------+--------------------------+---------------------+
+
+
+Introduction
+============
+
+Purpose and scope
+-----------------
+
+.. include:: project_purpose_and_scope.rst
+.. include:: project_terms_and_abbreviation.rst
+
+
+SW System Architecture
+----------------------
+
+The main components of the compiler are the following:
+
+- Configuration system
+- Importer (convert supported NN model to Model IR before optimization)
+- High-Level optimization (Applies HW independent optimizations)
+- Low-Level optimization (Applies optimizations appropriate to the specified target HW)
+- Code emitter (Produces the binary to take advantages of CPU and/or GPU)
+
+
+.. image:: ../images/nncc_idef0_a1.png
+    :scale: 100%
+
+
+Relevant Industry Standards
+---------------------------
+
+Architecture design is described using IDEF notation. Since the nncc is a part of open source STAR Platform project any other industry standards not required and/or applicable.
+
+
+SW Functional Requirements
+==========================
+
+Frontend
+--------
+
+.. list-table::
+   :widths: 23 50 100
+   :header-rows: 1
+
+   * - ID
+     - Requirement Name
+     - Description
+
+   * - RF-1
+     - Frontend: Tensorflow Lite
+     - The compiler should support import of NN model in Tensorflow Lite format (parsing & verification of data scheme v0-v3, 50 NN ops)
+
+   * - RF-2
+     - Frontend: Caffe
+     - The compiler should support import of NN model in Caffe format (parsing & verification)
+
+
+   * - RF-3
+     - Frontend: Caffe2 (Optional)
+     - The compiler should support import of NN model in Caffe2 format (parsing & verification)
+
+
+   * - RF-4
+     - Frontend: lossless import
+     - The front-end should use the lossless approach while it is converting any NN model to IR
+
+   * - RF-5
+     - Frontend: Inception_v3
+     - The front-end should successful import the Inception V3 NN model
+
+   * - RF-6
+     - Frontend: MobileNet
+     - The front-end should successful import the MobileNet NN model
+
+High-Level optimization
+-----------------------
+
+No special requirements
+
+
+Low-Level optimization
+----------------------
+
+No special requirements
+
+
+Backend
+-------
+
+.. list-table::
+   :widths: 23 50 100
+   :header-rows: 1
+
+   * - ID
+     - Requirement Name
+     - Description
+
+   * - RF-7
+     - Backend: ARM CPU
+     - The compiler should produce executable for ARM CPU
+
+   * - RF-8
+     - Backend: ARM GPU
+     - The compiler should produce the binary that takes advantages of GPU when it was specified before compilation
+
+   * - RF-9
+     - Backend: Artefact type
+     - The compiler should produce executable as a shared library or as a static library
+
+   * - RF-10
+     - Backend: Inception_v3
+     - The compiler should produce the valid compiled artefact for Inception v3 NN model
+
+   * - RF-11
+     - Backend: MobileNet
+     - The compiler should produce the valid compiled artefact for MobileNet NN model
+
+
+Configuration
+-------------
+
+.. list-table::
+   :widths: 23 50 100
+   :header-rows: 1
+
+   * - ID
+     - Requirement Name
+     - Description
+
+   * - RF-12
+     - Config: command line
+     - The compiler should get configuration parameters from command line
+
+   * - RF-13
+     - Config: config file (Optional)
+     - The compiler should get configuration parameters from config file
+
+   * - RF-14
+     - Config: environment variable (Optional)
+     - The compiler should get configuration parameters from environment variables
+
+Compiled Artefact
+-----------------
+
+.. list-table::
+   :widths: 23 50 100
+   :header-rows: 1
+
+   * - ID
+     - Requirement Name
+     - Description
+
+   * - RF-15
+     - Artefact: result
+     - The artefact should provide comparable result to the original NN model for the same input data
+
+   * - RF-16
+     - Artefact: input verifications
+     - The artefact should verify any input data and check consistency
+
+   * - RF-17
+     - Artefact: GPU
+     - The artefact should take advantage of the GPU for GPU-enabled operations
+
+   * - RF-18
+     - Artefact: CPU
+     - The artefact should take advantage of CPU if it was specified
+
+SW Non-Functional Requirements
+==============================
+
+
+
+The compiler
+------------
+
+Performance
+```````````
+
+No special requirements
+
+SW capacity
+```````````
+
+No special requirements
+
+
+Reliability
+```````````
+
+.. list-table::
+   :widths: 23 50 100
+   :header-rows: 1
+
+   * - ID
+     - Requirement Name
+     - Description
+   * - RNF-1
+     - Reliability: input
+     - The compiler should produce correct executable in order to utilize CPU and GPU when the correct input data is provided. If the incorrect input data are provided the compiler should not produce a compiled artefact, but inform user about all errors which were met
+
+Security
+````````
+
+No special requirements
+
+Usability
+`````````
+
+No special requirements
+
+Availability
+````````````
+
+No special requirements
+
+Maintainability
+```````````````
+
+No special requirements
+
+Extendibility
+`````````````
+
+.. list-table::
+   :widths: 23 50 100
+   :header-rows: 1
+
+   * - ID
+     - Requirement Name
+     - Description
+   * - RNF-2
+     - Extendibility: frontend
+     - The compiler design and implementations should provide possibility to add new features to front-end: new NN models format
+   * - RNF-3
+     - Extendibility: backend
+     - The compiler design and implementations should provide possibility to add new features to backend (new targets)
+
+
+Testability
+```````````
+
+
+.. list-table::
+   :widths: 23 50 100
+   :header-rows: 1
+
+   * - ID
+     - Requirement Name
+     - Description
+   * - RNF-4
+     - Testability: environment
+     - The test environment should be built in order to verify compiler functionality, product build status, artefact build/execution status, artefact calculation result and calculation memory footprint and performance
+
+
+Portability
+```````````
+
+.. list-table::
+   :widths: 23 50 100
+   :header-rows: 1
+
+   * - ID
+     - Requirement Name
+     - Description
+   * - RNF-5
+     - Portability: Linux
+     - The compiler should be portable with Linux-based OS
+
+Scalability
+```````````
+
+No special requirements
+
+Expandability
+`````````````
+
+No special requirements
+
+Configurability
+```````````````
+
+.. list-table::
+   :widths: 23 50 100
+   :header-rows: 1
+
+   * - ID
+     - Requirement Name
+     - Description
+   * - RNF-6
+     - Configurability: command line
+     - The compiler should support applying configuration through command line options.
+   * - RNF-7
+     - Configurability: file (Optional)
+     - The compiler should support applying configuration through configuration file.
+   * - RNF-8
+     - Configurability: environment (Optional)
+     - The compiler should support applying configuration through environment variables.
+
+The compiled artefact
+---------------------
+
+No special requirements
+
+The source code
+---------------
+
+.. list-table::
+   :widths: 23 50 100
+   :header-rows: 1
+
+   * - ID
+     - Requirement Name
+     - Description
+   * - RNF-9
+     - Legislation
+     - All source code files should follows its original license and general project license without any conflicts
+   * - RNF-10
+     - Legitimacy
+     - The project should have its own general license
+   * - RNF-11
+     - Coding style
+     - Each source code file should follow the one defined for the project coding style
+   * - RNF-12
+     - Contrib
+     - RNF-9, RNF-10, RNF-11 are applicable only for the final release version of source code. These requirements are not applicable to the source code placed in development branch or any folder which is used as temporary storage for the source code under development.
+
+
+SW Interface Requirements
+=========================
+
+The compiler interface
+----------------------
+
+
+User Interface
+``````````````
+
+.. list-table::
+   :widths: 23 50 100
+   :header-rows: 1
+
+   * - ID
+     - Requirement Name
+     - Description
+   * - RIF-1
+     - Compiler UI: no interaction
+     - The compiler should not require any user interation during compilation (completed compilations, fatal exit)
+   * - RIF-2
+     - Compiler UI: CLI
+     - The compiler is considering as a command line tool which proceed parameters from command line and/or config file, environment variables
+   * - RIF-3
+     - Compiler UI: input
+     - The compiler should provide the facility to specify NN model to be compiled
+   * - RIF-4
+     - Compiler UI: target device
+     - The compiler should provide the facility to specify result target device (CPU or GPU)
+   * - RIF-5
+     - Compiler UI: target platform
+     - The compiler should provide the facility to specify result target SW platform
+   * - RIF-6
+     - Compiler UI: output
+     - The compiler should provide the facility to specify result target name
+   * - RIF-7
+     - Compiler UI: target type
+     - The compiler should provide the facility to specify result target type: shared or static library
+
+
+Hardware Interface
+``````````````````
+
+.. list-table::
+   :widths: 23 50 100
+   :header-rows: 1
+
+   * - ID
+     - Requirement Name
+     - Description
+   * - RIF-8
+     - Compiler HWI: x86_64 executable
+     - The solution should provide executables to run on x86_64-compatible system
+
+Software Interface
+``````````````````
+
+.. list-table::
+   :widths: 23 50 100
+   :header-rows: 1
+
+   * - ID
+     - Requirement Name
+     - Description
+   * - RIF-9
+     - Compiler SWI: frontend plugin
+     - The compiler should provide the SW interface in order to add support of the new NN model formats
+   * - RIF-10
+     - Compiler SWI: backend plugin (HW)
+     - The compiler should provide the SW interface in order to add support of the new HW
+   * - RIF-11
+     - Compiler SWI: backend plugin (SW Platform)
+     - The compiler should provide the SW interface in order to add support of the new SW Platform
+
+Communication Interface
+```````````````````````
+
+No requirements for communication interface.
+
+
+The compiled Artefact interface
+-------------------------------
+
+
+User Interface
+``````````````
+
+.. list-table::
+   :widths: 23 50 100
+   :header-rows: 1
+
+   * - ID
+     - Requirement Name
+     - Description
+   * - RIF-12
+     - Artefact UI: no GUI
+     - Command line UI in text is suitable
+
+Hardware Interface
+``````````````````
+
+.. list-table::
+   :widths: 23 50 100
+   :header-rows: 1
+
+   * - ID
+     - Requirement Name
+     - Description
+   * - RIF-13
+     - Artefact HWI: CPU
+     - The artefact should use ARM CPU instruction set when it was built for ARM CPU
+   * - RIF-14
+     - Artefact HWI: GPU
+     - The artefact should use ARM GPU instruction set when it was build for ARM GPU
+
+Software Interface
+``````````````````
+
+.. list-table::
+   :widths: 23 50 100
+   :header-rows: 1
+
+   * - ID
+     - Requirement Name
+     - Description
+   * - RIF-15
+     - Artefact SWI: GPU driver
+     - The artefact should use ARM GPU driver to invoke calculations when it was built for ARM GPU
+   * - RIF-16
+     - Artefact SWI: C/C++ header      
+     - The artefact should provide C/C++ interface in order to use it in other applications
+   * - RIF-17
+     - Artefact SWI: shared type
+     - The compiled artefact should be a shared library in order to share it between several executables when it was specified before compilation
+   * - RIF-18
+     - Artefact SWI: static type
+     - The compiled artefact should be a static library in order to be built-in to an executable when it was specified before compilation
+   * - RIF-19
+     - Artefact SWI: Info
+     - The artefact should provide SW interface in order to get the actual status of calculation process (progress, errors, final result)
+
+
+Communication Interface
+```````````````````````
+
+No requirements for communication interface.
+
+
+
diff --git a/contrib/nnc/doc/project/images/nncc_components.png b/contrib/nnc/doc/project/images/nncc_components.png
new file mode 100644 (file)
index 0000000..becd63d
Binary files /dev/null and b/contrib/nnc/doc/project/images/nncc_components.png differ
diff --git a/contrib/nnc/doc/project/images/nncc_idef0_a0.png b/contrib/nnc/doc/project/images/nncc_idef0_a0.png
new file mode 100644 (file)
index 0000000..9ba0968
Binary files /dev/null and b/contrib/nnc/doc/project/images/nncc_idef0_a0.png differ
diff --git a/contrib/nnc/doc/project/images/nncc_idef0_a1.png b/contrib/nnc/doc/project/images/nncc_idef0_a1.png
new file mode 100644 (file)
index 0000000..c5ebec5
Binary files /dev/null and b/contrib/nnc/doc/project/images/nncc_idef0_a1.png differ
diff --git a/contrib/nnc/doc/project/images/nncc_idef0_a12.png b/contrib/nnc/doc/project/images/nncc_idef0_a12.png
new file mode 100644 (file)
index 0000000..dabcad7
Binary files /dev/null and b/contrib/nnc/doc/project/images/nncc_idef0_a12.png differ
diff --git a/contrib/nnc/doc/project/project_purpose_and_scope.rst b/contrib/nnc/doc/project/project_purpose_and_scope.rst
new file mode 100644 (file)
index 0000000..eaf8d1d
--- /dev/null
@@ -0,0 +1,19 @@
+The main goal of the project is to develop a compiler for neural networks to produce executable artefact for specified SW and HW platform.
+
+The development scope includes the following components:
+
+- Develop importer module to parse, verify and represent NN model for further optimization and compilation
+- Develop code emitters to produce executable binary for CPU and GPU
+
+|
+| **2018 year goals:**
+
+- Support TensorFlow Lite NN model format
+- Support Caffe NN model format
+- Support Caffe2 NN model format (Optional)
+- Support compilation of MobileNet NN
+- Support compilation of Inception v3 NN
+- Support ARM CPU
+- Support ARM GPU (Mali)
+- Support Tizen OS
+- Support SmartMachine OS (Optional)
diff --git a/contrib/nnc/doc/project/project_sw_hw_constraints.rst b/contrib/nnc/doc/project/project_sw_hw_constraints.rst
new file mode 100644 (file)
index 0000000..f47c13f
--- /dev/null
@@ -0,0 +1,51 @@
+|
+
+.. list-table:: Table 1-2. Assumptions, Dependencies and the Constraints
+   :widths: 23 40 23
+   :header-rows: 1
+
+   * - Item
+     - Assumptions, Dependencies and the Constraints
+     - Reference
+
+   * - Tizen SW Platform
+     - The following items should be provided:
+         - Tizen API
+         - Tizen kernel
+         - Tizen FW
+         - Tizen SDK
+         - Tizen naming convention
+         |
+     -
+         - `www.tizen.org <www.tizen.org>`_
+         - `wiki.tizen.org <wiki.tizen.org>`_
+         - `developer.tizen.org <developer.tizen.org>`_
+
+   * - SmartMachine OS Platform
+     - The following items should be provided:
+         - SmartMachine API
+         - SmartMachine kernel
+         - SmartMachine FW
+         - SmartMachine SDK
+         - SmartMachine naming convention
+         |
+     -
+         - `Platform confluence <http://suprem.sec.samsung.net/confluence/pages/viewpage.action?pageId=81833987>`_
+         - `Github <https://github.sec.samsung.net/RS7-SmartMachine>`_
+         - `Functional Safety confluence <http://suprem.sec.samsung.net/confluence/display/ASEC/Adaptive+AUTOSAR>`_
+
+
+   * - Host OS
+     - Linux-based OS (Ubuntu, Archlinux, etc)
+     -
+         - `Ubuntu site <https://www.ubuntu.com/>`_
+         - `Archlinux site <https://www.archlinux.org/>`_
+
+   * - Tizen target HW
+     - The reference device should be provided: Tizen TM2
+     -
+
+   * - SmartMachine target HW
+     - The reference device should be provided
+     -
+
diff --git a/contrib/nnc/doc/project/project_target_model.rst b/contrib/nnc/doc/project/project_target_model.rst
new file mode 100644 (file)
index 0000000..e16ab71
--- /dev/null
@@ -0,0 +1,21 @@
+|
+
+.. list-table:: Table 1-1. Target Model
+   :widths: 23 50 20
+   :header-rows: 1
+
+   * - Product
+     - Target Model Name
+     - Comment
+
+   * - Tizen phone
+     - Tizen TM2
+     - Reference device
+
+   * - Tizen device
+     - Odroid XU4
+     - Reference board
+
+   * - SmartMachine target
+     - Microvision mv8890, exynos8890
+     - Reference device
diff --git a/contrib/nnc/doc/project/project_terms_and_abbreviation.rst b/contrib/nnc/doc/project/project_terms_and_abbreviation.rst
new file mode 100644 (file)
index 0000000..cb167e6
--- /dev/null
@@ -0,0 +1,37 @@
+|
+
+**Terminology and Abbreviation**
+
+.. list-table::
+   :widths: 10 30
+   :header-rows: 0
+
+   * - OS
+     - Operating System
+   * - OS API
+     - Application interface of OS
+   * - HW
+     - Hardware
+   * - SW
+     - Software
+   * - NN
+     - Neural Network
+   * - NN model
+     - Neural network model (Instance of NN built with ML framework)
+   * - NN compiler
+     - The compiler for neural network
+   * - ML framework
+     - The machine learning framework
+   * - TF/TF Lite
+     - Tensorflow/Tensorflow Lite ML framework
+   * - IR
+     - Intermediate representation
+   * - CI/CI system
+     - Continuous integration system
+   * - UI
+     - The user interface
+   * - GUI
+     - The graphical user interface
+   * - CLI
+     - The command-line interface
+