.. _op_ai_onnx_Swish: Swish ===== - **Domain**: ``ai.onnx`` - **Since version**: 24 Swish function takes one input data (Tensor ) and produces one output data (Tensor ) of the same shape, where $Swish(x) = x \* sigmoid(alpha \* x)$. **Inputs** - **X** (*T*): Input tensor **Outputs** - **Y** (*T*): Output tensor **Attributes** - **alpha** (*float*): Coefficient to multiply with input before sigmoid. **Type Constraints** - **T**: Constrain input and output types to float tensors. Allowed types: tensor(bfloat16), tensor(double), tensor(float), tensor(float16). Examples -------- **test_cc_swish** .. code-block:: text Node: Swish(X) -> (Y) .. code-block:: text Inputs: X: shape=(2, 3), dtype=float32 [[-4., -1., 0.], [ 1., 2., 4.]] Outputs: Y: shape=(2, 3), dtype=float32 [[-0.07194484, -0.26894143, 0. ], [ 0.7310586 , 1.761594 , 3.928055 ]] **test_cc_swish_alpha** .. code-block:: text Node: Swish(X) -> (Y) Attributes: alpha = 2.0 .. code-block:: text Inputs: X: shape=(2, 3), dtype=float32 [[-4., -1., 0.], [ 1., 2., 4.]] Outputs: Y: shape=(2, 3), dtype=float32 [[-1.3414006e-03, -1.1920292e-01, 0.0000000e+00], [ 8.8079703e-01, 1.9640275e+00, 3.9986587e+00]]