HardSwish#
Domain:
ai.onnxSince version: 22
HardSwish takes one input data (Tensor ) and produces one output data (Tensor ) where the HardSwish function, y = x * max(0, min(1, alpha * x + beta)) = x * HardSigmoid (x), where alpha = 1/6 and beta = 0.5, is applied to the tensor elementwise.
Inputs
X (T): Input tensor
Outputs
Y (T): Output tensor
Type Constraints
T: Constrain input and output types to float tensors. Allowed types: tensor(bfloat16), tensor(double), tensor(float), tensor(float16).
Examples#
test_cc_hardswish
Node:
HardSwish(X) -> (Y)
Inputs:
X: shape=(2, 3), dtype=float32
[[-4., -1., 0.],
[ 1., 2., 4.]]
Outputs:
Y: shape=(2, 3), dtype=float32
[[-0. , -0.3333333, 0. ],
[ 0.6666667, 1.6666667, 4. ]]
test_cc_supported_dtype_HardSwish_BFLOAT16
Node:
HardSwish(X) -> (Y)
Inputs:
X: shape=(7,), dtype=bfloat16
[-4, -3, -1, 0, 1, 3, 4]
Outputs:
Y: shape=(7,), dtype=bfloat16
[-0, -0, -0.333984, 0, 0.667969, 3, 4]
test_cc_supported_dtype_HardSwish_FLOAT16
Node:
HardSwish(X) -> (Y)
Inputs:
X: shape=(7,), dtype=float16
[-4., -3., -1., 0., 1., 3., 4.]
Outputs:
Y: shape=(7,), dtype=float16
[-0. , -0. , -0.3333, 0. , 0.6665, 3. , 4. ]
Differences with previous version (14)#
SchemaDiff: HardSwish (domain 'ai.onnx')
old version: 14
new version: 22
breaking: no
Type constraints:
changed ‘T’: added types: [‘tensor(bfloat16)’]