-
Notifications
You must be signed in to change notification settings - Fork 785
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
Ignore error from extending ONNX Tensor #439
Conversation
src/utils/tensor.js
Outdated
@@ -36,6 +36,7 @@ const DataTypeMap = new Map([ | |||
|
|||
const ONNXTensor = ONNX.Tensor; | |||
|
|||
/** @ts-ignore Base constructors must all have the same return type. ts(2510) */ |
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.
/** @ts-ignore Base constructors must all have the same return type. ts(2510) */ | |
// @ts-ignore |
I don't see anywhere in the ts docs where this format (+ comments) is supported?
Also, in v3, We won't need to extend from the base tensor class, and that will be a more permanent solution
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.
Hey @xenova, it won't work like that - tsc
will simply strip a // ...
comment and we end up with a Tensor type declaration file that continues to trigger this lib check error, whereas /* ... */
comments are kept and therefore the lib check error disappears (don't ask me who comes up with these decisions 😅)
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.
Oh that's interesting... 👀 In that case, it might be worth making the update to not extend from the base tensor class now, since there are many other typing issues which are showing. See here to see what I'm referring to.
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.
Nice, you implemented every method that was used from ONNX.Tensor
into transformers Tensor
class? I like that, it keeps everything a bit closer to this code and easier to understand.
I guess it may break semver/backwards-compatibility a bit if people on v2 still use ONNX.Tensor methods that a maybe not re-implemented yet? So at least for v3 its a good deal.
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.
Fortunately, there shouldn't be any backwards-compatibility issues since our Tensor
reimplements all the same functionality/properties, and is usable wherever an ORT tensor is allowed.
With onnxruntime-web >=1.17.0, this will be an issue (but that isn't a problem here since we're frozen at 1.14.0.
Would you be interested in making the PR? If not, I can adapt my v3 code and make a standalone PR in the meantime.
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.
@xenova Thank you for the info! Currently I'm low on time, so I would appreciate if you can do it.
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
Very nice 👍 |
Superseded by #451 |
Fixes #437
(it requires a
npm run typegen
andnpm publish
)