瀏覽代碼

Add MLIR test files (#1044)

Lutz Roeder 3 年之前
父節點
當前提交
352b5fd976
共有 3 個文件被更改,包括 87 次插入0 次删除
  1. 72 0
      source/mlir.js
  2. 1 0
      source/view.js
  3. 14 0
      test/models.json

+ 72 - 0
source/mlir.js

@@ -0,0 +1,72 @@
+
+var mlir = {};
+var text = require('./text');
+
+mlir.ModelFactory = class {
+
+    match(context) {
+        const stream = context.stream;
+        if (stream) {
+            const reader = text.Reader.open(stream, 2048);
+            for (;;) {
+                const line = reader.read();
+                if (line === undefined) {
+                    break;
+                }
+                if (line.indexOf('module ') !== -1) {
+                    return 'mlir';
+                }
+            }
+        }
+        return null;
+    }
+
+    open(context) {
+        const stream = context.stream;
+        const decoder = text.Decoder.open(stream);
+        new mlir.Parser(decoder);
+        throw new mlir.Error('MLIR support is not implemented.');
+    }
+};
+
+mlir.Model = class {
+
+    constructor() {
+        this._format = 'MLIR';
+        this._graphs = [];
+    }
+
+    get format() {
+        return this._format;
+    }
+
+    get graphs() {
+        return this._graphs;
+    }
+};
+
+mlir.Tokenizer = class {
+
+    constructor(decoder) {
+        this._decoder = decoder;
+    }
+};
+
+mlir.Parser = class {
+
+    constructor(decoder) {
+        this._tokenizer = new mlir.Tokenizer(decoder);
+    }
+};
+
+mlir.Error = class extends Error {
+
+    constructor(message) {
+        super(message);
+        this.name = 'Error loading MLIR model.';
+    }
+};
+
+if (typeof module !== 'undefined' && typeof module.exports === 'object') {
+    module.exports.ModelFactory = mlir.ModelFactory;
+}

+ 1 - 0
source/view.js

@@ -4533,6 +4533,7 @@ view.ModelFactoryService = class {
         this.register('./nnef', [ '.nnef', '.dat' ]);
         this.register('./cambricon', [ '.cambricon' ]);
         this.register('./onednn', [ '.json']);
+        this.register('./mlir', [ '.mlir']);
     }
 
     register(id, factories, containers) {

+ 14 - 0
test/models.json

@@ -2772,6 +2772,20 @@
     "source":   "https://raw.githubusercontent.com/dotnet/machinelearning-samples/61b428c746f39069a9d1d92f9e0f819e6beb30f3/samples/csharp/end-to-end-apps/DeepLearning_ObjectDetection_Onnx/OnnxObjectDetectionE2EAPP/ML/MLNETModel/TinyYoloModel.zip",
     "format":   "ML.NET v1.0.27701.1"
   },
+  {
+    "type":     "mlir",
+    "target":   "examples.mnist_xla.mlir",
+    "source":   "https://github.com/lutzroeder/netron/files/10672271/examples.mnist_xla.mlir.zip[examples.mnist_xla.mlir]",
+    "error":    "MLIR support is not implemented.",
+    "link":     "https://github.com/lutzroeder/netron/issues/1044"
+  },
+  {
+    "type":     "mlir",
+    "target":   "issue_1043.mlir",
+    "source":   "https://github.com/lutzroeder/netron/files/10672270/issue_1043.mlir.zip[issue_1043.mlir]",
+    "error":    "MLIR support is not implemented.",
+    "link":     "https://github.com/lutzroeder/netron/issues/1044"
+  },
   {
     "type":     "mnn",
     "target":   "blazeface.mnn",