Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
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
7 changes: 7 additions & 0 deletions exir/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ class TensorDataLocation(IntEnum):
EXTERNAL = 1


class DeviceType(IntEnum):
CPU = 0
CUDA = 1


@dataclass
class ExtraTensorInfo:
"""
Expand All @@ -57,6 +62,8 @@ class ExtraTensorInfo:
mutable_data_segments_idx: int = 0
fully_qualified_name: Optional[str] = None
location: TensorDataLocation = TensorDataLocation.SEGMENT
device_type: DeviceType = DeviceType.CPU
device_index: int = -1
Comment thread
lucylq marked this conversation as resolved.
Outdated


@dataclass
Expand Down
15 changes: 15 additions & 0 deletions schema/program.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ enum TensorDataLocation : byte {
EXTERNAL = 1,
}

// Device type enum indicating where a tensor resides or should be allocated.
enum DeviceType : byte {
CPU = 0,
CUDA = 1,
}

// Table to put additional information about tensors in that is not applicable
// to the vast majority of tensors in the vast majority of programs.
table ExtraTensorInfo {
Expand All @@ -80,6 +86,15 @@ table ExtraTensorInfo {
// must be non-empty, and is used as a key to find the tensor's external
// data. Tensor.data_buffer_idx is ignored.
location: TensorDataLocation;

// [Optional] The device type where this tensor resides or should be allocated.
// Defaults to CPU for backward compatibility with existing PTE files.
device_type: DeviceType = CPU;

// [Optional] The device index for multi-device scenarios (e.g., cuda:0, cuda:1).
// A value of -1 indicates the default device. Defaults to -1 for backward
// compatibility.
device_index: byte = -1;
}

table Tensor {
Expand Down
Loading