quantizer.py 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # Copyright (c) Microsoft Corporation.
  2. # SPDX-License-Identifier: Apache-2.0
  3. # DeepSpeed Team
  4. from .builder import CUDAOpBuilder
  5. class QuantizerBuilder(CUDAOpBuilder):
  6. BUILD_VAR = "DS_BUILD_QUANTIZER"
  7. NAME = "quantizer"
  8. def __init__(self, name=None):
  9. name = self.NAME if name is None else name
  10. super().__init__(name=name)
  11. def absolute_name(self):
  12. return f'deepspeed.ops.quantizer.{self.NAME}_op'
  13. def sources(self):
  14. return [
  15. 'csrc/quantization/pt_binding.cpp',
  16. 'csrc/quantization/fake_quantizer.cu',
  17. 'csrc/quantization/quantize.cu',
  18. 'csrc/quantization/quantize_intX.cu',
  19. 'csrc/quantization/dequantize.cu',
  20. 'csrc/quantization/swizzled_quantize.cu',
  21. 'csrc/quantization/quant_reduce.cu',
  22. ]
  23. def include_paths(self):
  24. return ['csrc/includes']
  25. def extra_ldflags(self):
  26. if not self.is_rocm_pytorch():
  27. return ['-lcurand']
  28. else:
  29. return []