Skip to content
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

[Relay, TOPI] add onehot op support #3807

Closed
wants to merge 1 commit into from
Closed

Conversation

Beya2019
Copy link
Contributor

@Beya2019 Beya2019 commented Aug 20, 2019

add the onehot op support of tensorflow in Relay and Topi. Currently onehot operator supports multiple on_values/off_value/depth, and 0 <= axis < data.shape.size(). The default value: on_value=1.0, off_value=0.0, axis=-1.

@vinx13 would you be able to take a look?

@Beya2019 Beya2019 force-pushed the master branch 6 times, most recently from c91f213 to 4717383 Compare August 20, 2019 12:21
@vinx13 vinx13 self-assigned this Aug 20, 2019
topi/python/topi/transform.py Show resolved Hide resolved
topi/python/topi/transform.py Outdated Show resolved Hide resolved
python/tvm/relay/op/transform.py Show resolved Hide resolved
src/relay/op/tensor/transform.cc Outdated Show resolved Hide resolved
src/relay/op/tensor/transform.cc Show resolved Hide resolved
src/relay/op/tensor/transform.cc Show resolved Hide resolved
shape_size = shape_size * src_shape[i]
input_data = np.arange(shape_size, dtype=data_dtype).reshape((src_shape))
input = relay.var("input", relay.TensorType(input_data.shape, data_dtype))
on_value = relay.var("on_value", relay.TensorType((1,), value_dtype))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use relay.scalar_type instead

*
* \return A Tensor whose op member is the take operation
*/
inline Tensor onehot(const Tensor& a,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename to one_hot

topi/include/topi/transform.h Outdated Show resolved Hide resolved
topi/tests/python/test_topi_transform.py Outdated Show resolved Hide resolved
@jwfromm
Copy link
Contributor

jwfromm commented Aug 20, 2019

Worth noting that PR #3781 also implements this op and seems to have very similar changes.

@soiferj
Copy link
Contributor

soiferj commented Aug 20, 2019

Yeah, I implemented basically the same thing in #3781. Doesn't matter to me which one is checked in, it would just be nice to get this functionality committed :)

@Beya2019
Copy link
Contributor Author

Beya2019 commented Aug 21, 2019 via email

@soiferj
Copy link
Contributor

soiferj commented Aug 22, 2019

My change to add OneHot was just checked in - feel free to give it a try!

@vinx13
Copy link
Member

vinx13 commented Aug 23, 2019

Closed this. You can send another PR if further changes are needed. Thanks for your contribution.

@vinx13 vinx13 closed this Aug 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants