Browse Source

Update caffe2-metadata.json

Lutz Roeder 7 years ago
parent
commit
7555f461eb
15 changed files with 93 additions and 66 deletions
  1. 0 2
      src/caffe2-metadata.json
  2. 3 3
      tools/caffe
  3. 21 17
      tools/caffe2-script.py
  4. 3 3
      tools/cntk
  5. 5 3
      tools/coreml
  6. 3 3
      tools/darknet
  7. 6 4
      tools/keras
  8. 3 4
      tools/mxnet
  9. 6 5
      tools/onnx
  10. 3 1
      tools/paddle
  11. 9 8
      tools/pytorch
  12. 6 4
      tools/sklearn
  13. 5 3
      tools/tf
  14. 17 3
      tools/tflite
  15. 3 3
      tools/torch

+ 0 - 2
src/caffe2-metadata.json

@@ -1176,7 +1176,6 @@
       ],
       "outputs": [
         {
-          "description": "/Users/lutzroeder/Projects/netron/third_party/pytorch/caffe2/operators/quantized/int8_conv_op.cc",
           "name": "Y"
         }
       ],
@@ -1260,7 +1259,6 @@
       ],
       "outputs": [
         {
-          "description": "/Users/lutzroeder/Projects/netron/third_party/pytorch/caffe2/operators/quantized/int8_average_pool_op.cc",
           "name": "Y"
         }
       ],

+ 3 - 3
tools/caffe

@@ -17,13 +17,13 @@ bold() {
 git_sync() {
     mkdir -p "${third_party}"
     if [ -d "${third_party}/${1}" ]; then
-        git -C "${third_party}/${1}" fetch -p --quiet
+        git -C "${third_party}/${1}" fetch --quiet -p
         git -C "${third_party}/${1}" reset --quiet --hard origin/master
     else
         echo "Clone ${2}..."
-        git -C "${third_party}" clone --recursive ${2}
+        git -C "${third_party}" clone --quiet --recursive ${2}
     fi
-    git -C "${third_party}" submodule update --init
+    git -C "${third_party}" submodule update --quiet --init
 }
 
 clean() {

+ 21 - 17
tools/caffe2-script.py

@@ -106,38 +106,42 @@ def update_argument(schema, arg):
     return
 
 def update_input(schema, input_desc):
-    name = input_desc[0]
+    input_name = input_desc[0]
     description = input_desc[1]
     if not 'inputs' in schema:
         schema['inputs'] = []
     input_arg = None
     for current_input in schema['inputs']:
-        if 'name' in current_input and current_input['name'] == name:
+        if 'name' in current_input and current_input['name'] == input_name:
             input_arg = current_input
             break
     if not input_arg:
         input_arg = {}
-        input_arg['name'] = name
+        input_arg['name'] = input_name
         schema['inputs'].append(input_arg)
     input_arg['description'] = description
     if len(input_desc) > 2:
         return
 
-def update_output(schema, output_desc):
-    name = output_desc[0]
+def update_output(operator_name, schema, output_desc):
+    output_name = output_desc[0]
     description = output_desc[1]
     if not 'outputs' in schema:
         schema['outputs'] = []
     output_arg = None
     for current_output in schema['outputs']:
-        if 'name' in current_output and current_output['name'] == name:
+        if 'name' in current_output and current_output['name'] == output_name:
             output_arg = current_output
             break
     if not output_arg:
         output_arg = {}
-        output_arg['name'] = name
+        output_arg['name'] = output_name
         schema['outputs'].append(output_arg)
-    output_arg['description'] = description
+    if (operator_name == 'Int8Conv' or operator_name == 'Int8AveragePool') and output_name == 'Y':
+        if 'description' in output_arg:
+            del output_arg['description']
+    else:
+        output_arg['description'] = description
     if len(output_desc) > 2:
         return
 
@@ -158,26 +162,26 @@ def metadata():
     schema_map = {}
 
     for entry in json_root:
-        name = entry['name']
+        operator_name = entry['name']
         schema = entry['schema']
-        schema_map[name] = schema
+        schema_map[operator_name] = schema
 
-    for name in caffe2.python.core._GetRegisteredOperators():
-        op_schema = caffe2.python.workspace.C.OpSchema.get(name)
+    for operator_name in caffe2.python.core._GetRegisteredOperators():
+        op_schema = caffe2.python.workspace.C.OpSchema.get(operator_name)
         if op_schema:
-            if name in schema_map:
-                schema = schema_map[name]
+            if operator_name in schema_map:
+                schema = schema_map[operator_name]
             else:
                 schema = {}
-                schema_map[name] = { 'name': name, 'schema': schema }
+                schema_map[operator_name] = { 'name': operator_name, 'schema': schema }
             schema['description'] = op_schema.doc
             for arg in op_schema.args:
                 update_argument(schema, arg)
             for input_desc in op_schema.input_desc:
                 update_input(schema, input_desc)
-            if name != 'Int8ConvRelu' and name != 'Int8AveragePoolRelu':
+            if operator_name != 'Int8ConvRelu' and operator_name != 'Int8AveragePoolRelu':
                 for output_desc in op_schema.output_desc:
-                    update_output(schema, output_desc)
+                    update_output(operator_name, schema, output_desc)
             schema['support_level'] = get_support_level(os.path.dirname(op_schema.file))
 
     with io.open(json_file, 'w', newline='') as fout:

+ 3 - 3
tools/cntk

@@ -17,13 +17,13 @@ bold() {
 git_sync() {
     mkdir -p "${third_party}"
     if [ -d "${third_party}/${1}" ]; then
-        git -C "${third_party}/${1}" fetch -p --quiet
+        git -C "${third_party}/${1}" fetch --quiet -p
         git -C "${third_party}/${1}" reset --quiet --hard origin/master
     else
         echo "Clone ${2}..."
-        git -C "${third_party}" clone --recursive ${2} ${1}
+        git -C "${third_party}" clone --quiet --recursive ${2} ${1}
     fi
-    git -C "${third_party}" submodule update --init
+    git -C "${third_party}" submodule update --quiet --init
 }
 
 clean() {

+ 5 - 3
tools/coreml

@@ -26,11 +26,11 @@ bold() {
 git_sync () {
     mkdir -p "${third_party}"
     if [ -d "${third_party}/${1}" ]; then
-        git -C "${third_party}/${1}" fetch -p --quiet
+        git -C "${third_party}/${1}" fetch --quiet -p
         git -C "${third_party}/${1}" reset --quiet --hard origin/master
     else
         echo "Clone ${2}..."
-        git -C "${third_party}" clone --recursive ${2}
+        git -C "${third_party}" clone --quiet --recursive ${2}
     fi
 }
 
@@ -46,7 +46,9 @@ sync() {
 
 install() {
     bold "coreml install"
-    virtualenv --quiet -p ${python} ${virtualenv}
+    if [ ! -d "${virtualenv}" ]; then
+        virtualenv --quiet -p ${python} ${virtualenv}
+    fi
     source ${virtualenv}/bin/activate
     ${pip} install --quiet ${third_party}/${identifier}
     deactivate

+ 3 - 3
tools/darknet

@@ -17,13 +17,13 @@ bold() {
 git_sync() {
     mkdir -p "${third_party}"
     if [ -d "${third_party}/${1}" ]; then
-        git -C "${third_party}/${1}" fetch -p --quiet
+        git -C "${third_party}/${1}" fetch --quiet -p
         git -C "${third_party}/${1}" reset --quiet --hard origin/master
     else
         echo "Clone ${2}..."
-        git -C "${third_party}" clone --recursive ${2}
+        git -C "${third_party}" clone --quiet --recursive ${2}
     fi
-    git -C "${third_party}" submodule update --init
+    git -C "${third_party}" submodule update --quiet --init
 }
 
 clean() {

+ 6 - 4
tools/keras

@@ -21,13 +21,13 @@ bold() {
 git_sync() {
     mkdir -p "${third_party}"
     if [ -d "${third_party}/${1}" ]; then
-        git -C "${third_party}/${1}" fetch -p --quiet
+        git -C "${third_party}/${1}" fetch --quiet -p
         git -C "${third_party}/${1}" reset --quiet --hard origin/master
     else
         echo "Clone ${2}..."
-        git -C "${third_party}" clone --recursive ${2}
+        git -C "${third_party}" clone --quiet --recursive ${2}
     fi
-    git -C "${third_party}" submodule update --init
+    git -C "${third_party}" submodule update --quiet --init
 }
 
 clean() {
@@ -43,7 +43,9 @@ sync() {
 
 install() {
     bold "keras install"
-    virtualenv --quiet -p ${python} ${virtualenv}
+    if [ ! -d "${virtualenv}" ]; then
+        virtualenv --quiet -p ${python} ${virtualenv}
+    fi
     source ${virtualenv}/bin/activate
     ${pip} install --quiet tensorflow
     ${pip} install --quiet ${third_party}/${identifier}

+ 3 - 4
tools/mxnet

@@ -24,13 +24,12 @@ bold() {
 git_sync() {
     mkdir -p "${third_party}"
     if [ -d "${third_party}/${1}" ]; then
-        git -C "${third_party}/${1}" fetch -p --quiet
+        git -C "${third_party}/${1}" fetch --quiet -p
         git -C "${third_party}/${1}" reset --quiet --hard origin/master
     else
-        echo "Clone ${2}..."
-        git -C "${third_party}" clone --recursive ${2} ${1}
+        git -C "${third_party}" clone --quiet --recursive ${2} ${1}
     fi
-    git -C "${third_party}" submodule update --init
+    git -C "${third_party}" submodule update --quiet --init
 }
 
 clean() {

+ 6 - 5
tools/onnx

@@ -27,13 +27,12 @@ bold() {
 git_sync() {
     mkdir -p "${third_party}"
     if [ -d "${third_party}/${1}" ]; then
-        git -C "${third_party}/${1}" fetch -p --quiet
+        git -C "${third_party}/${1}" fetch --quiet -p
         git -C "${third_party}/${1}" reset --quiet --hard origin/master
     else
-        echo "Clone ${2}..."
-        git -C "${third_party}" clone --recursive ${2}
+        git -C "${third_party}" clone --quiet --recursive ${2}
     fi
-    git -C "${third_party}" submodule update --init
+    git -C "${third_party}" submodule update --quiet --init
 }
 
 clean() {
@@ -69,7 +68,9 @@ install() {
             fi
             ;;
     esac
-    virtualenv --quiet -p ${python} ${virtualenv}
+    if [ ! -d "${virtualenv}" ]; then
+        virtualenv --quiet -p ${python} ${virtualenv}
+    fi
     source ${virtualenv}/bin/activate
     ${pip} install --quiet protobuf
     export ONNX_ML=1

+ 3 - 1
tools/paddle

@@ -46,7 +46,9 @@ sync() {
 
 install() {
     bold "paddle install"
-    virtualenv --quiet -p ${python} ${virtualenv}
+    if [ ! -d "${virtualenv}" ]; then
+        virtualenv --quiet -p ${python} ${virtualenv}
+    fi
     source ${virtualenv}/bin/activate
     ${pip} install --quiet ${third_party}/${identifier}
     deactivate

+ 9 - 8
tools/pytorch

@@ -28,13 +28,12 @@ bold() {
 git_sync() {
     mkdir -p "${third_party}"
     if [ -d "${third_party}/${1}" ]; then
-        git -C "${third_party}/${1}" fetch -p --quiet
-        git -C "${third_party}/${1}" reset --quiet --hard origin/master
+        git -C "${third_party}/${1}" fetch --quiet -p
+        git -C "${third_party}/${1}" reset --quiet --hard origin/$(git -C "${third_party}/${1}" rev-parse --abbrev-ref HEAD)
     else
-        echo "Clone ${2}..."
-        git -C "${third_party}" clone --recursive ${2}
+        git -C "${third_party}" clone --quiet --recursive ${2}
     fi
-    git -C "${third_party}" submodule update --init
+    git -C "${third_party}" submodule update --quiet --init
 }
 
 clean() {
@@ -62,12 +61,14 @@ EOS
             fi
             ;;
     esac
-    virtualenv --quiet -p ${python} ${virtualenv}
+    if [ ! -d "${virtualenv}" ]; then
+        virtualenv --quiet -p ${python} ${virtualenv}
+    fi
     source ${virtualenv}/bin/activate
     pushd "${third_party}/pytorch" > /dev/null
     ${pip} install --quiet future leveldb numpy protobuf pydot python-gflags pyyaml scikit-image setuptools six hypothesis typing tqdm
     ${pip} install --quiet torchvision
-    ${python} setup.py install --quiet
+    ${pip} install --quiet .
     popd > /dev/null
     deactivate
 }
@@ -79,9 +80,9 @@ schema() {
 }
 
 metadata() {
-    bold "pytorch metadata"
     source ${virtualenv}/bin/activate
     pushd ${tools} > /dev/null
+    bold "pytorch metadata"
     ${python} pytorch-script.py metadata
     bold "caffe2 metadata"
     ${python} caffe2-script.py metadata

+ 6 - 4
tools/sklearn

@@ -22,13 +22,13 @@ bold() {
 git_sync() {
     mkdir -p "${third_party}"
     if [ -d "${third_party}/${1}" ]; then
-        git -C "${third_party}/${1}" fetch -p --quiet
+        git -C "${third_party}/${1}" fetch --quiet -p
         git -C "${third_party}/${1}" reset --quiet --hard origin/master
     else
         echo "Clone ${2}..."
-        git -C "${third_party}" clone --recursive ${2} ${1}
+        git -C "${third_party}" clone --quiet --recursive ${2} ${1}
     fi
-    git -C "${third_party}" submodule update --init
+    git -C "${third_party}" submodule update --quiet --init
 }
 
 sync() {
@@ -41,7 +41,9 @@ sync() {
 
 install() {
     bold "sklearn install"
-    virtualenv --quiet -p ${python} ${virtualenv}
+    if [ ! -d "${virtualenv}" ]; then
+        virtualenv --quiet -p ${python} ${virtualenv}
+    fi
     source ${virtualenv}/bin/activate
     ${pip} install --quiet Cython
     ${pip} install --quiet numpy

+ 5 - 3
tools/tf

@@ -27,11 +27,11 @@ bold() {
 git_sync () {
     mkdir -p "${third_party}"
     if [ -d "${third_party}/${1}" ]; then
-        git -C "${third_party}/${1}" fetch -p --quiet
+        git -C "${third_party}/${1}" fetch --quiet -p
         git -C "${third_party}/${1}" reset --quiet --hard origin/master
     else
         echo "Clone ${2}..."
-        git -C "${third_party}" clone --recursive ${2}
+        git -C "${third_party}" clone --quiet --recursive ${2}
     fi
 }
 
@@ -48,7 +48,9 @@ sync() {
 
 install() {
     bold "tf install"
-    virtualenv --quiet -p ${python} ${virtualenv}
+    if [ ! -d "${virtualenv}" ]; then
+        virtualenv --quiet -p ${python} ${virtualenv}
+    fi
     source ${virtualenv}/bin/activate
     ${pip} install --quiet protobuf
     deactivate

+ 17 - 3
tools/tflite

@@ -20,11 +20,11 @@ bold() {
 git_sync () {
     mkdir -p "${third_party}"
     if [ -d "${third_party}/${1}" ]; then
-        git -C "${third_party}/${1}" fetch -p --quiet
+        git -C "${third_party}/${1}" fetch --quiet -q
         git -C "${third_party}/${1}" reset --quiet --hard origin/master
     else
         echo "Clone ${2}..."
-        git -C "${third_party}" clone --recursive ${2}
+        git -C "${third_party}" clone --quiet --recursive ${2}
     fi
 }
 
@@ -42,12 +42,26 @@ sync() {
 
 install() {
     bold "flatbuffers install"
+    case "$(uname)" in
+        "Linux")
+            if [ -z "$(which cmake)" ]; then
+                sudo apt install cmake
+            fi
+            ;;
+        "Darwin")
+            if [ -z "$(which cmake)" ]; then
+                brew install cmake
+            fi
+            ;;
+    esac
     echo "Build flatbuffers..."
     pushd "${third_party}/flatbuffers" > /dev/null
     cmake -G "Unix Makefiles"
     make
     popd > /dev/null
-    virtualenv --quiet -p ${python} ${virtualenv}
+    if [ ! -d "${virtualenv}" ]; then
+        virtualenv --quiet -p ${python} ${virtualenv}
+    fi
 }
 
 schema() {

+ 3 - 3
tools/torch

@@ -17,13 +17,13 @@ bold() {
 git_sync() {
     mkdir -p "${third_party}"
     if [ -d "${third_party}/${1}" ]; then
-        git -C "${third_party}/${1}" fetch -p --quiet
+        git -C "${third_party}/${1}" fetch --quiet -p
         git -C "${third_party}/${1}" reset --quiet --hard origin/master
     else
         echo "Clone ${2}..."
-        git -C "${third_party}" clone --recursive ${2} ${1}
+        git -C "${third_party}" clone --quiet --recursive ${2} ${1}
     fi
-    git -C "${third_party}" submodule update --init
+    git -C "${third_party}" submodule update --quiet --init
 }
 
 clean() {