Skip to content

Commit 7b16ab7

Browse files
authored
Avoid relative imports (#739)
* avoid relative imports in python files that contain triton jit functions to allow importing those files as top-level files
1 parent ad1f5dc commit 7b16ab7

153 files changed

Lines changed: 502 additions & 507 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/flag_gems/fused/__init__.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
from .concat_and_cache_mla import concat_and_cache_mla
2-
from .cross_entropy_loss import cross_entropy_loss
3-
from .fused_add_rms_norm import fused_add_rms_norm
4-
from .gelu_and_mul import gelu_and_mul
5-
from .instance_norm import instance_norm
6-
from .outer import outer
7-
from .reshape_and_cache import reshape_and_cache
8-
from .rotary_embedding import apply_rotary_pos_emb
9-
from .silu_and_mul import silu_and_mul
10-
from .skip_layernorm import skip_layer_norm
11-
from .weight_norm import weight_norm
1+
from flag_gems.fused.concat_and_cache_mla import concat_and_cache_mla
2+
from flag_gems.fused.cross_entropy_loss import cross_entropy_loss
3+
from flag_gems.fused.fused_add_rms_norm import fused_add_rms_norm
4+
from flag_gems.fused.gelu_and_mul import gelu_and_mul
5+
from flag_gems.fused.instance_norm import instance_norm
6+
from flag_gems.fused.outer import outer
7+
from flag_gems.fused.reshape_and_cache import reshape_and_cache
8+
from flag_gems.fused.rotary_embedding import apply_rotary_pos_emb
9+
from flag_gems.fused.silu_and_mul import silu_and_mul
10+
from flag_gems.fused.skip_layernorm import skip_layer_norm
11+
from flag_gems.fused.weight_norm import weight_norm
1212

1313
__all__ = [
1414
"apply_rotary_pos_emb",

src/flag_gems/fused/concat_and_cache_mla.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import triton
55
import triton.language as tl
66

7-
from ..utils import libentry
7+
from flag_gems.utils import libentry
88

99
logger = logging.getLogger(__name__)
1010

src/flag_gems/fused/cross_entropy_loss.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
import triton.language as tl
66
from torch.nn import _reduction as _Reduction
77

8-
from .. import runtime
9-
from ..runtime import torch_device_fn
10-
from ..utils import libentry
11-
from ..utils import triton_lang_extension as tle
8+
from flag_gems import runtime
9+
from flag_gems.runtime import torch_device_fn
10+
from flag_gems.utils import libentry
11+
from flag_gems.utils import triton_lang_extension as tle
1212

1313
logger = logging.getLogger(__name__)
1414

src/flag_gems/fused/fused_add_rms_norm.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import triton
55
import triton.language as tl
66

7-
from ..runtime import torch_device_fn
8-
from ..utils import libentry
9-
from ..utils import triton_lang_extension as tle
7+
from flag_gems.runtime import torch_device_fn
8+
from flag_gems.utils import libentry
9+
from flag_gems.utils import triton_lang_extension as tle
1010

1111
logger = logging.getLogger(__name__)
1212

src/flag_gems/fused/gelu_and_mul.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import triton
55
import triton.language as tl
66

7-
from ..utils import pointwise_dynamic, tl_extra_shim
7+
from flag_gems.utils import pointwise_dynamic, tl_extra_shim
88

99
erf = tl_extra_shim.erf
1010
pow = tl_extra_shim.pow

src/flag_gems/fused/instance_norm.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
import triton
77
import triton.language as tl
88

9-
from .. import runtime
10-
from ..runtime import torch_device_fn
11-
from ..utils import libentry
12-
from ..utils.type_utils import get_accumulator_dtype
9+
from flag_gems import runtime
10+
from flag_gems.runtime import torch_device_fn
11+
from flag_gems.utils import libentry
12+
from flag_gems.utils.type_utils import get_accumulator_dtype
1313

1414
logger = logging.getLogger(__name__)
1515
Tensor = torch.Tensor

src/flag_gems/fused/outer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import torch
44

5-
from ..ops import mul, mv
5+
from flag_gems.ops import mul, mv
66

77
logger = logging.getLogger(__name__)
88

src/flag_gems/fused/reshape_and_cache.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import triton
44
import triton.language as tl
55

6-
from ..runtime import torch_device_fn
7-
from ..utils import libentry
6+
from flag_gems.runtime import torch_device_fn
7+
from flag_gems.utils import libentry
88

99
logger = logging.getLogger(__name__)
1010

src/flag_gems/fused/rotary_embedding.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
import triton
66
import triton.language as tl
77

8-
from ..runtime import torch_device_fn
9-
from ..utils import libentry
10-
from ..utils import triton_lang_extension as tle
8+
from flag_gems.runtime import torch_device_fn
9+
from flag_gems.utils import libentry
10+
from flag_gems.utils import triton_lang_extension as tle
1111

1212
logger = logging.getLogger(__name__)
1313

src/flag_gems/fused/silu_and_mul.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import triton
55
import triton.language as tl
66

7-
from ..utils import pointwise_dynamic
7+
from flag_gems.utils import pointwise_dynamic
88

99
logger = logging.getLogger(__name__)
1010

0 commit comments

Comments
 (0)