| 84 | } |
| 85 | |
| 86 | void CheckContiguousArray(PyArrayObject* arr, string name, |
| 87 | int channels, int height, int width) { |
| 88 | if (!(PyArray_FLAGS(arr) & NPY_ARRAY_C_CONTIGUOUS)) { |
| 89 | throw std::runtime_error(name + " must be C contiguous"); |
| 90 | } |
| 91 | if (PyArray_NDIM(arr) != 4) { |
| 92 | throw std::runtime_error(name + " must be 4-d"); |
| 93 | } |
| 94 | if (PyArray_TYPE(arr) != NPY_FLOAT32) { |
| 95 | throw std::runtime_error(name + " must be float32"); |
| 96 | } |
| 97 | if (PyArray_DIMS(arr)[1] != channels) { |
| 98 | throw std::runtime_error(name + " has wrong number of channels"); |
| 99 | } |
| 100 | if (PyArray_DIMS(arr)[2] != height) { |
| 101 | throw std::runtime_error(name + " has wrong height"); |
| 102 | } |
| 103 | if (PyArray_DIMS(arr)[3] != width) { |
| 104 | throw std::runtime_error(name + " has wrong width"); |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | // Net constructor |
| 109 | shared_ptr<Net<Dtype> > Net_Init(string network_file, int phase, |
no outgoing calls
no test coverage detected