-
Notifications
You must be signed in to change notification settings - Fork 129
Conversation
lib/backend.ts
Outdated
@@ -32,10 +33,9 @@ export interface SessionHandler { | |||
/** | |||
* Resolves the operator from the name; backend specific |
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.
nit: I think the comment would be - resolve the operator from the name and the opset version ?
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.
will fix
['Less', '', '7+', () => new binaryOps.WebGLBinaryOp(NUMBER_TYPES, binaryOps.glslLess(), undefined, 'bool')], | ||
['Log', '', '6+', () => new unaryOps.WebGLUnaryOp(FLOAT_TYPES, unaryOps.glslLog())], | ||
['MatMul', '', '1+', () => new WebGLMatMul()], | ||
['MaxPool', '', '1-7', () => new WebGLMaxPool()], // TODO: support new attributes for MaxPool-8 and MaxPool-10 |
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.
Developer-centric question - I am guessing the way we support different versions of an op (where there is majority overlap across versions) is we just extend the current working class and override appropriate methods so as to align with the new spec ?
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.
there are 2 ways.
one is to extend the existing implementation, if the new version is compatible with the old one according to the spec. (eg. add a new optional attribute, whose default value is the same of the old behavior)
one is to have different implementation, if the new version has a different behavior, or it is necessary to do so due to performance concern.
} | ||
|
||
/** | ||
* Domain of an opset, it can be an empty string(default value, represent for ai.onnx), or 'ai.onnx.ml' |
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.
can the domain be ai.onnx OR default value (empty string) to represent the ai.onnx domain ?
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.
empty string means ai.onnx as in domain. the string 'ai.onnx'
is not a valid value here
lib/opset.ts
Outdated
} | ||
} | ||
} | ||
throw new TypeError(`cannot resolve operator '${opType}'`); |
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.
can error thrown also mention requested opset version of the operator cannot be resolved ?
['And', '', '7+', () => new CpuBinaryOp(['bool'], (e1, e2) => (e1 && e2))], | ||
['ArgMax', '', '1+', () => new CpuArgMax()], | ||
['Asin', '', '7+', () => new unaryOps.CpuUnaryOp(NUMBER_TYPES, unaryOps.asin)], | ||
['Atan', '', '7+', () => new unaryOps.CpuUnaryOp(NUMBER_TYPES, unaryOps.atan)], |
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.
How were the ResolveRules created for the very first time? How can we make sure it is accurate? Do we need to maintain any script(s) used to generate them ?
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 is a pain point. one possible way is to grab more test cases from other place.
meanwhile, I am writing a script to generate the operator support table from data (to replace /docs/operators.md). that helps but still not a guarantee of 100% accuracy.
At a high level, the changes look okay. Looking at the build failures it looks to me that there might be issues concerning the array of |
I think the final solution is to make sure we have a good test coverage. Maybe we can leverage some test cases from onnxruntime. |
['Atan', '', '7+', () => new unaryOps.CpuUnaryOp(NUMBER_TYPES, unaryOps.atan)], | ||
['AveragePool', '', '7+', () => new CpuAveragePool()], | ||
['BatchNormalization', '', '7+', () => new CpuBatchNormalization()], | ||
['Ceil', '', '6+', () => new unaryOps.CpuUnaryOp(NUMBER_TYPES, unaryOps.ceil)], |
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.
Also, how can we ensure potentially a bad commit that could have conflicting operator resolves possible ?
For example, Ceil 6+ could be mapped to an op, let's say Ceil 10 has has a different op implementation, but the developer forgets to change 6+
to 6-9
. In that case, multiple op resolves are possible.
One way is to run a script at check-in time but we will have to maintain that...
['Sqrt', '', '6+', () => new unaryOps.CpuUnaryOp(NUMBER_TYPES, unaryOps.sqrt)], | ||
['Squeeze', '', '1+', () => new CpuSqueeze()], | ||
['Sub', '', '7+', () => new CpuBinaryOp(NUMBER_TYPES, (e1, e2) => (e1 - e2))], | ||
['Sum', '', '6+', () => new CpuSum()], // TODO: support multidirectional broadcast for Sum-8 |
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.
Do we need to throw exception when it looks like broadcasting support maybe required in the implementation (since it support 6+) ?
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 exception is thrown anyway. currently it will be thrown due to checkInput failure. the only difference is the error message
There are a couple of nits left out from being resolved/addressed-
|
This change updates the behavior how to resolve a
Graph.Node
to anOperator
in a session's initialization stage.7
,7+
)