I came across pytorch’s __torch_function__
and now I was wondering if there is an equivalent in tensorflow.
For some context:
__torch_function__
is a method that allows all kinds of objects to be treated like torch.Tensors. For example if we call torch.stack([t1, t2, t3]) with t1, t2, t2 instances of OurTensor
class, this will still work, as long as the class OurTensor
implements the __torch_function__()
to tell torch how to handle our tensors.