Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion python/triton/runtime/jit.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from collections import defaultdict
from dataclasses import dataclass
from functools import cached_property
from typing import Callable, Generic, Iterable, Optional, ParamSpec, TypeVar, overload, Dict, Any, Tuple
from typing import Callable, Concatenate, Generic, Iterable, Optional, ParamSpec, TYPE_CHECKING, TypeVar, overload, Dict, Any, Tuple

from triton.backends import BaseBackend
from types import ModuleType
Expand All @@ -29,6 +29,7 @@
T = TypeVar("T")
P = ParamSpec("P")
R = TypeVar("R")
U = TypeVar("U")

# -----------------------------------------------------------------------------
# Dependencies Finder
Expand Down Expand Up @@ -907,6 +908,20 @@ def finalize_compile(kernel):
def __call__(self: "JITFunction[Callable[P, R]]", *args: P.args, **kwargs: P.kwargs) -> R:
raise RuntimeError("Cannot call @triton.jit'd outside of the scope of a kernel")

if TYPE_CHECKING:

@overload
def __get__(self, instance: None, owner: Optional[type] = None) -> "JITFunction[T]":
...

@overload
def __get__(self: "JITFunction[Callable[Concatenate[U, P], R]]", instance: Any,
owner: Optional[type] = None) -> Callable[P, R]:
...

def __get__(self, instance, owner=None):
...

def __repr__(self):
return f"JITFunction({self.module}:{self.fn.__qualname__})"

Expand Down
Loading