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

add hardshrink kernel #500

Merged
merged 6 commits into from Sep 12, 2019
Merged

Conversation

WindQAQ
Copy link
Member

@WindQAQ WindQAQ commented Sep 11, 2019

Add hardshrink kernel: x if x < lower or x > upper else 0.

@WindQAQ
Copy link
Member Author

WindQAQ commented Sep 11, 2019

#437

Copy link
Member

@seanpmorgan seanpmorgan left a comment

Choose a reason for hiding this comment

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

Looks very good thanks as always Tzu-Wei. One request if you think it's appropriate.


#define REGISTER_HARDSHRINK_KERNELS(type) \
REGISTER_KERNEL_BUILDER( \
Name("Hardshrink").Device(DEVICE_CPU).TypeConstraint<type>("T"), \
Copy link
Member

Choose a reason for hiding this comment

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

Think we could change this to Addons>Hardshrink per tensorflow/community#126 ? It should work on the nightly and RC I believe.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wonder how to do this... I have tried to modify cc/kernels/hardshrink_op.cc and cc/ops/hardshrink_op.cc, but none of them gives the answer. I think I could just follow @tomerk's PR though.

Copy link
Member

Choose a reason for hiding this comment

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

Works for me.

Copy link
Member

@seanpmorgan seanpmorgan left a comment

Choose a reason for hiding this comment

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

Thanks again!

@seanpmorgan seanpmorgan merged commit 89415c7 into tensorflow:master Sep 12, 2019
tomerk pushed a commit to tomerk/addons that referenced this pull request Sep 17, 2019
* add hardshrink kernel
* make linter happy
facaiy pushed a commit that referenced this pull request Sep 19, 2019
* Namespaced all of the custom ops

* Updated C++ namespaces to not conflict w/ TF contrib ones

* Ran code reformatting tool

* Port bug fix in TF contrib to addons. (#497)

* Port bug fix in TF contrib to addons.

Original change at
tensorflow/tensorflow@a913689.

* Fix lint warning.

* check pass through and do the expand_dims() only if needed (#464)

* check pass through and do the expand_dims() only if needed
* add indent to the fixed line
* merge return condition to if state

* add hardshrink kernel (#500)

* add hardshrink kernel
* make linter happy

* Fixing SequenceLoss Keras incompatibility (#503)

* Fix SequenceLoss incompatibility with Keras built-in loops

* Remove debugging prints

* Change the attribute existence checking to use more pythonic way

* Replace some compat.v1 APIs by their v2 equivalent (#507)

* Replace some compat.v1 APIs by their v2 equivalent

* Fix lint error

* Add documentation for LazyAdam (#515)

* Updated hardshrink custom ops & made #ifdef names more consistent.

* Fix to undef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants