Easy-Transformer
Easy-Transformer copied to clipboard
Make `FactoredMatrix` compatible with tensor-like arguments
Description
I'd like to be able to use FactoredMatrix with things that implement the interface of torch.Tensor without subclassing it. This slight change allows FactoredMatrix to work with such classes rather than returning None in various places.
(I haven't finished the checklists, so creating this draft PR so I don't forget about this)
Type of change
Please delete options that are not relevant.
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] This change requires a documentation update
Checklist:
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [x] I have not rewritten tests relating to key interfaces which would affect backward compatibility
@JasonGross Do you still have a bit to wrap up on this? If you need any help getting this out the door let me know. If you could add a test for this, that would be greatly appreciated as well.