MCPcopy Create free account
hub / github.com/alexgkendall/caffe-segnet / check_contiguous_array

Method check_contiguous_array

python/caffe/_caffe.cpp:162–182  ·  view source on GitHub ↗

Generate Python exceptions for badly shaped or discontiguous arrays.

Source from the content-addressed store, hash-verified

160
161 // Generate Python exceptions for badly shaped or discontiguous arrays.
162 inline void check_contiguous_array(PyArrayObject* arr, string name,
163 int channels, int height, int width) {
164 if (!(PyArray_FLAGS(arr) & NPY_ARRAY_C_CONTIGUOUS)) {
165 throw std::runtime_error(name + " must be C contiguous");
166 }
167 if (PyArray_NDIM(arr) != 4) {
168 throw std::runtime_error(name + " must be 4-d");
169 }
170 if (PyArray_TYPE(arr) != NPY_FLOAT32) {
171 throw std::runtime_error(name + " must be float32");
172 }
173 if (PyArray_DIMS(arr)[1] != channels) {
174 throw std::runtime_error(name + " has wrong number of channels");
175 }
176 if (PyArray_DIMS(arr)[2] != height) {
177 throw std::runtime_error(name + " has wrong height");
178 }
179 if (PyArray_DIMS(arr)[3] != width) {
180 throw std::runtime_error(name + " has wrong width");
181 }
182 }
183
184 void Forward(int start, int end) {
185 net_->ForwardFromTo(start, end);

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected