Skip to content

Commit e552c5c

Browse files
committed
Add MLIR test file (#1044)
1 parent 8652f63 commit e552c5c

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

source/mlir.js

+16-7
Original file line numberDiff line numberDiff line change
@@ -1074,13 +1074,17 @@ mlir.Parser = class {
10741074
this._current.type !== '}' &&
10751075
this._current.type !== mlir.TokenType.IDENTIFIER &&
10761076
this._current.type !== mlir.TokenType.STRING_LITERAL) {
1077-
const value = this._eat(mlir.TokenType.VALUE_ID);
1078-
if (value) {
1077+
if (this._match(mlir.TokenType.VALUE_ID)) {
1078+
const value = this._eat(mlir.TokenType.VALUE_ID);
1079+
inputs.push(value.value);
1080+
} else if (this._match(mlir.TokenType.DENSE)) {
1081+
const value = this._eat(mlir.TokenType.DENSE);
1082+
inputs.push(value.value);
1083+
} else if (this._match(mlir.TokenType.INTEGER_LITERAL)) {
1084+
const value = this._eat(mlir.TokenType.INTEGER_LITERAL);
10791085
inputs.push(value.value);
10801086
} else {
1081-
const dense = this._eat(mlir.TokenType.DENSE);
1082-
inputs.push(dense.value);
1083-
return inputs;
1087+
throw new mlir.Error(`Unexpected token '${this._current.type}' ${this._tokenizer.location()}`);
10841088
}
10851089
this._eat(',');
10861090
}
@@ -1145,7 +1149,12 @@ mlir.Parser = class {
11451149
const attributes = new Map();
11461150
if (this._eat('{')) {
11471151
while (!this._eat('}')) {
1148-
const name = this._read(mlir.TokenType.IDENTIFIER).value;
1152+
let name = null;
1153+
if (this._match(mlir.TokenType.IDENTIFIER)) {
1154+
name = this._read(mlir.TokenType.IDENTIFIER).value;
1155+
} else {
1156+
name = this._read(mlir.TokenType.STRING_LITERAL).value;
1157+
}
11491158
if (this._eat('=')) {
11501159
let value = '';
11511160
let openingCount = 0;
@@ -1188,7 +1197,7 @@ mlir.Parser = class {
11881197
} else if (this._match(mlir.TokenType.ATTRIBUTE_ALIAS)) {
11891198
args.push(this._eat(mlir.TokenType.ATTRIBUTE_ALIAS).value);
11901199
} else {
1191-
throw new mlir(`Unexpected token '${this._current}.`);
1200+
throw new mlir.Error(`Unexpected token '${this._current}.`);
11921201
}
11931202
}
11941203
}

test/models.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -3122,7 +3122,7 @@
31223122
"target": "mlp_haiku.mlir",
31233123
"source": "https://github.com/user-attachments/files/17260022/mlp_haiku.mlir.zip[mlp_haiku.mlir]",
31243124
"format": "MLIR",
3125-
"error": "Cannot read properties of null (reading 'value')",
3125+
"error": "Unexpected token '=' at 3:63.",
31263126
"link": "https://github.com/lutzroeder/netron/issues/1044"
31273127
},
31283128
{
@@ -3141,6 +3141,14 @@
31413141
"error": "Invalid file content. File contains MLIR bytecode data.",
31423142
"link": "https://github.com/lutzroeder/netron/issues/1044"
31433143
},
3144+
{
3145+
"type": "mlir",
3146+
"target": "torch_mlir_3429.mlir",
3147+
"source": "https://github.com/user-attachments/files/17605115/torch_mlir_3429.mlir.zip[torch_mlir_3429.mlir]",
3148+
"format": "MLIR",
3149+
"error": "Unexpected token 'KEYWORD' at 8:34.",
3150+
"link": "https://github.com/lutzroeder/netron/issues/1044"
3151+
},
31443152
{
31453153
"type": "mnn",
31463154
"target": "blazeface.mnn",

0 commit comments

Comments
 (0)