__init__.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. """isort:skip_file"""
  2. __version__ = '3.6.0'
  3. # ---------------------------------------
  4. # Note: import order is significant here.
  5. # submodules
  6. from .runtime import (
  7. autotune,
  8. Config,
  9. heuristics,
  10. JITFunction,
  11. KernelInterface,
  12. reinterpret,
  13. TensorWrapper,
  14. OutOfResources,
  15. InterpreterError,
  16. MockTensor,
  17. )
  18. from .runtime.jit import constexpr_function, jit
  19. from .runtime._async_compile import AsyncCompileMode, FutureKernel
  20. from .compiler import compile, CompilationError
  21. from .errors import TritonError
  22. from .runtime._allocation import set_allocator
  23. from . import language
  24. from . import testing
  25. from . import tools
  26. must_use_result = language.core.must_use_result
  27. __all__ = [
  28. "AsyncCompileMode",
  29. "autotune",
  30. "cdiv",
  31. "CompilationError",
  32. "compile",
  33. "Config",
  34. "constexpr_function",
  35. "FutureKernel",
  36. "heuristics",
  37. "InterpreterError",
  38. "jit",
  39. "JITFunction",
  40. "KernelInterface",
  41. "language",
  42. "MockTensor",
  43. "must_use_result",
  44. "next_power_of_2",
  45. "OutOfResources",
  46. "reinterpret",
  47. "runtime",
  48. "set_allocator",
  49. "TensorWrapper",
  50. "TritonError",
  51. "testing",
  52. "tools",
  53. ]
  54. # -------------------------------------
  55. # misc. utilities that don't fit well
  56. # into any specific module
  57. # -------------------------------------
  58. @constexpr_function
  59. def cdiv(x: int, y: int):
  60. return (x + y - 1) // y
  61. @constexpr_function
  62. def next_power_of_2(n: int):
  63. """Return the smallest power of 2 greater than or equal to n"""
  64. n -= 1
  65. n |= n >> 1
  66. n |= n >> 2
  67. n |= n >> 4
  68. n |= n >> 8
  69. n |= n >> 16
  70. n |= n >> 32
  71. n += 1
  72. return n