Skip to content

Commit 27d226d

Browse files
author
pengcheng888
committed
issue/943 - fix bugs: (1) circular imports (2) ambiguous filenames and class names.
1 parent 7c97894 commit 27d226d

7 files changed

Lines changed: 27 additions & 25 deletions

File tree

python/infinicore/__init__.py

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,8 @@
22

33
import infinicore.context as context
44
import infinicore.nn as nn
5-
6-
# Import context functions
7-
from infinicore.context import (
8-
get_device,
9-
get_device_count,
10-
get_stream,
11-
is_graph_recording,
12-
set_device,
13-
start_graph_recording,
14-
stop_graph_recording,
15-
sync_device,
16-
sync_stream,
17-
)
18-
from infinicore.device import device
19-
from infinicore.device_event import DeviceEvent
20-
from infinicore.dtype import (
5+
from infinicore._device import device
6+
from infinicore._dtype import (
217
bfloat16,
228
bool,
239
cdouble,
@@ -42,6 +28,20 @@
4228
short,
4329
uint8,
4430
)
31+
32+
# Import context functions
33+
from infinicore.context import (
34+
get_device,
35+
get_device_count,
36+
get_stream,
37+
is_graph_recording,
38+
set_device,
39+
start_graph_recording,
40+
stop_graph_recording,
41+
sync_device,
42+
sync_stream,
43+
)
44+
from infinicore.device_event import DeviceEvent
4545
from infinicore.ops.add import add
4646
from infinicore.ops.add_rms_norm import add_rms_norm, add_rms_norm_
4747
from infinicore.ops.attention import attention

python/infinicore/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import infinicore.device
1+
import infinicore._device
22
from infinicore.graph import Graph
33
from infinicore.lib import _infinicore
44

python/infinicore/device_event.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import infinicore.device
1+
import infinicore._device
22
from infinicore.lib import _infinicore
33

44

python/infinicore/tensor.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
import numpy as np
44

5-
import infinicore.device
6-
import infinicore.dtype
5+
import infinicore._device
6+
import infinicore._dtype
7+
from infinicore._device import device
8+
from infinicore._dtype import dtype
79
from infinicore.lib import _infinicore
810

911
from .utils import (
@@ -18,8 +20,8 @@ class Tensor:
1820
_underlying: _infinicore.Tensor
1921
_torch_ref: "torch.Tensor" # noqa: F821
2022
shape: list[int]
21-
dtype: infinicore.dtype
22-
device: infinicore.device
23+
dtype: dtype
24+
device: device
2325

2426
def __init__(self, underlying, *, _torch_ref=None):
2527
"""An internal method. Please do not use this directly."""
@@ -198,8 +200,8 @@ def from_torch(torch_tensor) -> Tensor:
198200
def from_numpy(
199201
np_array,
200202
*,
201-
dtype: infinicore.dtype = None,
202-
device: infinicore.device = None,
203+
dtype: dtype = None,
204+
device: device = None,
203205
) -> Tensor:
204206
"""Convert a NumPy ndarray to an infinicore Tensor.
205207

test/infinicore/test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def test5_bf16():
170170

171171

172172
def func6_initialize_device_relationship():
173-
from infinicore.device import _initialize_device_relationship
173+
from infinicore._device import _initialize_device_relationship
174174

175175
all_device_types = [
176176
_infinicore.Device.Type.CPU, # 0 "cpu"

0 commit comments

Comments
 (0)