chop.nn.quantized.modules

Contents

chop.nn.quantized.modules#

chop.nn.quantized.modules.attention#

class chop.nn.quantized.modules.attention.BertSelfAttentionInteger(config, q_config: dict = None, out_q_config: dict = None, position_embedding_type=None, bias=True, floor=False, output_tensor_only=False)[source]#

Bases: _BertSelfAttentionBase

__init__(config, q_config: dict = None, out_q_config: dict = None, position_embedding_type=None, bias=True, floor=False, output_tensor_only=False) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

chop.nn.quantized.modules.attention_head#

class chop.nn.quantized.modules.attention_head.BertSelfAttentionHeadInteger(config, q_config: dict = None)[source]#

Bases: _BertSelfAttentionHeadBase

__init__(config, q_config: dict = None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(query_layer: Tensor, key_layer: Tensor, value_layer: Tensor, attention_mask: FloatTensor | None = None) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

chop.nn.quantized.modules.batch_norm1d#

class chop.nn.quantized.modules.batch_norm1d.BatchNorm1dInteger(num_features: int, eps: float = 1e-05, momentum: float = 0.1, affine: bool = True, track_running_stats: bool = True, device=None, dtype=None, config=None)[source]#

Bases: _BatchNorm1dBase

__init__(num_features: int, eps: float = 1e-05, momentum: float = 0.1, affine: bool = True, track_running_stats: bool = True, device=None, dtype=None, config=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

chop.nn.quantized.modules.batch_norm2d#

class chop.nn.quantized.modules.batch_norm2d.BatchNorm2dInteger(num_features: int, eps: float = 1e-05, momentum: float = 0.1, affine: bool = True, track_running_stats: bool = True, device=None, dtype=None, config=None)[source]#

Bases: _BatchNorm2dBase

__init__(num_features: int, eps: float = 1e-05, momentum: float = 0.1, affine: bool = True, track_running_stats: bool = True, device=None, dtype=None, config=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.batch_norm2d.BatchNorm2dBinary(num_features: int, eps: float = 1e-05, momentum: float = 0.1, affine: bool = True, track_running_stats: bool = True, device=None, dtype=None, config=None)[source]#

Bases: _BatchNorm2dBase

__init__(num_features: int, eps: float = 1e-05, momentum: float = 0.1, affine: bool = True, track_running_stats: bool = True, device=None, dtype=None, config=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

chop.nn.quantized.modules.conv1d#

class chop.nn.quantized.modules.conv1d.Conv1dInteger(in_channels: int, out_channels: int, kernel_size: int | Tuple[int], stride: int | Tuple[int] = 1, padding: str | int | Tuple[int] = 0, dilation: int | Tuple[int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config=None)[source]#

Bases: _Conv1dBase

__init__(in_channels: int, out_channels: int, kernel_size: int | Tuple[int], stride: int | Tuple[int] = 1, padding: str | int | Tuple[int] = 0, dilation: int | Tuple[int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.conv1d.Conv1dMinifloatDenorm(in_channels: int, out_channels: int, kernel_size: int | Tuple[int], stride: int | Tuple[int] = 1, padding: str | int | Tuple[int] = 0, dilation: int | Tuple[int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config: dict = None)[source]#

Bases: _Conv1dBase

__init__(in_channels: int, out_channels: int, kernel_size: int | Tuple[int], stride: int | Tuple[int] = 1, padding: str | int | Tuple[int] = 0, dilation: int | Tuple[int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config: dict = None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.conv1d.Conv1dLog(in_channels: int, out_channels: int, kernel_size: int | Tuple[int], stride: int | Tuple[int] = 1, padding: str | int | Tuple[int] = 0, dilation: int | Tuple[int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config: dict = None)[source]#

Bases: _Conv1dBase

__init__(in_channels: int, out_channels: int, kernel_size: int | Tuple[int], stride: int | Tuple[int] = 1, padding: str | int | Tuple[int] = 0, dilation: int | Tuple[int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config: dict = None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.conv1d.Conv1dMinifloatIEEE(in_channels: int, out_channels: int, kernel_size: int | Tuple[int], stride: int | Tuple[int] = 1, padding: str | int | Tuple[int] = 0, dilation: int | Tuple[int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config: dict = None)[source]#

Bases: _Conv1dBase

__init__(in_channels: int, out_channels: int, kernel_size: int | Tuple[int], stride: int | Tuple[int] = 1, padding: str | int | Tuple[int] = 0, dilation: int | Tuple[int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config: dict = None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.conv1d.Conv1dBlockFP(in_channels: int, out_channels: int, kernel_size: int | Tuple[int], stride: int | Tuple[int] = 1, padding: str | int | Tuple[int] = 0, dilation: int | Tuple[int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config: dict = None)[source]#

Bases: _Conv1dBase

__init__(in_channels: int, out_channels: int, kernel_size: int | Tuple[int], stride: int | Tuple[int] = 1, padding: str | int | Tuple[int] = 0, dilation: int | Tuple[int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config: dict = None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.conv1d.Conv1dBlockMinifloat(in_channels: int, out_channels: int, kernel_size: int | Tuple[int], stride: int | Tuple[int] = 1, padding: str | int | Tuple[int] = 0, dilation: int | Tuple[int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config: dict = None)[source]#

Bases: _Conv1dBase

__init__(in_channels: int, out_channels: int, kernel_size: int | Tuple[int], stride: int | Tuple[int] = 1, padding: str | int | Tuple[int] = 0, dilation: int | Tuple[int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config: dict = None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.conv1d.Conv1dBlockLog(in_channels: int, out_channels: int, kernel_size: int | Tuple[int], stride: int | Tuple[int] = 1, padding: int | Tuple[int] | str = 0, dilation: int | Tuple[int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config: dict = None)[source]#

Bases: _Conv1dBase

__init__(in_channels: int, out_channels: int, kernel_size: int | Tuple[int], stride: int | Tuple[int] = 1, padding: int | Tuple[int] | str = 0, dilation: int | Tuple[int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config: dict = None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.conv1d.Conv1dBinary(in_channels: int, out_channels: int, kernel_size: int | Tuple[int], stride: int | Tuple[int] = 1, padding: str | int | Tuple[int] = 0, dilation: int | Tuple[int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config=None)[source]#

Bases: _Conv1dBase

__init__(in_channels: int, out_channels: int, kernel_size: int | Tuple[int], stride: int | Tuple[int] = 1, padding: str | int | Tuple[int] = 0, dilation: int | Tuple[int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.conv1d.Conv1dTernary(in_channels: int, out_channels: int, kernel_size: int | Tuple[int], stride: int | Tuple[int] = 1, padding: int | Tuple[int] | str = 0, dilation: int | Tuple[int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config=None)[source]#

Bases: _Conv1dBase

__init__(in_channels: int, out_channels: int, kernel_size: int | Tuple[int], stride: int | Tuple[int] = 1, padding: int | Tuple[int] | str = 0, dilation: int | Tuple[int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

chop.nn.quantized.modules.conv2d#

class chop.nn.quantized.modules.conv2d.Conv2dInteger(in_channels: int, out_channels: int, kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] = 1, padding: str | int | Tuple[int, int] = 0, dilation: int | Tuple[int, int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config=None)[source]#

Bases: _Conv2dBase

__init__(in_channels: int, out_channels: int, kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] = 1, padding: str | int | Tuple[int, int] = 0, dilation: int | Tuple[int, int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.conv2d.Conv2dMinifloatDenorm(in_channels: int, out_channels: int, kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] = 1, padding: str | int | Tuple[int, int] = 0, dilation: int | Tuple[int, int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config: dict = None)[source]#

Bases: _Conv2dBase

__init__(in_channels: int, out_channels: int, kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] = 1, padding: str | int | Tuple[int, int] = 0, dilation: int | Tuple[int, int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config: dict = None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.conv2d.Conv2dMinifloatIEEE(in_channels: int, out_channels: int, kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] = 1, padding: str | int | Tuple[int, int] = 0, dilation: int | Tuple[int, int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config: dict = None)[source]#

Bases: _Conv2dBase

__init__(in_channels: int, out_channels: int, kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] = 1, padding: str | int | Tuple[int, int] = 0, dilation: int | Tuple[int, int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config: dict = None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.conv2d.Conv2dLog(in_channels: int, out_channels: int, kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] = 1, padding: str | int | Tuple[int, int] = 0, dilation: int | Tuple[int, int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config: dict = None)[source]#

Bases: _Conv2dBase

__init__(in_channels: int, out_channels: int, kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] = 1, padding: str | int | Tuple[int, int] = 0, dilation: int | Tuple[int, int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config: dict = None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.conv2d.Conv2dBlockFP(in_channels: int, out_channels: int, kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] = 1, padding: str | int | Tuple[int, int] = 0, dilation: int | Tuple[int, int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config: dict = None)[source]#

Bases: _Conv2dBase

__init__(in_channels: int, out_channels: int, kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] = 1, padding: str | int | Tuple[int, int] = 0, dilation: int | Tuple[int, int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config: dict = None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.conv2d.Conv2dBlockMinifloat(in_channels: int, out_channels: int, kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] = 1, padding: str | int | Tuple[int, int] = 0, dilation: int | Tuple[int, int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config: dict = None)[source]#

Bases: _Conv2dBase

__init__(in_channels: int, out_channels: int, kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] = 1, padding: str | int | Tuple[int, int] = 0, dilation: int | Tuple[int, int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config: dict = None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.conv2d.Conv2dBlockLog(in_channels: int, out_channels: int, kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] = 1, padding: int | Tuple[int, int] | str = 0, dilation: int | Tuple[int, int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config: dict = None)[source]#

Bases: _Conv2dBase

__init__(in_channels: int, out_channels: int, kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] = 1, padding: int | Tuple[int, int] | str = 0, dilation: int | Tuple[int, int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config: dict = None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.conv2d.Conv2dBinary(in_channels: int, out_channels: int, kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] = 1, padding: str | int | Tuple[int, int] = 0, dilation: int | Tuple[int, int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config=None)[source]#

Bases: _Conv2dBase

__init__(in_channels: int, out_channels: int, kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] = 1, padding: str | int | Tuple[int, int] = 0, dilation: int | Tuple[int, int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.conv2d.Conv2dBinaryScaling(in_channels: int, out_channels: int, kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] = 1, padding: str | int | Tuple[int, int] = 0, dilation: int | Tuple[int, int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config=None)[source]#

Bases: _Conv2dBase

Binary scaling variant of the conv2d transformation layer.

  • “bypass”: Bypass quantization for standard linear transformation.

  • “data_in_stochastic”, “bias_stochastic”, “weight_stochastic”: Stochastic settings.

  • “data_in_bipolar”, “bias_bipolar”, “weight_bipolar”: Bipolar settings.

  • “binary_training”: Apply binary scaling during training.

__init__(in_channels: int, out_channels: int, kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] = 1, padding: str | int | Tuple[int, int] = 0, dilation: int | Tuple[int, int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config=None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.conv2d.Conv2dBinaryResidualSign(in_channels: int, out_channels: int, kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] = 1, padding: str | int | Tuple[int, int] = 0, dilation: int | Tuple[int, int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config=None)[source]#

Bases: _Conv2dBase

Binary conv2d layer with redisual sign variant of the linear transformation layer.

  • “bypass”: Bypass quantization for standard linear transformation.

  • “data_in_stochastic”, “bias_stochastic”, “weight_stochastic”: Stochastic settings.

  • “data_in_bipolar”, “bias_bipolar”, “weight_bipolar”: Bipolar settings.

  • “binary_training”: Apply binary scaling during training.

  • “data_in_levels”: The num of residual layers to use.

  • “data_in_residual_sign” : Apply residual sign on input

__init__(in_channels: int, out_channels: int, kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] = 1, padding: str | int | Tuple[int, int] = 0, dilation: int | Tuple[int, int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config=None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.conv2d.Conv2dTernary(in_channels: int, out_channels: int, kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] = 1, padding: str | int | Tuple[int, int] = 0, dilation: int | Tuple[int, int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config=None)[source]#

Bases: _Conv2dBase

__init__(in_channels: int, out_channels: int, kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] = 1, padding: str | int | Tuple[int, int] = 0, dilation: int | Tuple[int, int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.conv2d.Conv2dLUT(config: None, in_channels: int, out_channels: int, kernel_size: int | tuple, stride: int | tuple = 1, padding: int | tuple = 0, dilation: int | tuple = 1, groups: int | tuple = 1, bias: bool = True, padding_mode: str = 'zeros', trainer_type: ~typing.Type[~chop.nn.quantizers.LUTNet.BaseTrainer.BaseTrainer] = <class 'chop.nn.quantizers.LUTNet.BaseTrainer.LagrangeTrainer'>, mask_builder_type: ~typing.Type[~chop.nn.quantizers.LUTNet.MaskBase.MaskBase] = <class 'chop.nn.quantizers.LUTNet.MaskBase.MaskExpanded'>, device: str = None)[source]#

Bases: Module

mask_builder: MaskBase#
__init__(config: None, in_channels: int, out_channels: int, kernel_size: int | tuple, stride: int | tuple = 1, padding: int | tuple = 0, dilation: int | tuple = 1, groups: int | tuple = 1, bias: bool = True, padding_mode: str = 'zeros', trainer_type: ~typing.Type[~chop.nn.quantizers.LUTNet.BaseTrainer.BaseTrainer] = <class 'chop.nn.quantizers.LUTNet.BaseTrainer.LagrangeTrainer'>, mask_builder_type: ~typing.Type[~chop.nn.quantizers.LUTNet.MaskBase.MaskBase] = <class 'chop.nn.quantizers.LUTNet.MaskBase.MaskExpanded'>, device: str = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

in_channels: int#
out_channels: int#
kernel_size: tuple#
stride: tuple#
padding: bool#
dilation: tuple#
mask_builder_type: Type[MaskBase]#
groups: tuple#
bias: Tensor#
padding_mode: str#
k: int#
input_dim: tuple#
device: str | None#
input_mask: Tensor#
tables_count: int#
trainer: BaseTrainer#
forward(input: Tensor, targets: tensor = None, initalize: bool = False)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

pre_initialize()[source]#
update_initialized_weights()[source]#
class chop.nn.quantized.modules.conv2d.Conv2DLogicNets(in_channels: int, out_channels: int, kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] = 1, padding: str | int | Tuple[int, int] = 0, dilation: int | Tuple[int, int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config=None)[source]#

Bases: _Conv2dBase

__init__(in_channels: int, out_channels: int, kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] = 1, padding: str | int | Tuple[int, int] = 0, dilation: int | Tuple[int, int] = 1, groups: int = 1, bias: bool = True, padding_mode: str = 'zeros', device=None, dtype=None, config=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

table_lookup(connected_input: Tensor, input_perm_matrix: Tensor, bin_output_states: Tensor) Tensor[source]#
lut_forward(x: Tensor) Tensor[source]#
construct_mask_index()[source]#
calculate_truth_tables()[source]#
forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

encode(input: Tensor) Tensor[source]#
decode(input: Tensor) Tensor[source]#
math_forward(input: Tensor) Tensor[source]#

chop.nn.quantized.modules.gelu#

class chop.nn.quantized.modules.gelu.GELUInteger(inplace: bool = False, config: dict = None)[source]#

Bases: _GELUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

bypass = None#
class chop.nn.quantized.modules.gelu.GELUMinifloatDenorm(inplace: bool = False, config: dict = None)[source]#

Bases: _GELUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.gelu.GELUMinifloatIEEE(inplace: bool = False, config: dict = None)[source]#

Bases: _GELUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.gelu.GELULog(inplace: bool = False, config: dict = None)[source]#

Bases: _GELUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.gelu.GELUBlockFP(inplace: bool = False, config: dict = None)[source]#

Bases: _GELUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.gelu.GELUBlockMinifloat(inplace: bool = False, config: dict = None)[source]#

Bases: _GELUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.gelu.GELUBlockLog(inplace: bool = False, config: dict = None)[source]#

Bases: _GELUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.gelu.GELUBinary(inplace: bool = False, config: dict = None)[source]#

Bases: _GELUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

bypass = None#
class chop.nn.quantized.modules.gelu.GELUTernary(inplace: bool = False, config: dict = None)[source]#

Bases: _GELUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

bypass = None#

chop.nn.quantized.modules.group_norm#

class chop.nn.quantized.modules.group_norm.GroupNormInteger(num_groups: int, num_channels: int, eps: float = 1e-05, affine: bool = True, device=None, dtype=None, config=None)[source]#

Bases: _GroupNormBase

__init__(num_groups: int, num_channels: int, eps: float = 1e-05, affine: bool = True, device=None, dtype=None, config=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

chop.nn.quantized.modules.instance_norm2d#

class chop.nn.quantized.modules.instance_norm2d.InstanceNorm2dInteger(num_features: int, eps: float = 1e-05, momentum: float = 0.1, affine: bool = False, track_running_stats: bool = False, device=None, dtype=None, config=None)[source]#

Bases: _InstanceNorm2dBase

__init__(num_features: int, eps: float = 1e-05, momentum: float = 0.1, affine: bool = False, track_running_stats: bool = False, device=None, dtype=None, config=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

chop.nn.quantized.modules.layer_norm#

class chop.nn.quantized.modules.layer_norm.LayerNormInteger(normalized_shape, eps: float = 1e-05, elementwise_affine: bool = False, bias: bool = False, device=None, dtype=None, config=None)[source]#

Bases: _LayerNormBase

__init__(normalized_shape, eps: float = 1e-05, elementwise_affine: bool = False, bias: bool = False, device=None, dtype=None, config=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

chop.nn.quantized.modules.linear#

class chop.nn.quantized.modules.linear.LinearInteger(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None, config=None, out_config=None, floor=False)[source]#

Bases: _LinearBase

__init__(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None, config=None, out_config=None, floor=False) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.linear.LinearMinifloatDenorm(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None, config=None)[source]#

Bases: _LinearBase

__init__(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None, config=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.linear.LinearMinifloatIEEE(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None, config=None)[source]#

Bases: _LinearBase

__init__(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None, config=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.linear.LinearLog(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None, config=None)[source]#

Bases: _LinearBase

__init__(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None, config=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.linear.LinearBlockFP(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None, config=None)[source]#

Bases: _LinearBase

__init__(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None, config=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.linear.LinearBlockMinifloat(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None, config=None)[source]#

Bases: _LinearBase

__init__(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None, config=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.linear.LinearBlockLog(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None, config=None)[source]#

Bases: _LinearBase

__init__(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None, config=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.linear.LinearBinary(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None, config=None)[source]#

Bases: _LinearBase

__init__(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None, config=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.linear.LinearBinaryScaling(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None, config=None)[source]#

Bases: _LinearBase

Binary scaling variant of the linear transformation layer.

  • “bypass”: Bypass quantization for standard linear transformation.

  • “data_in_stochastic”, “bias_stochastic”, “weight_stochastic”: Stochastic settings.

  • “data_in_bipolar”, “bias_bipolar”, “weight_bipolar”: Bipolar settings.

  • “binary_training”: Apply binary scaling during training.

__init__(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None, config=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.linear.LinearTernary(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None, config=None)[source]#

Bases: _LinearBase

__init__(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None, config=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.linear.LinearBinaryResidualSign(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None, config=None)[source]#

Bases: _LinearBase

Binary Linear layer with redisual sign variant of the linear transformation layer.

  • “bypass”: Bypass quantization for standard linear transformation.

  • “data_in_stochastic”, “bias_stochastic”, “weight_stochastic”: Stochastic settings.

  • “data_in_bipolar”, “bias_bipolar”, “weight_bipolar”: Bipolar settings.

  • “binary_training”: Apply binary scaling during training.

  • “data_in_levels”: The num of residual layers to use.

  • “data_in_residual_sign” : Apply residual sign on input

__init__(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None, config=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.linear.LinearLUT(config: None, in_features: int, out_features: int, mask_builder_type: ~typing.Type[~chop.nn.quantizers.LUTNet.MaskBase.MaskBase] = <class 'chop.nn.quantizers.LUTNet.MaskBase.MaskExpanded'>, trainer_type: ~typing.Type[~chop.nn.quantizers.LUTNet.BaseTrainer.BaseTrainer] = <class 'chop.nn.quantizers.LUTNet.BaseTrainer.LagrangeTrainer'>, bias: bool = True, device: str = None)[source]#

Bases: Module

mask_builder: MaskBase#
__init__(config: None, in_features: int, out_features: int, mask_builder_type: ~typing.Type[~chop.nn.quantizers.LUTNet.MaskBase.MaskBase] = <class 'chop.nn.quantizers.LUTNet.MaskBase.MaskExpanded'>, trainer_type: ~typing.Type[~chop.nn.quantizers.LUTNet.BaseTrainer.BaseTrainer] = <class 'chop.nn.quantizers.LUTNet.BaseTrainer.LagrangeTrainer'>, bias: bool = True, device: str = None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

in_features: int#
out_features: int#
mask_builder_type: Type[MaskBase]#
input_mask: Tensor#
tables_count: int#
trainer: BaseTrainer#
forward(input: Tensor, targets: tensor = None, initalize: bool = False)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

pre_initialize()[source]#
update_initialized_weights()[source]#
class chop.nn.quantized.modules.linear.LinearLogicNets(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None, config=None, activation_module=None, input_layers=None, output_layers=None)[source]#

Bases: _LinearBase

__init__(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None, config=None, activation_module=None, input_layers=None, output_layers=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

table_lookup(connected_input: Tensor, input_perm_matrix: Tensor, bin_output_states: Tensor) Tensor[source]#
lut_forward(x: Tensor) Tensor[source]#
construct_mask_index()[source]#
calculate_truth_tables()[source]#
math_forward(input: Tensor) Tensor[source]#
set_fused(fused: bool)[source]#
run_layers(input: Tensor, layers) Tensor[source]#
encode(input: Tensor) Tensor[source]#
decode(input: Tensor) Tensor[source]#
forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.linear.LinearMXIntHardware(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None, config=None, out_config=None)[source]#

Bases: _LinearBase

__init__(in_features: int, out_features: int, bias: bool = True, device=None, dtype=None, config=None, out_config=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

chop.nn.quantized.modules.max_pool2d#

class chop.nn.quantized.modules.pool2d.AvgPool2dInteger(kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] | None = None, padding: int | Tuple[int, int] = 0, ceil_mode: bool = False, count_include_pad: bool = True, divisor_override: int | None = None, config=None)[source]#

Bases: _AvgPool2dBase

__init__(kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] | None = None, padding: int | Tuple[int, int] = 0, ceil_mode: bool = False, count_include_pad: bool = True, divisor_override: int | None = None, config=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.pool2d.AdaptiveAvgPool2dInteger(output_size, config)[source]#

Bases: _AdaptiveAvgPool2dBase

__init__(output_size, config) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.pool2d.AvgPool2dBinary(kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] | None = None, padding: int | Tuple[int, int] = 0, ceil_mode: bool = False, count_include_pad: bool = True, divisor_override: int | None = None, config=None)[source]#

Bases: _AvgPool2dBase

__init__(kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] | None = None, padding: int | Tuple[int, int] = 0, ceil_mode: bool = False, count_include_pad: bool = True, divisor_override: int | None = None, config=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.pool2d.AvgPool2dTernary(kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] | None = None, padding: int | Tuple[int, int] = 0, ceil_mode: bool = False, count_include_pad: bool = True, divisor_override: int | None = None, config=None)[source]#

Bases: _AvgPool2dBase

__init__(kernel_size: int | Tuple[int, int], stride: int | Tuple[int, int] | None = None, padding: int | Tuple[int, int] = 0, ceil_mode: bool = False, count_include_pad: bool = True, divisor_override: int | None = None, config=None) None[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

chop.nn.quantized.modules.relu#

class chop.nn.quantized.modules.relu.ReLUInteger(inplace: bool = False, config: dict = None)[source]#

Bases: _ReLUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

bypass = None#
class chop.nn.quantized.modules.relu.ReLUMinifloatDenorm(inplace: bool = False, config: dict = None)[source]#

Bases: _ReLUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.relu.ReLUMinifloatIEEE(inplace: bool = False, config: dict = None)[source]#

Bases: _ReLUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.relu.ReLULog(inplace: bool = False, config: dict = None)[source]#

Bases: _ReLUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.relu.ReLUBlockFP(inplace: bool = False, config: dict = None)[source]#

Bases: _ReLUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.relu.ReLUBlockMinifloat(inplace: bool = False, config: dict = None)[source]#

Bases: _ReLUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.relu.ReLUBlockLog(inplace: bool = False, config: dict = None)[source]#

Bases: _ReLUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.relu.ReLUBinary(inplace: bool = False, config: dict = None)[source]#

Bases: _ReLUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

bypass = None#
class chop.nn.quantized.modules.relu.ReLUTernary(inplace: bool = False, config: dict = None)[source]#

Bases: _ReLUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

bypass = None#

chop.nn.quantized.modules.rms_norm#

class chop.nn.quantized.modules.rms_norm.RMSNorm(normalized_shape, eps: float = 1e-08, elementwise_affine: bool = False, device=None, dtype=None)[source]#

Bases: Module

Root Mean Square Layer Normalization

__init__(normalized_shape, eps: float = 1e-08, elementwise_affine: bool = False, device=None, dtype=None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor)[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.rms_norm.RMSNormInteger(normalized_shape, eps: float = 1e-08, elementwise_affine: bool = False, device=None, dtype=None, config=None)[source]#

Bases: _RMSNormBase

__init__(normalized_shape, eps: float = 1e-08, elementwise_affine: bool = False, device=None, dtype=None, config=None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

chop.nn.quantized.modules.selu#

class chop.nn.quantized.modules.selu.SELUInteger(inplace: bool = False, config: dict = None)[source]#

Bases: _SELUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

bypass = None#
class chop.nn.quantized.modules.selu.SELUMinifloatDenorm(inplace: bool = False, config: dict = None)[source]#

Bases: _SELUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.selu.SELUMinifloatIEEE(inplace: bool = False, config: dict = None)[source]#

Bases: _SELUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.selu.SELULog(inplace: bool = False, config: dict = None)[source]#

Bases: _SELUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.selu.SELUBlockFP(inplace: bool = False, config: dict = None)[source]#

Bases: _SELUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.selu.SELUBlockMinifloat(inplace: bool = False, config: dict = None)[source]#

Bases: _SELUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.selu.SELUBlockLog(inplace: bool = False, config: dict = None)[source]#

Bases: _SELUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.selu.SELUBinary(inplace: bool = False, config: dict = None)[source]#

Bases: _SELUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

bypass = None#
class chop.nn.quantized.modules.selu.SELUTernary(inplace: bool = False, config: dict = None)[source]#

Bases: _SELUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

bypass = None#

chop.nn.quantized.modules.silu#

class chop.nn.quantized.modules.silu.SiLUInteger(inplace: bool = False, config: dict = None)[source]#

Bases: _SiLUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

bypass = None#
class chop.nn.quantized.modules.silu.SiLUMinifloatDenorm(inplace: bool = False, config: dict = None)[source]#

Bases: _SiLUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.silu.SiLUMinifloatIEEE(inplace: bool = False, config: dict = None)[source]#

Bases: _SiLUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.silu.SiLULog(inplace: bool = False, config: dict = None)[source]#

Bases: _SiLUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.silu.SiLUBlockFP(inplace: bool = False, config: dict = None)[source]#

Bases: _SiLUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.silu.SiLUBlockMinifloat(inplace: bool = False, config: dict = None)[source]#

Bases: _SiLUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.silu.SiLUBlockLog(inplace: bool = False, config: dict = None)[source]#

Bases: _SiLUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.silu.SiLUBinary(inplace: bool = False, config: dict = None)[source]#

Bases: _SiLUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

bypass = None#
class chop.nn.quantized.modules.silu.SiLUTernary(inplace: bool = False, config: dict = None)[source]#

Bases: _SiLUBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

bypass = None#

chop.nn.quantized.modules.softplus#

class chop.nn.quantized.modules.softplus.SoftplusInteger(inplace: bool = False, config: dict = None)[source]#

Bases: _SoftplusBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

bypass = None#
class chop.nn.quantized.modules.softplus.SoftplusMinifloatDenorm(inplace: bool = False, config: dict = None)[source]#

Bases: _SoftplusBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.softplus.SoftplusMinifloatIEEE(inplace: bool = False, config: dict = None)[source]#

Bases: _SoftplusBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.softplus.SoftplusLog(inplace: bool = False, config: dict = None)[source]#

Bases: _SoftplusBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.softplus.SoftplusBlockFP(inplace: bool = False, config: dict = None)[source]#

Bases: _SoftplusBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.softplus.SoftplusBlockMinifloat(inplace: bool = False, config: dict = None)[source]#

Bases: _SoftplusBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.softplus.SoftplusBlockLog(inplace: bool = False, config: dict = None)[source]#

Bases: _SoftplusBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.softplus.SoftplusBinary(inplace: bool = False, config: dict = None)[source]#

Bases: _SoftplusBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

bypass = None#
class chop.nn.quantized.modules.softplus.SoftplusTernary(inplace: bool = False, config: dict = None)[source]#

Bases: _SoftplusBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

bypass = None#

chop.nn.quantized.modules.softsign#

class chop.nn.quantized.modules.softsign.SoftsignInteger(inplace: bool = False, config: dict = None)[source]#

Bases: _SoftsignBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

bypass = None#
class chop.nn.quantized.modules.softsign.SoftsignMinifloatDenorm(inplace: bool = False, config: dict = None)[source]#

Bases: _SoftsignBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.softsign.SoftsignMinifloatIEEE(inplace: bool = False, config: dict = None)[source]#

Bases: _SoftsignBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.softsign.SoftsignLog(inplace: bool = False, config: dict = None)[source]#

Bases: _SoftsignBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.softsign.SoftsignBlockFP(inplace: bool = False, config: dict = None)[source]#

Bases: _SoftsignBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.softsign.SoftsignBlockMinifloat(inplace: bool = False, config: dict = None)[source]#

Bases: _SoftsignBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.softsign.SoftsignBlockLog(inplace: bool = False, config: dict = None)[source]#

Bases: _SoftsignBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.softsign.SoftsignBinary(inplace: bool = False, config: dict = None)[source]#

Bases: _SoftsignBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

bypass = None#
class chop.nn.quantized.modules.softsign.SoftsignTernary(inplace: bool = False, config: dict = None)[source]#

Bases: _SoftsignBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

bypass = None#

chop.nn.quantized.modules.tanh#

class chop.nn.quantized.modules.tanh.TanhInteger(inplace: bool = False, config: dict = None)[source]#

Bases: _TanhBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

bypass = None#
class chop.nn.quantized.modules.tanh.TanhMinifloatDenorm(inplace: bool = False, config: dict = None)[source]#

Bases: _TanhBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.tanh.TanhMinifloatIEEE(inplace: bool = False, config: dict = None)[source]#

Bases: _TanhBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.tanh.TanhLog(inplace: bool = False, config: dict = None)[source]#

Bases: _TanhBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

class chop.nn.quantized.modules.tanh.TanhBlockFP(inplace: bool = False, config: dict = None)[source]#

Bases: _TanhBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.tanh.TanhBlockMinifloat(inplace: bool = False, config: dict = None)[source]#

Bases: _TanhBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.tanh.TanhBlockLog(inplace: bool = False, config: dict = None)[source]#

Bases: _TanhBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

forward(x: Tensor) Tensor[source]#

Define the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

class chop.nn.quantized.modules.tanh.TanhBinary(inplace: bool = False, config: dict = None)[source]#

Bases: _TanhBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

bypass = None#
class chop.nn.quantized.modules.tanh.TanhTernary(inplace: bool = False, config: dict = None)[source]#

Bases: _TanhBase

__init__(inplace: bool = False, config: dict = None)[source]#

Initialize internal Module state, shared by both nn.Module and ScriptModule.

bypass = None#

chop.nn.quantized.utils#

chop.nn.quantized.utils.extract_required_config(self, config: dict)[source]#
chop.nn.quantized.utils.get_stats(config: dict, stat_name: str) float | None[source]#
chop.nn.quantized.utils.quantiser_passthrough(x: Tensor)[source]#