class_docstr: Builds py:class:`QConfigMapping` from :py:class:`LinearQuantizerConfig`.
class_docstr_tok: ["Builds","py",":","class",":","`","QConfigMapping","`","from",":","py",":","class",":","`","LinearQuantizerConfig","`","."]
docstr: Creates a :py:class:`QConfig` from ``quantization_config``
docstr_tok: ["Creates","a",":","py",":","class",":","`","QConfig","`","from","``","quantization_config","``"]
code: def _create_qconfig_from_quantization_config(
      quantization_config: _ModuleLinearQuantizerConfig,
  ) -> _Optional[_aoquant.QConfig]:
      """
      Creates a :py:class:`QConfig` from ``quantization_config``
      """
      if quantization_config.weight_dtype == _torch.float32:
          return None
      if quantization_config.activation_dtype == _torch.float32:
          activation_qconfig = _aoquant.NoopObserver.with_args(
              dtype=_torch.float,
          )
      else:
          activation_qconfig = _aoquant.FakeQuantize.with_args(
              observer=_ObserverType.get_observer(
                  quantization_config.activation_observer,
                  is_per_channel=False,
              ),
              dtype=quantization_config.activation_dtype,
              qscheme=_QuantizationScheme.get_qscheme(
                  quantization_config.quantization_scheme,
                  is_per_channel=False,
              ),
          )
      weight_qconfig = _aoquant.FakeQuantize.with_args(
          observer=_ObserverType.get_observer(
              quantization_config.weight_observer,
              is_per_channel=quantization_config.weight_per_channel,
          ),
          dtype=quantization_config.weight_dtype,
          qscheme=_QuantizationScheme.get_qscheme(
              quantization_config.quantization_scheme,
              is_per_channel=quantization_config.weight_per_channel,
          ),
      )
      return _aoquant.QConfig(
          activation=activation_qconfig, weight=weight_qconfig
      )
  
file_path: coremltools/coremltools/optimize/torch/quantization/_qconfig_mapping.py
imports: from typing import Any
  from typing import Optional
  import torch
  import torch.ao.quantization
  import torch.nn
  from coremltools.optimize.torch.quantization._backend_config import _fixed_qparams_modules
  from coremltools.optimize.torch.quantization._backend_config import get_supported_modules
  from coremltools.optimize.torch.quantization.quantization_config import LinearQuantizerConfig
  from coremltools.optimize.torch.quantization.quantization_config import ModuleLinearQuantizerConfig
  from coremltools.optimize.torch.quantization.quantization_config import ObserverType
  from coremltools.optimize.torch.quantization.quantization_config import QuantizationScheme
  from coremltools.optimize.torch.quantization.quantization_config import _default_quantization_options
label_desc: Use image node_id 4 for calling the _QConfigMappingBuilder obj's underlying member method code with example usage: obj._create_qconfig_from_quantization_config(quantization_config) and returns: _aoquant, None