-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add mindir
format support.
#1227
base: main
Are you sure you want to change the base?
Conversation
@Ethan-Chen-plus can you provide some context:
|
9a4785e
to
1a817ad
Compare
1f388bc
to
0cfad16
Compare
994aca4
to
0de981a
Compare
PS I:\netron> npm run validate
eslint
pylint
test
gguf/phi-2.Q2_K.gguf
onnx/candy.onnx
keras/1151.4.keras
coreml/Exermote.mlmodel
pytorch/alexnet.ptl
pytorch/DCGAN2.pt
tf/conv-layers.pb.zip
tflite/mobilenet_v1_0.75_160_quantized.tflite
tflite/squeezenet.tflite I have updated my code, please review. |
@Ethan-Chen-plus can you provide some context:
|
66d40fe
to
19e4123
Compare
8abf19b
to
dc7a947
Compare
@lutzroeder Thank you again and we have updated our code. And let me introduce some background infomation:
The user base for the MindIR format primarily comprises researchers, developers, and enterprises needing to deploy AI models across multiple hardware platforms. Given its compatibility with diverse hardware including Ascend AI processors, GPUs, and CPUs, MindIR is particularly well-suited for applications that require deployment both in the cloud and on edge devices. For instance, MindIR can be utilized in Huawei's Atlas 200/300/500 inference products, which are specifically designed for edge AI processing scenarios. -Why is a new format needed given there are many similar formats? Compared to other similar IR formats such as ONNX and AIR, MindIR presents unique advantages and application scenarios. ONNX (Open Neural Network Exchange) is a universal format designed for the expression of machine learning models, primarily used for model transfer between different frameworks or on inference engines like TensorRT. AIR (Ascend Intermediate Representation), defined by Huawei, is an open file format tailored for machine learning to better accommodate Huawei AI processors, typically used for inference tasks on Ascend 310. MindIR, on the other hand, is a functional IR based on graph representation. It not only defines an extensible graph structure and operator IR representations but also eliminates model discrepancies across different backends. It is generally used for cross-platform inference tasks, such as executing inference on Ascend 310, GPUs, and MindSpore Lite for models trained on Ascend 910. |
514284f
to
0250d3e
Compare
@lutzroeder Hello.👋 I noticed that eslint failed. Could you please tell me which config file eslint is using? I'll make the necessary fixes based on that config file. Thank you! |
952b6ed
to
2781faa
Compare
Workflow requires approval, thank you🤗 |
b448189
to
1d342d8
Compare
d9a23ec
to
5028ef6
Compare
Workflow requires approval, thank you again🤗 |
1a3b633
to
dc51e07
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Compared to other similar IR formats such as ...
This format looks very similar to ONNX. Instead of defining a new format, can this be accomplished by using metadata
extensions in ONNX to augment with additional information.
There is also an existing MindSpore Lite format and a dozen other formats that look similar in principle. Consider a path that leverages existing formats or standards instead of creating another duplicate format that needs to be maintained.
@@ -734,7 +734,8 @@ base.Metadata = class { | |||
'ptl', 't7', | |||
'dlc', 'uff', 'armnn', | |||
'mnn', 'ms', 'ncnn', 'om', 'tm', 'mge', 'tmfile', 'tnnproto', 'xmodel', 'kmodel', 'rknn', | |||
'tar', 'zip' | |||
'tar', 'zip', | |||
'mindir', 'mind_ir' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove for now for testing.
@@ -0,0 +1,713 @@ | |||
export const protobuf = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to mindir-proto.js
. Sync to latest and regenerate this file using ./tools/mindir sync schema
.
@@ -0,0 +1,252 @@ | |||
syntax = "proto2"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should not be added to the repro and instead downloaded to a location in ./third_party/source/mindspore/mindspore/core/proto/mind_ir.proto
.
sync() { | ||
echo "mind_ir sync" | ||
mkdir -p "./third_party/source/mindspore/mindspore/mindir/schema/" | ||
curl --silent --location --output "./third_party/source/mindspore/mindspore/mindir/schema/mind_ir-metadata.json" "https://raw.githubusercontent.com/Ethan-Chen-plus/mindir/main/mind_ir-metadata.json" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The metadata file should not be downloaded from an external location and instead be updated in place as part of ./tools/mindir metadata
.
@@ -5455,6 +5455,34 @@ view.ModelFactoryService = class { | |||
this.register('./modular', ['.maxviz']); | |||
this.register('./cambricon', ['.cambricon']); | |||
this.register('./weka', ['.model']); | |||
this.register('./mslite', ['.ms']); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolve incorrect merge.
* The Model class represents a mind_ir model and contains information about the model's format, name, and graphs. | ||
* The Graph class represents a graph within a mind_ir model and contains information about the graph's inputs, outputs, and nodes. | ||
*/ | ||
export const protobuf = {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove, this should not be needed.
const identifier = context.identifier; | ||
const extension = identifier.split('.').pop().toLowerCase(); | ||
if (extension === "mindir") { | ||
return 'mind_ir'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has changed in more recent versions. Sync to latest.
} | ||
}; | ||
|
||
mind_ir.Parameter = class { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed in latest. Parameter
to Argument
and Argument
to Value
.
|
||
constructor(message) { | ||
super(message); | ||
this.name = 'SnapML Model Load Error.'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix error message.
|
||
constructor(context, attribute) { | ||
|
||
this._name = attribute.name; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Attribute
has been removed in latest and replaced with using Argument
to represent attribtues.
🤗👋Hi! We have added our
.mindir
format. Please review our commit.