class_docstr: A quantized linear module with quantized tensor as inputs and outputs
  to support APoT quantization.
  We adopt the same interface as `torch.nn.Linear`, see
  https://pytorch.org/docs/stable/nn.html#torch.nn.Linear for documentation.
  
  Similar to :class:`~torch.nn.Linear`, attributes will be randomly
  initialized at module creation time and will be overwritten later
  
  Attributes:
      alpha: `alpha` qparam of output Quantized Tensor, type: Tensor
      gamma: `gamma` qparam of output Quantized Tensor, type: Tensor
      quantization_levels: `quantization_levels` qparam of output Quantized Tensor, type: Tensor
      level_indices: `level_indices` qparam of output Quantized Tensor, type: Tensor
      weight: APoT quantized tensor from weight2quantize
      weight_transposed: transposed weight tensor, used in linear transformation calculation (y = x * A^T + b)
class_docstr_tok: ["A","quantized","linear","module","with","quantized","tensor","as","inputs","and","outputs","to","support","APoT","quantization",".","We","adopt","the","same","interface","as","`","torch.nn.Linear","`",",","see","https",":","\/\/pytorch.org\/docs\/stable\/nn.html","#","torch.nn.Linear","for","documentation",".","Similar","to",":","class",":","`","~torch.nn.Linear","`",",","attributes","will","be","randomly","initialized","at","module","creation","time","and","will","be","overwritten","later","Attributes",":","alpha",":","`","alpha","`","qparam","of","output","Quantized","Tensor",",","type",":","Tensor","gamma",":","`","gamma","`","qparam","of","output","Quantized","Tensor",",","type",":","Tensor","quantization_levels",":","`","quantization_levels","`","qparam","of","output","Quantized","Tensor",",","type",":","Tensor","level_indices",":","`","level_indices","`","qparam","of","output","Quantized","Tensor",",","type",":","Tensor","weight",":","APoT","quantized","tensor","from","weight2quantize","weight_transposed",":","transposed","weight","tensor",",","used","in","linear","transformation","calculation","(","y","=","x","*","A^T","+","b",")"]
docstr: Multiply APoT quantized weight and uniformly quantized activation (dtype: quint8)
  with bitshifting instead of matrix multiplication.
  Result has dtype torch.float32
  Args:
      activation (Tensor): uniformly quantized activation tensor
docstr_tok: ["Multiply","APoT","quantized","weight","and","uniformly","quantized","activation","(","dtype",":","quint8",")","with","bitshifting","instead","of","matrix","multiplication",".","Result","has","dtype","torch.float32","Args",":","activation","(","Tensor",")",":","uniformly","quantized","activation","tensor"]
code: def forward(self, activation: torch.Tensor) -> torch.FloatTensor:
      r"""
      Multiply APoT quantized weight and uniformly quantized activation (dtype: quint8)
      with bitshifting instead of matrix multiplication.
      Result has dtype torch.float32
      Args:
          activation (Tensor): uniformly quantized activation tensor
      """
      assert activation.dim() == 2
  
      weight_rows = self.weight_transposed.size()[0]
      weight_cols = self.weight_transposed.size()[1]
  
      decomposed_weight: np.ndarray = np.empty(
          shape=(weight_rows, weight_cols), dtype=object
      )
      for row in range(weight_rows):
          for col in range(weight_cols):
              decomposed_weight[row][col] = self.decompose_APoT(
                  bin(self.weight_transposed[row][col])
              )
  
      result = self.matmul(decomposed_weight, activation).type(
          torch.FloatTensor
      )
  
      return result
  
file_path: pytorch/torch/ao/quantization/experimental/linear.py
imports: import torch
  import numpy
  from torch.ao.nn.quantized.modules.utils import WeightedQuantizedModule
  from torch.ao.quantization.experimental.observer import APoTObserver
  from torch.ao.quantization.experimental.quantizer import quantize_APoT
label_desc: Use image node_id 5 for calling the LinearAPoT obj's underlying member method code with example usage: obj.forward(activation) and returns: result