Skip to content

Commit

Permalink
Add MLIR test file (#1044)
Browse files Browse the repository at this point in the history
  • Loading branch information
lutzroeder committed Nov 2, 2024
1 parent 8652f63 commit e552c5c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 8 deletions.
23 changes: 16 additions & 7 deletions source/mlir.js
Original file line number Diff line number Diff line change
Expand Up @@ -1074,13 +1074,17 @@ mlir.Parser = class {
this._current.type !== '}' &&
this._current.type !== mlir.TokenType.IDENTIFIER &&
this._current.type !== mlir.TokenType.STRING_LITERAL) {
const value = this._eat(mlir.TokenType.VALUE_ID);
if (value) {
if (this._match(mlir.TokenType.VALUE_ID)) {
const value = this._eat(mlir.TokenType.VALUE_ID);
inputs.push(value.value);
} else if (this._match(mlir.TokenType.DENSE)) {
const value = this._eat(mlir.TokenType.DENSE);
inputs.push(value.value);
} else if (this._match(mlir.TokenType.INTEGER_LITERAL)) {
const value = this._eat(mlir.TokenType.INTEGER_LITERAL);
inputs.push(value.value);
} else {
const dense = this._eat(mlir.TokenType.DENSE);
inputs.push(dense.value);
return inputs;
throw new mlir.Error(`Unexpected token '${this._current.type}' ${this._tokenizer.location()}`);
}
this._eat(',');
}
Expand Down Expand Up @@ -1145,7 +1149,12 @@ mlir.Parser = class {
const attributes = new Map();
if (this._eat('{')) {
while (!this._eat('}')) {
const name = this._read(mlir.TokenType.IDENTIFIER).value;
let name = null;
if (this._match(mlir.TokenType.IDENTIFIER)) {
name = this._read(mlir.TokenType.IDENTIFIER).value;
} else {
name = this._read(mlir.TokenType.STRING_LITERAL).value;
}
if (this._eat('=')) {
let value = '';
let openingCount = 0;
Expand Down Expand Up @@ -1188,7 +1197,7 @@ mlir.Parser = class {
} else if (this._match(mlir.TokenType.ATTRIBUTE_ALIAS)) {
args.push(this._eat(mlir.TokenType.ATTRIBUTE_ALIAS).value);
} else {
throw new mlir(`Unexpected token '${this._current}.`);
throw new mlir.Error(`Unexpected token '${this._current}.`);
}
}
}
Expand Down
10 changes: 9 additions & 1 deletion test/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -3122,7 +3122,7 @@
"target": "mlp_haiku.mlir",
"source": "https://github.com/user-attachments/files/17260022/mlp_haiku.mlir.zip[mlp_haiku.mlir]",
"format": "MLIR",
"error": "Cannot read properties of null (reading 'value')",
"error": "Unexpected token '=' at 3:63.",
"link": "https://github.com/lutzroeder/netron/issues/1044"
},
{
Expand All @@ -3141,6 +3141,14 @@
"error": "Invalid file content. File contains MLIR bytecode data.",
"link": "https://github.com/lutzroeder/netron/issues/1044"
},
{
"type": "mlir",
"target": "torch_mlir_3429.mlir",
"source": "https://github.com/user-attachments/files/17605115/torch_mlir_3429.mlir.zip[torch_mlir_3429.mlir]",
"format": "MLIR",
"error": "Unexpected token 'KEYWORD' at 8:34.",
"link": "https://github.com/lutzroeder/netron/issues/1044"
},
{
"type": "mnn",
"target": "blazeface.mnn",
Expand Down

0 comments on commit e552c5c

Please sign in to comment.