logging.py 780 B

1234567891011121314151617181920212223242526
  1. # Copyright (c) Microsoft Corporation.
  2. # SPDX-License-Identifier: Apache-2.0
  3. # DeepSpeed Team
  4. import logging
  5. from deepspeed.utils.logging import LoggerFactory
  6. inf_logger = None
  7. def inference_logger(level: int = logging.INFO) -> logging.Logger:
  8. """
  9. Create the inference logger. NOTE: Logging is not cost free. On a 3960X,
  10. there is a cost of about 6 us per call to a no-op logger, so this should
  11. be used during setup only and not during the inference loop.
  12. Args:
  13. level (int, optional): The logging level. Defaults to logging.INFO.
  14. """
  15. global inf_logger
  16. if inf_logger is None:
  17. inf_logger = LoggerFactory.create_logger(name="DS-Inference", level=level)
  18. inf_logger.debug("Inference logger created.")
  19. return inf_logger