Caffe2 - C++ API
A deep learning, cross platform ML framework
Generator.h
1 #pragma once
2 
3 #include <torch/csrc/python_headers.h>
4 #include <ATen/ATen.h>
5 
6 #include <torch/csrc/THP_export.h>
7 
8 struct THPGenerator {
9  PyObject_HEAD
10  at::Generator *cdata;
11  bool owner; // if true, frees cdata in destructor
12 };
13 
14 #define THPGenerator_Check(obj) \
15  PyObject_IsInstance(obj, THPGeneratorClass)
16 
17 #define THPGenerator_TH_CData(obj) \
18  (THGenerator*)((THPGenerator*)obj)->cdata->unsafeGetTH()
19 
20 THP_API PyObject * THPGenerator_New();
21 
22 // Creates a new Python object wrapping the at::Generator. The reference is
23 // borrowed. The caller should ensure that the THGenerator* object lifetime
24 // last at least as long as the Python wrapper.
25 THP_API PyObject * THPGenerator_NewWithGenerator(at::Generator& cdata);
26 
27 THP_API PyObject *THPGeneratorClass;
28 
29 #ifdef _THP_CORE
30 bool THPGenerator_init(PyObject *module);
31 #endif