mindspore_gs.ptq.PTQConfig

View Source On Gitee
class mindspore_gs.ptq.PTQConfig(mode = PTQMode.QUANTIZE, backend = BackendTarget.NONE, opname_blacklist = <dataclasses._MISSING_TYPE object at 0x7f9bec467c50>)[source]

Config for post trainning quantization.

Parameters
  • mode (mindspore_gs.ptq.PTQMode) – Flag for ptq mode, QUANTIZATION for quantization mode, DEPLOY for deploy mode.

  • backend (mindspore_gs.ptq.BackendTarget) – Flag for backend target, NONE for no specific backend, ASCEND for ascend backend.

  • opname_blacklist (List[str]) – Blacklist of opname. Layers in network with name fuzzy matched with this blacklist will not being quanted.

Raises
  • ValueError – If mode is not in PTQMode's members.

  • ValueError – If backend is not in BackendTarget's members.

  • TypeError – if opname_blacklist is not a list of str.

Example

>>> from mindspore_gs.ptq import PTQConfig, PTQMode
>>> from mindspore_gs.common import BackendTarget
>>> PTQConfig(mode=PTQMode.DEPLOY, backend=BackendTarget.ASCEND, opname_blacklist=['layer0'])
PTQConfig(mode=<PTQMode.DEPLOY: 'deploy'>, backend=<BackendTarget.ASCEND: 'ascend'>, opname_blacklist=['layer0'], algo_args={})