| 250 | |
| 251 | template<typename T> |
| 252 | void evalMultiple(vector<Array<T> *> arrays) { |
| 253 | vector<Param> outputs; |
| 254 | vector<Array<T> *> output_arrays; |
| 255 | vector<Node *> nodes; |
| 256 | |
| 257 | // Check if all the arrays have the same dimension |
| 258 | auto it = std::adjacent_find(begin(arrays), end(arrays), |
| 259 | [](const Array<T> *l, const Array<T> *r) { |
| 260 | return l->dims() != r->dims(); |
| 261 | }); |
| 262 | |
| 263 | // If they are not the same. eval individually |
| 264 | if (it != end(arrays)) { |
| 265 | for (auto ptr : arrays) { ptr->eval(); } |
| 266 | return; |
| 267 | } |
| 268 | |
| 269 | for (Array<T> *array : arrays) { |
| 270 | if (array->isReady()) { continue; } |
| 271 | |
| 272 | const ArrayInfo info = array->info; |
| 273 | |
| 274 | array->setId(getActiveDeviceId()); |
| 275 | array->data = std::shared_ptr<cl::Buffer>( |
| 276 | memAlloc<T>(info.elements()).release(), bufferFree); |
| 277 | |
| 278 | // Do not replace this with cast operator |
| 279 | KParam kInfo = { |
| 280 | {info.dims()[0], info.dims()[1], info.dims()[2], info.dims()[3]}, |
| 281 | {info.strides()[0], info.strides()[1], info.strides()[2], |
| 282 | info.strides()[3]}, |
| 283 | 0}; |
| 284 | |
| 285 | outputs.emplace_back(array->data.get(), kInfo); |
| 286 | output_arrays.push_back(array); |
| 287 | nodes.push_back(array->getNode().get()); |
| 288 | } |
| 289 | |
| 290 | evalNodes(outputs, nodes); |
| 291 | |
| 292 | for (Array<T> *array : output_arrays) { array->node.reset(); } |
| 293 | } |
| 294 | |
| 295 | template<typename T> |
| 296 | Node_ptr Array<T>::getNode() { |
nothing calls this directly
no test coverage detected