| 200 | |
| 201 | template<typename T> |
| 202 | void evalMultiple(std::vector<Array<T> *> arrays) { |
| 203 | vector<Param<T>> output_params; |
| 204 | vector<Array<T> *> output_arrays; |
| 205 | vector<Node *> nodes; |
| 206 | |
| 207 | // Check if all the arrays have the same dimension |
| 208 | auto it = std::adjacent_find(begin(arrays), end(arrays), |
| 209 | [](const Array<T> *l, const Array<T> *r) { |
| 210 | return l->dims() != r->dims(); |
| 211 | }); |
| 212 | |
| 213 | // If they are not the same. eval individually |
| 214 | if (it != end(arrays)) { |
| 215 | for (auto ptr : arrays) { ptr->eval(); } |
| 216 | return; |
| 217 | } |
| 218 | |
| 219 | for (Array<T> *array : arrays) { |
| 220 | if (array->isReady()) { continue; } |
| 221 | |
| 222 | array->setId(getActiveDeviceId()); |
| 223 | array->data = |
| 224 | shared_ptr<T>(memAlloc<T>(array->elements()).release(), memFree); |
| 225 | |
| 226 | output_params.emplace_back(array->getData().get(), array->dims().get(), |
| 227 | array->strides().get()); |
| 228 | output_arrays.push_back(array); |
| 229 | nodes.push_back(array->getNode().get()); |
| 230 | } |
| 231 | |
| 232 | if (output_params.empty()) return; |
| 233 | |
| 234 | evalNodes(output_params, nodes); |
| 235 | |
| 236 | for (Array<T> *array : output_arrays) { array->node.reset(); } |
| 237 | } |
| 238 | |
| 239 | template<typename T> |
| 240 | Node_ptr Array<T>::getNode() { |
nothing calls this directly
no test coverage detected