| 124 | |
| 125 | template<typename T> |
| 126 | void evalMultiple(std::vector<Param<T>> arrays, |
| 127 | std::vector<common::Node_ptr> output_nodes_) { |
| 128 | using arrayfire::common::ModdimNode; |
| 129 | using arrayfire::common::Node; |
| 130 | using arrayfire::common::Node_map_t; |
| 131 | using arrayfire::common::NodeIterator; |
| 132 | |
| 133 | af::dim4 odims = arrays[0].dims(); |
| 134 | af::dim4 ostrs = arrays[0].strides(); |
| 135 | |
| 136 | Node_map_t node_index_map; |
| 137 | std::vector<T *> ptrs; |
| 138 | std::vector<common::Node *> full_nodes; |
| 139 | std::vector<common::Node_ids> ids; |
| 140 | |
| 141 | int narrays = static_cast<int>(arrays.size()); |
| 142 | ptrs.reserve(narrays); |
| 143 | for (int i = 0; i < narrays; i++) { |
| 144 | ptrs.push_back(arrays[i].get()); |
| 145 | output_nodes_[i]->getNodesMap(node_index_map, full_nodes, ids); |
| 146 | } |
| 147 | auto node_clones = cloneNodes(full_nodes, ids); |
| 148 | |
| 149 | std::vector<TNode<T> *> cloned_output_nodes = |
| 150 | getClonedOutputNodes<T>(node_index_map, node_clones, output_nodes_); |
| 151 | propagateModdimsShape(node_clones); |
| 152 | removeNodeOfOperation(node_clones, af_moddims_t); |
| 153 | |
| 154 | bool is_linear = true; |
| 155 | for (auto &node : node_clones) { is_linear &= node->isLinear(odims.get()); } |
| 156 | |
| 157 | int num_nodes = node_clones.size(); |
| 158 | int num_output_nodes = cloned_output_nodes.size(); |
| 159 | if (is_linear) { |
| 160 | int num = arrays[0].dims().elements(); |
| 161 | int cnum = |
| 162 | jit::VECTOR_LENGTH * std::ceil(double(num) / jit::VECTOR_LENGTH); |
| 163 | for (int i = 0; i < cnum; i += jit::VECTOR_LENGTH) { |
| 164 | int lim = std::min(jit::VECTOR_LENGTH, num - i); |
| 165 | for (int n = 0; n < num_nodes; n++) { |
| 166 | node_clones[n]->calc(i, lim); |
| 167 | } |
| 168 | for (int n = 0; n < num_output_nodes; n++) { |
| 169 | std::copy(cloned_output_nodes[n]->m_val.begin(), |
| 170 | cloned_output_nodes[n]->m_val.begin() + lim, |
| 171 | ptrs[n] + i); |
| 172 | } |
| 173 | } |
| 174 | } else { |
| 175 | for (int w = 0; w < (int)odims[3]; w++) { |
| 176 | dim_t offw = w * ostrs[3]; |
| 177 | |
| 178 | for (int z = 0; z < (int)odims[2]; z++) { |
| 179 | dim_t offz = z * ostrs[2] + offw; |
| 180 | |
| 181 | for (int y = 0; y < (int)odims[1]; y++) { |
| 182 | dim_t offy = y * ostrs[1] + offz; |
| 183 |
nothing calls this directly
no test coverage detected