tanh
Classes
TanhOperator
TanhOperator(op: AirOperator, model: AirModel, platform: SocPlatform, prefix: str = 'aot', attributes: dict[str, str] = {})
TANH operator.
This operator computes the tanh 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
make_tanh_lut
make_tanh_lut(input_scale: float, input_zero_point: int, output_scale: float, output_zero_point: int) -> np.ndarray
Build a 256-entry int8 → int8 LUT for quantized Tanh, iterating over q in [-128..127].
compute_params_s16
Compute the input_multiplier and input_left_shift parameters for int16 Tanh.
Parameters:
Returns:
-
AirFixedPointScale(AirFixedPointScale) –The input_multiplier and input_left_shift parameters.