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