Remove modelgen tool (#3263)
author이한종/동작제어Lab(SR)/Engineer/삼성전자 <hanjoung.lee@samsung.com>
Fri, 19 Oct 2018 08:47:38 +0000 (17:47 +0900)
committer오형석/동작제어Lab(SR)/Staff Engineer/삼성전자 <hseok82.oh@samsung.com>
Fri, 19 Oct 2018 08:47:38 +0000 (17:47 +0900)
Remove modelgen tool since it can be done with tflchef from nncc.

Signed-off-by: Hanjoung Lee <hanjoung.lee@samsung.com>
tools/modelgen/CONV_2D.template.json [deleted file]
tools/modelgen/modelgen.py [deleted file]
tools/modelgen/modelgen.sh [deleted file]

diff --git a/tools/modelgen/CONV_2D.template.json b/tools/modelgen/CONV_2D.template.json
deleted file mode 100644 (file)
index 34ce09f..0000000
+++ /dev/null
@@ -1,102 +0,0 @@
-{
-  "version":3,
-  "operator_codes": [
-    {
-      "builtin_code": "CONV_2D"
-    }
-  ],
-  "subgraphs": [
-    {
-      "tensors": [
-        {
-          "shape": [
-            1,
-            3,
-            3,
-            3
-          ],
-          "buffer": 0,
-          "name": "input",
-          "quantization": {
-            "min": [
-              0.0
-            ],
-            "max": [
-              255.0
-            ]
-          }
-        },
-        {
-          "shape": [
-            1,
-            3,
-            3,
-            3
-          ],
-          "buffer": 1,
-          "name": "weights",
-          "quantization": {
-          }
-        },
-        {
-          "shape": [
-            1
-          ],
-          "buffer": 2,
-          "name": "convolution_bias",
-          "quantization": {
-          }
-        },
-        {
-          "shape": [
-            1,
-            3,
-            3,
-            1
-          ],
-          "buffer": 3,
-          "name": "output",
-          "quantization": {
-          }
-        }
-      ],
-      "inputs": [
-        0
-      ],
-      "outputs": [
-        3
-      ],
-      "operators": [
-        {
-          "opcode_index": 0,
-          "inputs": [
-            0,
-            1,
-            2
-          ],
-          "outputs": [
-            3
-          ],
-          "builtin_options_type": "Conv2DOptions",
-          "builtin_options": {
-            "padding": "SAME",
-            "stride_w": 1,
-            "stride_h": 1,
-            "fused_activation_function": "RELU"
-          }
-        }
-      ]
-    }
-  ],
-  "description": "TOCO Converted.",
-  "buffers": [
-    {},
-    {
-      "data": []
-    },
-    {
-      "data": []
-    },
-    {}
-  ]
-}
diff --git a/tools/modelgen/modelgen.py b/tools/modelgen/modelgen.py
deleted file mode 100755 (executable)
index 112a1e8..0000000
+++ /dev/null
@@ -1,98 +0,0 @@
-#!/usr/bin/python
-
-# Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#    http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import json
-import numpy as np
-import os
-import struct
-
-dir_path = os.path.dirname(os.path.realpath(__file__))
-
-builtin_ops = [
-    "CONV_2D",
-]
-
-# N,H,W,C
-input_shape = [1, 6, 6, 3]
-kernel_shape = [1, 3, 3, 3]
-
-# load template file.
-with open(dir_path + "/CONV_2D.template.json", 'r') as f:
-    graph = json.loads(f.read())
-    f.close()
-
-tensors = graph['subgraphs'][0]['tensors']
-buffers = graph['buffers']
-
-buffer_map = {}
-
-# shape setup
-for t in tensors:
-    if t['name'] == 'input':
-        t['shape'] = input_shape
-    elif t['name'] == 'weights':
-        t['shape'] = kernel_shape
-    elif t['name'] == 'convolution_bias':
-        # bias size = N of weight
-        t['shape'] = [kernel_shape[0]]
-    elif t['name'] == 'output':
-        # just for now, the same padding algorithm.
-        # stride = 1
-        t['shape'][0] = 1  # N
-        t['shape'][1] = input_shape[1]  # H
-        t['shape'][2] = input_shape[2]  # W
-        t['shape'][3] = kernel_shape[0]  # C
-
-    buffer_map[t['buffer']] = {'name': t['name'], 'shape': t['shape']}
-
-# buffer setup
-for i in range(len(buffers)):
-    if buffer_map[i]['name'] == 'weights':
-        shape = buffer_map[i]['shape']
-
-        weight = np.ones(shape)
-        n = shape[0]
-        h = shape[1]
-        w = shape[2]
-        c = shape[3]
-        for nn in range(n):
-            for hh in range(h):
-                for ww in range(w):
-                    for cc in range(c):
-                        if cc == 0:
-                            weight[nn][hh][ww][cc] = 1.0
-                        else:
-                            weight[nn][hh][ww][cc] = 0.0
-
-        weight_list = weight.flatten()
-        weight_bytes = struct.pack('%sf' % (len(weight_list)), *weight_list)
-        weight_uints = struct.unpack('%sB' % (len(weight_list) * 4), weight_bytes)
-
-        buffers[i]['data'] = list(weight_uints)
-
-    elif buffer_map[i]['name'] == 'convolution_bias':
-        # weight of N
-        shape = buffer_map[i]['shape']
-
-        bias = np.zeros(shape)
-        bias_list = bias.flatten()
-        bias_bytes = struct.pack('%sf' % (len(bias_list)), *bias_list)
-        bias_uints = struct.unpack('%sB' % (len(bias_list) * 4), bias_bytes)
-
-        buffers[i]['data'] = list(bias_uints)
-
-with open('model.json', 'w') as f:
-    f.write(json.dumps(graph, indent=2))
diff --git a/tools/modelgen/modelgen.sh b/tools/modelgen/modelgen.sh
deleted file mode 100755 (executable)
index 563240d..0000000
+++ /dev/null
@@ -1,31 +0,0 @@
-#!/bin/bash
-
-# Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-#    http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-SCRIPT_PATH="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-ROOT_PATH=$SCRIPT_PATH/../..
-FLATC=$ROOT_PATH/Product/out/bin/flatc
-
-if [ ! -e "$1" ]; then
-  echo "file not exists: $1"
-  exit 1
-fi
-
-JSON_FILE=$1
-JSON_FILENAME=${TFLITE_FILE##*\/}
-TFLITE_FILENAME=${TFLITE_FILENAME%\.json}.tflite
-
-$FLATC -b $ROOT_PATH/externals/tensorflow/tensorflow/contrib/lite/schema/schema.fbs $JSON_FILE
-