Hi, is it by design that torch.from_blob is not exposed in the python API? Or am I looking in the wrong places? I find plenty of docs with respect on how to use it in C++ interface but on python3.11, torch==2.1.2+cu121 (cuda 12.1), I cannot seem to find it. Context is I work in a python heavy shop and would like to be able to express/execute from_blob in python code.
Hey!
We indeed don’t expose that API to python for three main reasons: it is quite dangerous as the ownership system is not something that is “pythonic”, it requires some arguments/constructors to be c++ constructs to properly interface with the c++ backend and we never needed it.
In particular, most systems using it like NumPy or DLPack interrop already work within c++ and so we never had the need.
I would also mention that for testing, I’ve use torch.util.cpp_extension.load_inline()
to write a small wrapper around that API and expose specific behavior to Python.
If you have a good use case for it and we can come up with a good pythonic API for it, we can definitely add that.
If you’re interested, the first step would be to open an issue with details on the new python API so we can discuss that because adding the binding.