torch-mlir/lib/Dialect/Torch/Utils
John Wu 46f2cb50dc
[onnx] Lower onnx.HardSigmoid to torch (#2682)
The expression for HardSigmoid in Onnx
(https://onnx.ai/onnx/operators/onnx__HardSigmoid.html): max(0, min(1,
alpha * x + beta))

is inherently different from HardSigmoid in Torch
(https://pytorch.org/docs/stable/generated/torch.nn.Hardsigmoid.html)
which is: if x < -3 -> 0
elif x > 3 -> 1
else x/6 + 1/2

That being said, it was just better to compute out the entire expression
when translating the Onnx expression to Torch mlir, which is done in
this PR. Some of the logic is shared from the files in
`DecomposeComplexOps`. Therefore, refactored some shared logic between
`DecomposeComplexOps` and `DefaultDomainGToP` and put it in a `Utils`
file.
2023-12-21 07:29:22 -08:00
..
CMakeLists.txt mlir: add missing dependency on TableGen targets (#1537) 2022-11-01 14:59:11 -05:00
TorchUpstream.cpp [Torch Dialect] Scatter reduce lowering (#1884) 2023-02-21 23:05:55 +00:00
Utils.cpp [onnx] Lower onnx.HardSigmoid to torch (#2682) 2023-12-21 07:29:22 -08:00