You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Do the above also with a given memory, i.e. CPU or GPU memory
For the purposes of being able to make decisions at the code level and also to gain back some control. In a meeting with @willow-ahrens and @mtsokol we decided the following interface for the long-term.
Proposed interface
I propose a number of new classes (stubs and descriptions below):
classLeafLevel(abc.ABC):
@abc.abstractmethoddef_construct(self, *, dtype, fill_value) ->jl.LeafLevel:
...
classLevel(abc.ABC):
@abc.abstractmethoddef_construct(self, *, inner_level: "Level"|LeafLevel) ->jl.Level:
...
# Example impl of `Level`classSparseList(Level):
def__init__(self, index_type=dtypes.intp, pointer_type=dtypes.intp):
self.index_type=index_typeself.pointer_type=pointer_typedef_construct(self, *, level) ->SparseList:
returnjl.SparseList[self.index_type, self.pos_type](level)
classFormat:
levels: tuple[Level, ...]
order: tuple[int, ...]
leaf: LeafLeveldef__init__(self, *, levels: tuple[Level, ...], order: tuple[int, ...] |None, leaf: LeafLevel) ->None:
iforderisNone:
order=tuple(range(len(levels)))
iflen(order) !=len(levels):
raiseValueError(f"len(order) != len(levels), {order=}, {levels=}")
ifsorted(order) !=range(len(order)):
raiseValueError(f"sorted(order) != range(len(order)), {order=}")
self.order=orderself.levels=levelsself.leaf=leafdef_construct(self, *, fill_value, dtype) ->jl.Swizzle:
out_level=self.leaf._construct(dtype=dtype, fill_value=fill_value)
forlevelinreversed(self.levels):
out_level=level._construct(out_level)
returnjl.Swizzle(out_level, *reversed(self.order))
classDevice:
"""The memory the `Tensor` will live on; as well as the execution context. Mixing devices will err."""classTensor:
device: Deviceformat: Formatfill_value: Anydtype: dtypes.DType
...
defto_device(self, device, /) ->"Tensor":
...
defto_format(self, format, /) ->"Tensor":
...
defasarray(x: Any, /, *, dtype=None, device: Device|None=None, format: Format|None=None, fill_value: Any):
# Massage dtype/device/format into acceptable form iff `None`returnTensor(jl_data=format._construct(fill_value=fill_value, dtype=dtype))
The text was updated successfully, but these errors were encountered:
Motivation
Users may need a way to:
Tensor
is currently inFor the purposes of being able to make decisions at the code level and also to gain back some control. In a meeting with @willow-ahrens and @mtsokol we decided the following interface for the long-term.
Proposed interface
I propose a number of new classes (stubs and descriptions below):
The text was updated successfully, but these errors were encountered: