.. _l-onnx-doc-HardSwish: ========= HardSwish ========= .. contents:: :local: .. _l-onnx-op-hardswish-14: HardSwish - 14 ============== **Version** * **name**: `HardSwish (GitHub) `_ * **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. **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. **Examples** **default** :: node = onnx.helper.make_node( "HardSwish", inputs=["x"], outputs=["y"], ) x = np.random.randn(3, 4, 5).astype(np.float32) y = hardswish(x) expect(node, inputs=[x], outputs=[y], name="test_hardswish")