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: Perform matrix multiplication between decomposed_weight and
  activation by calling bitshift_mul function for each value
  Args:
      decomposed_weight (Tensor): APoT quantized weight decomposed into binary
      activation (Tensor): uniformly quantized activation
docstr_tok: ["Perform","matrix","multiplication","between","decomposed_weight","and","activation","by","calling","bitshift_mul","function","for","each","value","Args",":","decomposed_weight","(","Tensor",")",":","APoT","quantized","weight","decomposed","into","binary","activation","(","Tensor",")",":","uniformly","quantized","activation"]
code: def matmul(self, decomposed_weight, activation):
      r"""
      Perform matrix multiplication between decomposed_weight and
      activation by calling bitshift_mul function for each value
      Args:
          decomposed_weight (Tensor): APoT quantized weight decomposed into binary
          activation (Tensor): uniformly quantized activation
      """
      rows1 = activation.size(dim=0)
      cols1 = activation.size(dim=1)
  
      rows2 = decomposed_weight.shape[0]
      cols2 = decomposed_weight.shape[1]
  
      result = torch.zeros(rows1, cols2)
  
      # compute matrix multiplication with bitshifts
      for i in range(rows1):
          for j in range(cols2):
              for k in range(rows2):
                  weight_val = decomposed_weight[k][j]
                  r = int(activation[i][k])
  
                  product = self.bitshift_mul(weight_val, r)
  
                  result[i][j] += product
  
      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 4 for calling the LinearAPoT obj's underlying member method code with example usage: obj.matmul(decomposed_weight, activation) and returns: result