-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d71f4d8
commit 352b5fd
Showing
3 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters