Copy input shape for batchedMatMulOp instead of append #405
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If you look a bit up in the diff of
op_math.go
you'll seeouterX := x[:len(x)-2]
. Taking a range from a slice and then appending to it will override the original slice instead of copying it into a new slice. Not very obvious but that's how it works. This change does a copy so that the shape of the input node doesn't get altered.I looked into
slice.Clone()
but returning a slice to the pool that I appended to didn't feel right. Manually callingBorrowInts()
creates a lot of clutter. It would be nice if there was a function to clone+append in the tensor package to do this. But for now I chose this approach. However, it isn't clear ifouterX
can contain more than 1 element. If it doesn't, then I could simplify it some more.This is a result of #404 but don't close it yet. There are still some other issues I'm having that I'm still figuring out.