Skip to content

Commit

Permalink
Add MLIR test files (#1044)
Browse files Browse the repository at this point in the history
  • Loading branch information
lutzroeder committed Feb 7, 2023
1 parent d71f4d8 commit 352b5fd
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 0 deletions.
72 changes: 72 additions & 0 deletions source/mlir.js
Original file line number Diff line number Diff line change
@@ -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 change: 1 addition & 0 deletions source/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
14 changes: 14 additions & 0 deletions test/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 352b5fd

Please sign in to comment.