hard_swish
Classes
HardSwishOperator
HardSwishOperator(op: AirOperator, model: AirModel, platform: SocPlatform, prefix: str = 'aot', attributes: dict[str, str] = {})
HARD_SWISH operator.
This operator computes the hard swish activation function on the input tensor.
Parameters:
-
(opAirOperator) –The AIR operator to wrap.
-
(modelAirModel) –The AIR model.
-
(platformSocPlatform) –The target platform for code generation.
-
(prefixstr, default:'aot') –Prefix for generated code files. Defaults to "aot".
-
(attributesdict[str, str], default:{}) –Attributes for template values. Defaults to {}.
Functions
compute_values
emit
Generate the source code for the operator.
Parameters:
-
(save_pathPath) –Path to save the generated code.
Functions
compute_prescale
make_hardswish_lut_s8
make_hardswish_lut_s8(input_scale: float, input_zero_point: int, output_scale: float, output_zero_point: int) -> np.ndarray
Build a 256-entry int8 → int8 LUT for HardSwish, iterating over q in [-128,127].
Parameters:
-
(input_scalefloat) –Scale of the input tensor.
-
(input_zero_pointint) –Zero point of the input tensor.
-
(output_scalefloat) –Scale of the output tensor.
-
(output_zero_pointint) –Zero point of the output tensor.
Returns:
-
ndarray–np.ndarray: The generated LUT.