-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[AutoDiff] [API] Fix bug in Tensor.reshaped VJP #21923
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
Conversation
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 catch, thanks!
071dbf7
to
c39a853
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.
FYI: use expectEqual
when you can, and the first argument is expected to be the expected value.
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.
If I recall, pure GPE can't handle expectEqual
(because expectEqual
opaquely calls Tensor.==
and isn't inlined by GPE). That's also why test/TensorFlowRuntime/tensor.swift
doesn't call Tensor.==
directly.
Shall we use expectEqual
anyways? I feel it especially makes sense for this test file.
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.
It can now, because #tfop
has an ABI now.
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:
- We generally don't use
self.
unless it's required. - It'd be more efficient if you make it capture
self.shapeTensor
explicitly instead of capturingself
. I'd write this as
{ [shape = shapeTensor] v in
return v.reshaped(toShape: shape)
}
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.
FYI: there are definitely more places where we could use explicit captures instead of capturing self
for efficiency. We should change those places at some point!
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.
Depends on whether self
is practically a larger tensor that the result you get from operations on self
:)
c39a853
to
7886508
Compare
@swift-ci please test tensorflow |
Also adds test.
7886508
to
881d954
Compare
@swift-ci please test tensorflow |
1 similar comment
@swift-ci please test tensorflow |
Introduced in #21740. Added a test.