-
Notifications
You must be signed in to change notification settings - Fork 159
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
[luci/pass] Bug in ExpandBroadcastConstPass #14554
Comments
Tested LocallyBy running #14555, inference value matches However, it seems value testing pass does not exist and it is required.. import circle_interpreter
import numpy as np
intp = circle_interpreter.Interpreter("AddBroadcast.circle")
in_ = np.random.randn(3, 4, 4)
in_ = np.array(in_, dtype=np.float32)
out_ = intp.infer([in_])
print(out_)
intp2 = circle_interpreter.Interpreter("AddBroadcast.opt.v2.circle") # Generated model from the PR
out2_ = intp2.infer([in_])
print(out2_)
print(np.allclose(out_, out2_, atol=1e-3, rtol=1e-3)) # True
print(np.max(np.abs(out_[0] - out2_[0]))) # 0.0 |
This comment has been minimized.
This comment has been minimized.
@dayo09 , please prepare a draft with pass changes and below items for validation
|
@dayo09 one more thing, as it seems calculation branches with number of ranks, |
@seanshpark Thanks for the suggestion. I have added recipes with 2, 3, 4 ranks and added them to Please take a look at PR. If you want them to be split into several PRs, let me know. |
Done ;-D |
What?
I found a bug in ExpandBroadcastConstPass.
It's the passed applied by
onecc optimize --expand_broadcast_const
.It found out weird behavior of the optimization pass, it broadcasts a const tensor to wrong dimension.
Example
In the above example, broadcast dimension is 3. Therefore, the broadcasted value must be as below.
Inference results mismatch before/after the optimization
Most clearly, I tried inference on the circle model before/after the optimization.
And the result inference values failed to match.
Broadcasting in pytorch and tensorflow - checked!
To make sure this, I checked on broadcast result of same dimensions from pytorch and tensorflow.
Pytorch
Tensorflow
```py import tensorflow as tfx = tf.constant([[1., 2., 3.], [4., 5., 6.], [7., 8., 9.]])
y = tf.constant([[1.], [2.], [3.]])
y_ = tf.constant([[1., 1., 1.], [2., 2., 2.], [3., 3., 3.]])
subXY = x - y
subXY2 = x - y_
print(subXY)
print(subXY2) # 같다.
The text was updated successfully, but these errors were encountered: