Does any similar feature exist for PyTorch tensors? I’ve tried several things, but unfortunately not been able to get it working. I found a similar discussion from a year ago but no good answer was provided.
This almost works, but it fails to capture one of the key benefits of the numpy subclassing: various operations, most notably slicing and basic operations like addition, preserve the added information. I’d like to be able to run: print(obj1[:2].extra_data).
Furthermore, is there any way to subclass boolean, integer, or other types of tensors? Currently, using them as a base class throws an error. But I can find no way to modify or set the type of a tensor subclass; it’s stuck on float32.