| 379 | BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(SolveOverloads, Solve, 0, 1); |
| 380 | |
| 381 | BOOST_PYTHON_MODULE(_caffe) { |
| 382 | // below, we prepend an underscore to methods that will be replaced |
| 383 | // in Python |
| 384 | |
| 385 | bp::scope().attr("__version__") = AS_STRING(CAFFE_VERSION); |
| 386 | |
| 387 | // Caffe utility functions |
| 388 | bp::def("init_log", &InitLog); |
| 389 | bp::def("init_log", &InitLogLevel); |
| 390 | bp::def("init_log", &InitLogLevelPipe); |
| 391 | bp::def("log", &Log); |
| 392 | bp::def("has_nccl", &HasNCCL); |
| 393 | bp::def("set_mode_cpu", &set_mode_cpu); |
| 394 | bp::def("set_mode_gpu", &set_mode_gpu); |
| 395 | bp::def("set_random_seed", &set_random_seed); |
| 396 | bp::def("set_device", &Caffe::SetDevice); |
| 397 | bp::def("solver_count", &Caffe::solver_count); |
| 398 | bp::def("set_solver_count", &Caffe::set_solver_count); |
| 399 | bp::def("solver_rank", &Caffe::solver_rank); |
| 400 | bp::def("set_solver_rank", &Caffe::set_solver_rank); |
| 401 | bp::def("set_multiprocess", &Caffe::set_multiprocess); |
| 402 | |
| 403 | bp::def("layer_type_list", &LayerRegistry<Dtype>::LayerTypeList); |
| 404 | |
| 405 | bp::class_<Net<Dtype>, shared_ptr<Net<Dtype> >, boost::noncopyable >("Net", |
| 406 | bp::no_init) |
| 407 | // Constructor |
| 408 | .def("__init__", bp::make_constructor(&Net_Init, |
| 409 | bp::default_call_policies(), (bp::arg("network_file"), "phase", |
| 410 | bp::arg("level")=0, bp::arg("stages")=bp::object(), |
| 411 | bp::arg("weights")=bp::object()))) |
| 412 | // Legacy constructor |
| 413 | .def("__init__", bp::make_constructor(&Net_Init_Load)) |
| 414 | .def("_forward", &Net<Dtype>::ForwardFromTo) |
| 415 | .def("_backward", &Net<Dtype>::BackwardFromTo) |
| 416 | .def("reshape", &Net<Dtype>::Reshape) |
| 417 | .def("clear_param_diffs", &Net<Dtype>::ClearParamDiffs) |
| 418 | // The cast is to select a particular overload. |
| 419 | .def("copy_from", static_cast<void (Net<Dtype>::*)(const string)>( |
| 420 | &Net<Dtype>::CopyTrainedLayersFrom)) |
| 421 | .def("share_with", &Net<Dtype>::ShareTrainedLayersWith) |
| 422 | .add_property("_blob_loss_weights", bp::make_function( |
| 423 | &Net<Dtype>::blob_loss_weights, bp::return_internal_reference<>())) |
| 424 | .def("_bottom_ids", bp::make_function(&Net<Dtype>::bottom_ids, |
| 425 | bp::return_value_policy<bp::copy_const_reference>())) |
| 426 | .def("_top_ids", bp::make_function(&Net<Dtype>::top_ids, |
| 427 | bp::return_value_policy<bp::copy_const_reference>())) |
| 428 | .add_property("_blobs", bp::make_function(&Net<Dtype>::blobs, |
| 429 | bp::return_internal_reference<>())) |
| 430 | .add_property("layers", bp::make_function(&Net<Dtype>::layers, |
| 431 | bp::return_internal_reference<>())) |
| 432 | .add_property("_blob_names", bp::make_function(&Net<Dtype>::blob_names, |
| 433 | bp::return_value_policy<bp::copy_const_reference>())) |
| 434 | .add_property("_layer_names", bp::make_function(&Net<Dtype>::layer_names, |
| 435 | bp::return_value_policy<bp::copy_const_reference>())) |
| 436 | .add_property("_inputs", bp::make_function(&Net<Dtype>::input_blob_indices, |
| 437 | bp::return_value_policy<bp::copy_const_reference>())) |
| 438 | .add_property("_outputs", |
nothing calls this directly
no test coverage detected