(l-onnx-doc-HardSwish)= # HardSwish (l-onnx-op-hardswish-22)= ## HardSwish - 22 ### Version - **name**: [HardSwish (GitHub)](https://github.com/onnx/onnx/blob/main/docs/Operators.md#HardSwish) - **domain**: `main` - **since_version**: `22` - **function**: `True` - **support_level**: `SupportType.COMMON` - **shape inference**: `True` This version of the operator has been available **since version 22**. ### Summary 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. #### Function Body The function definition for this operator. ``` < domain: "", opset_import: ["" : 22] > HardSwish (X) => (Y) { HS_X = HardSigmoid (X) Y = Mul (X, HS_X) } ``` ### Inputs - **X** (heterogeneous) - **T**: Input tensor ### Outputs - **Y** (heterogeneous) - **T**: Output tensor ### Type Constraints * **T** in ( `tensor(bfloat16)`, `tensor(double)`, `tensor(float)`, `tensor(float16)` ): Constrain input and output types to float tensors. ```{toctree} text_diff_HardSwish_14_22 ``` (l-onnx-op-hardswish-14)= ## HardSwish - 14 ### Version - **name**: [HardSwish (GitHub)](https://github.com/onnx/onnx/blob/main/docs/Operators.md#HardSwish) - **domain**: `main` - **since_version**: `14` - **function**: `True` - **support_level**: `SupportType.COMMON` - **shape inference**: `True` This version of the operator has been available **since version 14**. ### Summary 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. #### Function Body The function definition for this operator. ``` < domain: "", opset_import: ["" : 14] > HardSwish (X) => (Y) { HS_X = HardSigmoid (X) Y = Mul (X, HS_X) } ``` ### Inputs - **X** (heterogeneous) - **T**: Input tensor ### Outputs - **Y** (heterogeneous) - **T**: Output tensor ### Type Constraints * **T** in ( `tensor(double)`, `tensor(float)`, `tensor(float16)` ): Constrain input and output types to float tensors.