Add hardshrink op to metal backend (#82224)

Summary:
Add hardshrink op's metal implementation to pytorch codebase

Heavily based on already existing Hardswish implementation

Test Plan:
Add two unit tests to compare the result of metal-based hardshrink function to that of the CPU implementation. Both tests pass:

{F755783049}

Differential Revision: D38152454

Pull Request resolved: https://github.com/pytorch/pytorch/pull/82224
Approved by: https://github.com/SS-JIA
This commit is contained in:
David Tsenter
2022-07-27 19:48:15 +00:00
committed by PyTorch MergeBot
parent 3a4343afc5
commit 1231194dd3
6 changed files with 203 additions and 0 deletions

View File

@ -59,6 +59,7 @@ METAL_SOURCE_LIST = [
"aten/src/ATen/native/metal/ops/MetalConvolution.mm",
"aten/src/ATen/native/metal/ops/MetalCopy.mm",
"aten/src/ATen/native/metal/ops/MetalHardswish.mm",
"aten/src/ATen/native/metal/ops/MetalHardshrink.mm",
"aten/src/ATen/native/metal/ops/MetalLeakyReLU.mm",
"aten/src/ATen/native/metal/ops/MetalNeurons.mm",
"aten/src/ATen/native/metal/ops/MetalPadding.mm",