Kaynağa Gözat

Update mslite.js (#600)

Lutz Roeder 5 yıl önce
ebeveyn
işleme
6c2e6a3ec2
5 değiştirilmiş dosya ile 1447 ekleme ve 2468 silme
  1. 1423 2386
      source/mslite-schema.js
  2. 15 4
      source/mslite.js
  3. 1 1
      source/view.js
  4. 7 77
      test/models.json
  5. 1 0
      tools/mslite

Dosya farkı çok büyük olduğundan ihmal edildi
+ 1423 - 2386
source/mslite-schema.js


+ 15 - 4
source/mslite.js

@@ -10,7 +10,7 @@ mslite.ModelFactory = class {
         if (stream.length >= 8) {
             const buffer = stream.peek(8);
             const reader = new flatbuffers.Reader(buffer);
-            if (reader.identifier === 'MSL1') {
+            if (reader.identifier === '' || reader.identifier === 'MSL1' || reader.identifier === 'MSL2') {
                 return true;
             }
         }
@@ -19,11 +19,20 @@ mslite.ModelFactory = class {
 
     open(context) {
         return context.require('./mslite-schema').then(() => {
+            const buffer = context.stream.peek();
+            const reader = new flatbuffers.Reader(buffer);
+            switch (reader.identifier) {
+                case 'MSL2':
+                    throw new mslite.Error('MSL2 format is not supported.');
+                case 'MSL1':
+                    throw new mslite.Error('MSL1 format is deprecated.', false);
+                case '':
+                    throw new mslite.Error('MSL0 format is deprecated.', false);
+            }
+            /*
             let model = null;
             try {
                 mslite.schema = flatbuffers.get('mslite').mindspore.schema;
-                const buffer = context.stream.peek();
-                const reader = new flatbuffers.Reader(buffer);
                 model = mslite.schema.MetaGraph.create(reader);
             }
             catch (error) {
@@ -33,6 +42,7 @@ mslite.ModelFactory = class {
             return mslite.Metadata.open(context).then((metadata) => {
                 return new mslite.Model(metadata, model);
             });
+            */
         });
     }
 };
@@ -620,9 +630,10 @@ mslite.Utility = class {
 
 mslite.Error = class extends Error {
 
-    constructor(message) {
+    constructor(message, context) {
         super(message);
         this.name = 'Error loading MindSpore Lite model.';
+        this.context = context === false ? false : true;
     }
 };
 

+ 1 - 1
source/view.js

@@ -1594,7 +1594,7 @@ view.ModelFactoryService = class {
                         return model;
                     }).catch((error) => {
                         const text = " in '" + context.identifier + "'.";
-                        if (error && !error.message.endsWith(text)) {
+                        if (error && !error.message.endsWith(text) && (error.context === undefined || error.context === true)) {
                             error.message = error.message.replace(/\.$/, '') + text;
                         }
                         errors.push(error);

+ 7 - 77
test/models.json

@@ -2640,87 +2640,17 @@
   },
   {
     "type":   "mslite",
-    "target": "conv_autopad.onnx.r1.1.ms",
-    "source": "https://github.com/YvetteLaw/test/releases/download/v1.0/conv_autopad.onnx.r1.1.ms",
-    "format": "MindSpore Lite v1.1.0",
-    "link":   "https://github.com/mindspore-ai/mindspore"
-  },
-  {
-    "type":   "mslite",
-    "target": "deeplab_mobilenetv2_513.tflite.r1.1.ms",
-    "source": "https://github.com/YvetteLaw/test/releases/download/v1.0/deeplab_mobilenetv2_513.tflite.r1.1.ms",
-    "format": "MindSpore Lite v1.1.0",
-    "link":   "https://github.com/mindspore-ai/mindspore"
-  },
-  {
-    "type":   "mslite",
-    "target": "densenet.tflite.r1.1.ms",
-    "source": "https://github.com/YvetteLaw/test/releases/download/v1.0/densenet.tflite.r1.1.ms",
-    "format": "MindSpore Lite v1.1.0",
-    "link":   "https://github.com/mindspore-ai/mindspore"
-  },
-  {
-    "type":   "mslite",
-    "target": "inception_resnet_v2.tflite.r1.1.ms",
-    "source": "https://github.com/YvetteLaw/test/releases/download/v1.0/inception_resnet_v2.tflite.r1.1.ms",
-    "format": "MindSpore Lite v1.1.0",
-    "link":   "https://github.com/mindspore-ai/mindspore"
-  },
-  {
-    "type":   "mslite",
-    "target": "mobilenet_v1_1.0_224.tflite.r1.1.ms",
-    "source": "https://github.com/YvetteLaw/test/releases/download/v1.0/mobilenet_v1_1.0_224.tflite.r1.1.ms",
-    "format": "MindSpore Lite v1.1.0",
-    "link":   "https://github.com/mindspore-ai/mindspore"
-  },
-  {
-    "type":   "mslite",
-    "target": "squeezenet1.1.onnx.r1.1.ms",
-    "source": "https://github.com/YvetteLaw/test/releases/download/v1.0/squeezenet1.1.onnx.r1.1.ms",
-    "format": "MindSpore Lite v1.1.0",
-    "link":   "https://github.com/mindspore-ai/mindspore"
-  },
-  {
-    "type":   "mslite",
-    "target": "ssd.onnx.r1.1.ms",
-    "source": "https://github.com/YvetteLaw/test/releases/download/v1.0/ssd.onnx.r1.1.ms",
-    "format": "MindSpore Lite v1.1.0",
-    "link":   "https://github.com/mindspore-ai/mindspore"
-  },
-  {
-    "type":   "mslite",
-    "target": "super-resolution-10.onnx.r1.1.ms",
-    "source": "https://github.com/YvetteLaw/test/releases/download/v1.0/super-resolution-10.onnx.r1.1.ms",
-    "format": "MindSpore Lite v1.1.0",
-    "link":   "https://github.com/mindspore-ai/mindspore"
-  },
-  {
-    "type":   "mslite",
-    "target": "deeplabv3.ms",
-    "source": "https://github.com/YvetteLaw/test/releases/download/v1.0/deeplabv3.ms",
-    "format": "MindSpore Lite v1.0.0",
-    "link":   "https://github.com/mindspore-ai/mindspore"
-  },
-  {
-    "type":   "mslite",
-    "target": "residual_distill_res18_cifar10_bs_1_update.ms",
-    "source": "https://github.com/YvetteLaw/test/releases/download/v1.0/residual_distill_res18_cifar10_bs_1_update.ms",
-    "format": "MindSpore Lite v1.0.0",
-    "link":   "https://github.com/mindspore-ai/mindspore"
-  },
-  {
-    "type":   "mslite",
-    "target": "ssd.ms",
-    "source": "https://github.com/YvetteLaw/test/releases/download/v1.0/ssd.ms",
-    "format": "MindSpore Lite v1.0.0",
-    "link":   "https://github.com/mindspore-ai/mindspore"
+    "target": "blazeface_quant.ms",
+    "source": "https://github.com/lutzroeder/netron/files/6097966/blazeface_quant.ms.zip[blazeface_quant.ms]",
+    "error":  "MSL0 format is deprecated.",
+    "link":   "https://github.com/lutzroeder/netron/issues/600"
   },
   {
     "type":   "mslite",
     "target": "control_flow_ut_while_0122.ms",
-    "source": "https://github.com/YvetteLaw/test/releases/download/v1.0/control_flow_ut_while_0122.ms",
-    "format": "MindSpore Lite v1.1.0",
-    "link":   "https://github.com/mindspore-ai/mindspore"
+    "source": "https://github.com/lutzroeder/netron/files/6097971/control_flow_ut_while_0122.ms.zip[control_flow_ut_while_0122.ms]",
+    "error":  "MSL1 format is deprecated.",
+    "link":   "https://github.com/lutzroeder/netron/issues/600"
   },
   {
     "type":   "mxnet",

+ 1 - 0
tools/mslite

@@ -13,6 +13,7 @@ sync() {
     mkdir -p "./third_party/source/mindspore/mindspore/lite/schema/"
     curl --silent --location --output "./third_party/source/mindspore/mindspore/lite/schema/model.fbs" "https://github.com/mindspore-ai/mindspore/blob/master/mindspore/lite/schema/model.fbs?raw=true"
     curl --silent --location --output "./third_party/source/mindspore/mindspore/lite/schema/ops.fbs" "https://github.com/mindspore-ai/mindspore/blob/master/mindspore/lite/schema/ops.fbs?raw=true"
+    curl --silent --location --output "./third_party/source/mindspore/mindspore/lite/schema/ops_types.fbs" "https://github.com/mindspore-ai/mindspore/blob/master/mindspore/lite/schema/ops_types.fbs?raw=true"
 }
 
 schema() {

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor