| 67 | } |
| 68 | |
| 69 | void CheckContiguousArray(PyArrayObject* arr, string name, |
| 70 | int channels, int height, int width) { |
| 71 | if (!(PyArray_FLAGS(arr) & NPY_ARRAY_C_CONTIGUOUS)) { |
| 72 | throw std::runtime_error(name + " must be C contiguous"); |
| 73 | } |
| 74 | if (PyArray_NDIM(arr) != 4) { |
| 75 | throw std::runtime_error(name + " must be 4-d"); |
| 76 | } |
| 77 | if (PyArray_TYPE(arr) != NPY_FLOAT32) { |
| 78 | throw std::runtime_error(name + " must be float32"); |
| 79 | } |
| 80 | if (PyArray_DIMS(arr)[1] != channels) { |
| 81 | throw std::runtime_error(name + " has wrong number of channels"); |
| 82 | } |
| 83 | if (PyArray_DIMS(arr)[2] != height) { |
| 84 | throw std::runtime_error(name + " has wrong height"); |
| 85 | } |
| 86 | if (PyArray_DIMS(arr)[3] != width) { |
| 87 | throw std::runtime_error(name + " has wrong width"); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | // Net constructor |
| 92 | shared_ptr<Net<Dtype> > Net_Init(string network_file, int phase, |
no outgoing calls
no test coverage detected