HardSwish#

  • Domain: ai.onnx

  • Since 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.       ]]

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)’]

Version History#