Skip to content

Commit bc6e7ac

Browse files
committed
Unify definition of DeviceOrMemoryType
1 parent 7df58d5 commit bc6e7ac

File tree

5 files changed

+9
-18
lines changed

5 files changed

+9
-18
lines changed

python/tritonserver/_api/_datautils.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
from typing import Any, Callable, ClassVar, Optional, Sequence, Type
3636

3737
import numpy
38+
from tritonserver._api._memorybuffer import DeviceOrMemoryType
3839
from tritonserver._c import InvalidArgumentError
3940
from tritonserver._c import TRITONSERVER_DataType as DataType
4041
from tritonserver._c import TRITONSERVER_MemoryType as MemoryType
@@ -47,10 +48,6 @@
4748
except ImportError:
4849
cupy = None
4950

50-
DeviceOrMemoryType = (
51-
tuple[MemoryType, int] | MemoryType | tuple[_dlpack.DLDeviceType, int] | str
52-
)
53-
5451

5552
class CustomKeyErrorDict(dict):
5653
def __init__(

python/tritonserver/_api/_memorybuffer.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,17 @@
3333

3434
import numpy
3535
from tritonserver._api._datautils import DLPackObject
36+
from tritonserver._api._dlpack import DLDeviceType
3637
from tritonserver._c.triton_bindings import (
3738
InvalidArgumentError,
3839
TRITONSERVER_BufferAttributes,
3940
)
4041
from tritonserver._c.triton_bindings import TRITONSERVER_MemoryType as MemoryType
4142

43+
DeviceOrMemoryType = (
44+
tuple[MemoryType, int] | MemoryType | tuple[DLDeviceType, int] | str
45+
)
46+
4247

4348
@dataclass
4449
class MemoryBuffer:

python/tritonserver/_api/_request.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,14 @@
3636
from tritonserver._api import _model
3737
from tritonserver._api._datautils import CustomKeyErrorDict
3838
from tritonserver._api._dlpack import DLDeviceType as DLDeviceType
39+
from tritonserver._api._memorybuffer import DeviceOrMemoryType
3940
from tritonserver._api._tensor import Tensor
4041
from tritonserver._c.triton_bindings import InvalidArgumentError
4142
from tritonserver._c.triton_bindings import TRITONSERVER_DataType as DataType
4243
from tritonserver._c.triton_bindings import TRITONSERVER_InferenceRequest
4344
from tritonserver._c.triton_bindings import TRITONSERVER_MemoryType as MemoryType
4445
from tritonserver._c.triton_bindings import TRITONSERVER_Server
4546

46-
DeviceOrMemoryType = (
47-
tuple[MemoryType, int] | MemoryType | tuple[DLDeviceType, int] | str
48-
)
49-
5047

5148
@dataclass
5249
class InferenceRequest:

python/tritonserver/_api/_response.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
from tritonserver._api._dlpack import DLDeviceType as DLDeviceType
4545
from tritonserver._api._logging import LogMessage
46-
from tritonserver._api._memorybuffer import MemoryBuffer
46+
from tritonserver._api._memorybuffer import DeviceOrMemoryType, MemoryBuffer
4747
from tritonserver._api._tensor import Tensor
4848
from tritonserver._c.triton_bindings import (
4949
InternalError,
@@ -57,10 +57,6 @@
5757
TRITONSERVER_Server,
5858
)
5959

60-
DeviceOrMemoryType = (
61-
tuple[MemoryType, int] | MemoryType | tuple[DLDeviceType, int] | str
62-
)
63-
6460

6561
@dataclass
6662
class InferenceResponse:

python/tritonserver/_api/_tensor.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
DLManagedTensor,
4646
c_str_dltensor,
4747
)
48-
from tritonserver._api._memorybuffer import MemoryBuffer
48+
from tritonserver._api._memorybuffer import DeviceOrMemoryType, MemoryBuffer
4949
from tritonserver._c.triton_bindings import (
5050
InvalidArgumentError,
5151
TRITONSERVER_BufferAttributes,
@@ -54,10 +54,6 @@
5454
from tritonserver._c.triton_bindings import TRITONSERVER_MemoryType as MemoryType
5555
from tritonserver._c.triton_bindings import UnsupportedError
5656

57-
DeviceOrMemoryType = (
58-
tuple[MemoryType, int] | MemoryType | tuple[DLDeviceType, int] | str
59-
)
60-
6157
try:
6258
import cupy
6359
except ImportError:

0 commit comments

Comments
 (0)