Shortcuts

Struct Obj

Struct Documentation

struct Obj

this is a wrapper class that refers to a PyObject* instance in a particular interpreter.

We can’t use normal PyObject or pybind11 objects here because these objects get used in a user application which will not directly link against libpython. Instead all owningSession with the Python state in each interpreter is done via this wrapper class, and methods on InterpreterSession.

Public Functions

inline explicit Obj(std::shared_ptr<InterpreterObj> baseObj)
inline Obj()
inline at::IValue toIValue() const

Converts the python object to a C++ at::IValue.

inline Obj operator()(at::ArrayRef<Obj> args)

Call an Obj callable, with arguments given by the tuple args.

Equivalent to __call__ in python.

inline Obj operator()(at::ArrayRef<at::IValue> args)

Call an Obj callable, with arguments given by the tuple args.

Equivalent to __call__ in python.

inline Obj callKwargs(std::vector<at::IValue> args, std::unordered_map<std::string, c10::IValue> kwargs)

Call an Obj callable, with arguments given by the tuple args, and named arguments given by the dictionary kwargs.

Equivalent to __call__ in python.

inline Obj callKwargs(std::unordered_map<std::string, c10::IValue> kwargs)

Call an Obj callable, with named arguments given by the dictionary kwargs.

Equivalent to __call__ in python.

inline bool hasattr(const char *attr)

Returns true if Obj has attribute with name attr and false otherwise.

inline Obj attr(const char *attr)

Returns attribute attr from Obj.

This is equivalent to calling getattr(Obj, attr) in python.

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources