Implement a Tensor protocol and a generic Arithmetics protocol to allow to control what functions are available on a Tensor.
To get an idea how it should looks like:
class Tensor:
pass
T_Tensor = TypeVar("T_Tensor", bound=Tensor)
class Arithmetics(Protocol[T_Tensor]):
def add(a: T_Tensor, b: T_Tensor) -> T_Tensor:
...
class TorchTensorWrapper(Tensor):
def __init__(self, wrapped: torch.Tensor) -> None:
...
class FixedPointTensor(Tensor):
def __init__(self, wrapped: torch.Tensor) -> None:
self._wrapped = wrapped
self.frac_bits = 8
...
class FixedPointArithmetics(Arithmetics[FixedPointTensor]):
...
Implement a Tensor protocol and a generic Arithmetics protocol to allow to control what functions are available on a Tensor. To get an idea how it should looks like: