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 hard sigmoid #4043

Merged
merged 6 commits into from
Jan 4, 2021
Merged

Add hard sigmoid #4043

merged 6 commits into from
Jan 4, 2021

Conversation

MARD1NO
Copy link
Contributor

@MARD1NO MARD1NO commented Dec 25, 2020

增加 hardsigmoid 算子
暂时没做inplace
Pytorch实现有误区, 边界值依旧有梯度,做不了inplace操作
Paddle的边界值则没有梯度

概述

实现hardsigmiod算子,对标Pytorch的 torch.nn.Hardsigmoid
图片

功能 CheckList

注意 : 功能复选框均为可选项,若未选择,说明理由即可。例如:该 Op 由 Python 接口拼接而成,因此无 SetBatchAxisInferFn Op 注册;再比如:该 Op 无输入,因此无 SetInputArgModifyFn

模板中自带的复选框可留空,但是不能删除。可根据实际情况增加复选框选项。

Op

  • Op SetBatchAxisInferFn
  • Op SetGetSbpFn
  • Op SetInputArgModifyFn
  • Op 反向梯度注册

Kernel

注册浮点类型, 仅仅针对前向注册 int整数类型

  • CPU in:float32

  • CPU in:float64

  • GPU in:float32

  • GPU in:float64

  • GPU in:float16

Python Wrapper

  • Python API 参数检查及异常提示
  • 接口注释
  • Example 

测试

  • 单机单卡 CPU Test Case
  • 单机单卡 GPU Test Case
  • 单机多卡 CPU Test Case
  • 单机多卡 GPU Test Case
  • 分布式 CPU Test Case
  • 分布式 GPU Test Case

GPU 有效带宽

理论带宽:

 Device to Device Bandwidth, 1 Device(s)
 PINNED Memory Transfers
   Transfer Size (Bytes)	Bandwidth(GB/s)
   32000000			378.4

实际带宽:


I1230 17:54:02.273802 233663 kernel.cpp:89] PROFILER::KERNEL::CUDA_MEMORY_BANDWIDTH op_name: HardSigmoid_1 elapsed(ms): 0.177888 memory_size(Byte): 50331648 bandwidth(GB/s): 263.508

折合成百分比为69.64%

PR Checklist

  • PR 标题语句通畅,明确表达 PR 内容,适合直接作为新版本发布时的 changelog
  • 代码格式化
  • 已经本地编译通过
  • 已本地针对改动测试
  • 已添加 type 标签:(填写 type 标签名,如 bug, enhancement, purge, feature, documentation)
  • 已添加 component 标签:(填写 component 标签名,如 op, system, eager, build, xla, python, ci, test, tooling, onnx)
  • Draft 转正式 PR 前已请人 Review

@MARD1NO MARD1NO requested a review from Ldpe2G December 30, 2020 09:56
@MARD1NO MARD1NO marked this pull request as ready for review December 31, 2020 01:09
@oneflow-ci-bot oneflow-ci-bot removed their request for review December 31, 2020 03:54
@oneflow-ci-bot oneflow-ci-bot removed their request for review December 31, 2020 07:58
@MARD1NO MARD1NO requested a review from oneflow-ci-bot January 4, 2021 03:40
@oneflow-ci-bot oneflow-ci-bot removed their request for review January 4, 2021 06:25
@oneflow-ci-bot oneflow-ci-bot merged commit 7d4ffee into master Jan 4, 2021
@oneflow-ci-bot oneflow-ci-bot deleted the dev_hardsigmoid branch January 4, 2021 06:25
liujuncheng pushed a commit that referenced this pull request Jun 3, 2021
* add cpu version

* add hardsigmoid kernel

* add test case

* fix

Former-commit-id: 7d4ffee
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.

3 participants