-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[TOPI] LRN & L2norm Operator #1051
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
|
cc @sxjscience can you do another round of review? |
|
Need to work on the project in Amazon. I'll give a deep dive into how to implement it better on Thursday. For now, I think we need to support L2Normalization with arbitrary axis. |
|
@sxjscience , shall I follow https://www.tensorflow.org/api_docs/python/tf/nn/l2_normalize for l2norm implementation? |
|
@sxjscience , I have added arbitrary axis support for L2norm. Could you please help to review further. |
|
I think it's good now. We can refactor the implementation later. |
tqchen
left a comment
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 seems that we can also make lrn axis invariant by providing an axis argument for to specify the channel, can we do that?
|
|
||
| rxk = tvm.reduce_axis((0, size), name='rxk') | ||
| sqr_sum = tvm.compute((b, c, h, w), lambda i, l, j, k: tvm.sum( | ||
| tvm.power(pad_data[i, l + rxk, j, k], 2.0), |
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 not use power to calculate the square, instead use x* x
topi/tests/python/test_topi_lrn.py
Outdated
| sqr_sum[i, j, k, l] = sqr_sum[i, j, k, l] + \ | ||
| (a_np[i, j, k, l + rxl] * \ | ||
| a_np[i, j, k, l + rxl]) | ||
| for i in range(axis0): |
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.
use broadcasting semantics, instead of the loop
|
Thanks for improving the code during the review process, this is now merged! |
LRN operator for caffe alexnet model to use with onnx frontend
@tqchen @sxjscience your review comments from #1000 is addressed here. #1000 got accidentally closed.