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 Dec 7, 2024
1 parent 1dbf2b7 commit a44954e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
15 changes: 11 additions & 4 deletions source/mlir.js
Original file line number Diff line number Diff line change
Expand Up @@ -937,10 +937,13 @@ mlir.Parser = class {
if (op.name.endsWith('.call') || op.name.endsWith('.generic_call')) {
this.parseSymbolName('callee', op.attributes);
}
if (op.name === 'arith.cmpi') {
if (op.name === 'arith.cmpi' || op.name.endsWith('.contract')) {
if (this._match('id')) {
op.attributes.push({ name: 'predicate', value: this._read() });
this._read(',');
const list = [];
do {
list.push(this._read());
} while (this._eat(',') && this._match('id'));
op.attributes.push({ name: 'predicate', value: list });
}
}
if (op.name.endsWith('.func')) {
Expand Down Expand Up @@ -1038,7 +1041,7 @@ mlir.Parser = class {
// dictionary-attribute?
// condition: start with `{`, end with `}`
if (this._match('{')) {
if (op.attributes.length === 0) {
if (op.attributes.length === 0 || (op.attributes.length === 1 && op.attributes[0].name === 'predicate')) {
this.parseAttributeDict(op.attributes);
} else {
const region = {};
Expand Down Expand Up @@ -1248,6 +1251,9 @@ mlir.Parser = class {
const value = this._parseValue();
input.type = value.type;
input.value = value.value;
if (open && this._eat(':')) {
input.type = this._parseType();
}
}
inputs.push(input);
if (!this._eat(',')) {
Expand All @@ -1267,6 +1273,7 @@ mlir.Parser = class {
this._token.value === 'i64' ||
this._token.value === 'si64' ||
this._token.value === 'f32' ||
this._token.value === 'f64' ||
this._token.value === 'index') {
return this._read('id');
}
Expand Down
7 changes: 7 additions & 0 deletions test/models.json
Original file line number Diff line number Diff line change
Expand Up @@ -3309,6 +3309,13 @@
"format": "MLIR",
"link": "https://github.com/lutzroeder/netron/issues/1044"
},
{
"type": "mlir",
"target": "toy_gemms.mlir",
"source": "https://github.com/user-attachments/files/18049387/toy_gemms.mlir.zip[toy_gemms.mlir]",
"format": "MLIR",
"link": "https://github.com/lutzroeder/netron/issues/1044"
},
{
"type": "mlir",
"target": "versioned-op-2.0.mlirbc",
Expand Down

0 comments on commit a44954e

Please sign in to comment.