#define PyArray_SetBaseObject(arr, x) (PyArray_BASE(arr) = (x))
#endif
+namespace bp = boost::python;
+
namespace caffe {
// For Python, for now, we'll just always use float as the type.
typedef float Dtype;
+void set_mode_cpu() { Caffe::set_mode(Caffe::CPU); }
+void set_mode_gpu() { Caffe::set_mode(Caffe::GPU); }
+void set_phase_train() { Caffe::set_phase(Caffe::TRAIN); }
+void set_phase_test() { Caffe::set_phase(Caffe::TEST); }
+
// For convenience, check that input files can be opened, and raise an
// exception that boost will send to Python if not (caffe could still crash
// later if the input files are disturbed before they are actually used, but
}
BOOST_PYTHON_MODULE(_caffe) {
+ // below, we prepend an underscore to methods that will be replaced
+ // in Python
+ // Caffe utility functions
+ bp::def("set_mode_cpu", &set_mode_cpu);
+ bp::def("set_mode_gpu", &set_mode_gpu);
+ bp::def("set_phase_train", &set_phase_train);
+ bp::def("set_phase_test", &set_phase_test);
+ bp::def("set_device", &Caffe::SetDevice);
+
import_array();
}