-
Notifications
You must be signed in to change notification settings - Fork 685
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 op hardshrink #7887
Add op hardshrink #7887
Conversation
@@ -451,6 +451,60 @@ def extra_repr(self): | |||
return inplace_str | |||
|
|||
|
|||
class Hardshrink(Module): | |||
r""" | |||
The interface is consistent with PyTorch. |
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.
这几行都去掉,可以在torch文档基础增改一下,不要照搬
[](user_op::KernelComputeContext* ctx) { \ | ||
return HardShrinkFunctor<dtype>(ctx->Attr<double>("lambd")); \ | ||
}, \ | ||
"out", "in"); \ |
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.
lazy这里支持inplace还需要参考这部分 https://github.com/Oneflow-Inc/oneflow/blob/master/oneflow/user/kernels/activation_kernels.h#L309-L313。
另外一个PR也记得改一下
def __init__(self, lambd: float = 0.5, inplace: bool = False): | ||
self.inplace = inplace | ||
self.lambd = lambd | ||
super().__init__() |
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.
先super调用父类init,再初始化inplace 和 lambd
CI failed when running job: cuda-misc. PR label automerge has been removed |
Speed stats:
|
View latest API docs preview at: https://staging.oneflow.info/docs/Oneflow-Inc/oneflow/pr/7887/ |
View latest API docs preview at: https://staging.oneflow.info/docs/Oneflow-Inc/oneflow/pr/7887/ |
View latest API docs preview at: https://staging.oneflow.info/docs/Oneflow-Inc/oneflow/pr/7887/ |
View latest API docs preview at: https://staging.oneflow.info/docs/Oneflow-Inc/oneflow/pr/7887/ |
Speed stats:
|
View latest API docs preview at: https://staging.oneflow.info/docs/Oneflow-Inc/oneflow/pr/7887/ |
Speed stats:
|
此PR完成了: