| 375 | /// Removes empty columns from output and the other node pointers in \p nodes |
| 376 | template<typename ParamT, typename BufferNodeT, typename ShiftNodeT> |
| 377 | void removeEmptyDimensions(nonstd::span<ParamT> outputs, |
| 378 | nonstd::span<Node_ptr> nodes) { |
| 379 | dim_t *outDims{outputs[0].dims_ptr()}; |
| 380 | dim_t *outStrides{outputs[0].strides_ptr()}; |
| 381 | auto shifts = compressArray(outDims); |
| 382 | applyShifts<dim_t>(shifts, {outStrides, AF_MAX_DIMS}); |
| 383 | for (auto nodeIt{begin(nodes)}, endIt{end(nodes)}; |
| 384 | (nodeIt = find_if(nodeIt, endIt, isBufferOrShift)) != endIt; |
| 385 | ++nodeIt) { |
| 386 | switch ((*nodeIt)->getNodeType()) { |
| 387 | case kNodeType::Buffer: { |
| 388 | BufferNodeT *buf{static_cast<BufferNodeT *>(nodeIt->get())}; |
| 389 | applyShifts<dim_t>(shifts, |
| 390 | {buf->m_param.dims_ptr(), AF_MAX_DIMS}); |
| 391 | applyShifts<dim_t>(shifts, |
| 392 | {buf->m_param.strides_ptr(), AF_MAX_DIMS}); |
| 393 | } break; |
| 394 | case kNodeType::Shift: { |
| 395 | ShiftNodeT &shiftNode{ |
| 396 | *static_cast<ShiftNodeT *>(nodeIt->get())}; |
| 397 | BufferNodeT &buf{shiftNode.getBufferNode()}; |
| 398 | applyShifts<dim_t>(shifts, |
| 399 | {buf.m_param.dims_ptr(), AF_MAX_DIMS}); |
| 400 | applyShifts<dim_t>(shifts, |
| 401 | {buf.m_param.strides_ptr(), AF_MAX_DIMS}); |
| 402 | |
| 403 | auto &node_shifts = shiftNode.getShifts(); |
| 404 | applyShifts<int>(shifts, node_shifts); |
| 405 | } break; |
| 406 | default: break; |
| 407 | } |
| 408 | } |
| 409 | std::for_each( |
| 410 | std::begin(outputs) + 1, std::end(outputs), [&shifts](ParamT &output) { |
| 411 | applyShifts<dim_t>(shifts, {output.dims_ptr(), AF_MAX_DIMS}); |
| 412 | applyShifts<dim_t>(shifts, {output.strides_ptr(), AF_MAX_DIMS}); |
| 413 | }); |
| 414 | } |
| 415 | |
| 416 | } // namespace common |
| 417 | } // namespace arrayfire |
nothing calls this directly
no test coverage detected