| 2623 | } |
| 2624 | |
| 2625 | void TfLiteParserImpl::ParseStridedSlice(size_t subgraphIndex, size_t operatorIndex) |
| 2626 | { |
| 2627 | CHECK_MODEL(m_Model, subgraphIndex, operatorIndex); |
| 2628 | |
| 2629 | auto inputs = GetInputs(m_Model, subgraphIndex, operatorIndex); |
| 2630 | CHECK_VALID_SIZE(inputs.size(), 4); |
| 2631 | |
| 2632 | auto outputs = GetOutputs(m_Model, subgraphIndex, operatorIndex); |
| 2633 | CHECK_VALID_SIZE(outputs.size(), 1); |
| 2634 | |
| 2635 | const auto& operatorPtr = m_Model->subgraphs[subgraphIndex]->operators[operatorIndex]; |
| 2636 | const auto* options = operatorPtr->builtin_options.AsStridedSliceOptions(); |
| 2637 | |
| 2638 | StridedSliceDescriptor desc; |
| 2639 | desc.m_BeginMask = options->begin_mask; |
| 2640 | desc.m_EllipsisMask = options->ellipsis_mask; |
| 2641 | desc.m_EndMask = options->end_mask; |
| 2642 | desc.m_NewAxisMask = options->new_axis_mask; |
| 2643 | desc.m_ShrinkAxisMask = options->shrink_axis_mask; |
| 2644 | desc.m_DataLayout = armnn::DataLayout::NHWC; |
| 2645 | |
| 2646 | armnn::TensorInfo beginTensorInfo = InputTensorInfo(subgraphIndex, operatorIndex, 1); |
| 2647 | BufferRawPtr beginBufferPtr = GetBuffer(m_Model, inputs[1]->buffer); |
| 2648 | ValidateBuffer(beginBufferPtr, beginTensorInfo, "begin"); |
| 2649 | |
| 2650 | std::vector<int> begin(beginTensorInfo.GetNumElements()); |
| 2651 | if (beginBufferPtr->data.data() != nullptr) |
| 2652 | { |
| 2653 | ::memcpy(begin.data(), beginBufferPtr->data.data(), beginTensorInfo.GetNumBytes()); |
| 2654 | } |
| 2655 | else |
| 2656 | { |
| 2657 | throw ParseException("ParseStridedSlice: Invalid input - the begin vector is null"); |
| 2658 | } |
| 2659 | |
| 2660 | armnn::TensorInfo endTensorInfo = InputTensorInfo(subgraphIndex, operatorIndex, 2); |
| 2661 | BufferRawPtr endBufferPtr = GetBuffer(m_Model, inputs[2]->buffer); |
| 2662 | ValidateBuffer(endBufferPtr, endTensorInfo, "end"); |
| 2663 | |
| 2664 | std::vector<int> end(endTensorInfo.GetNumElements()); |
| 2665 | if (endBufferPtr->data.data() != nullptr) |
| 2666 | { |
| 2667 | ::memcpy(end.data(), endBufferPtr->data.data(), endTensorInfo.GetNumBytes()); |
| 2668 | } |
| 2669 | else |
| 2670 | { |
| 2671 | throw ParseException("ParseStridedSlice: Invalid input - the end vector is null"); |
| 2672 | } |
| 2673 | |
| 2674 | armnn::TensorInfo strideTensorInfo = InputTensorInfo(subgraphIndex, operatorIndex, 3); |
| 2675 | BufferRawPtr strideBufferPtr = GetBuffer(m_Model, inputs[3]->buffer); |
| 2676 | ValidateBuffer(strideBufferPtr, strideTensorInfo, "stride"); |
| 2677 | |
| 2678 | std::vector<int> stride(strideTensorInfo.GetNumElements()); |
| 2679 | |
| 2680 | if (strideBufferPtr->data.data() != nullptr) |
| 2681 | { |
| 2682 | ::memcpy(stride.data(), strideBufferPtr->data.data(), strideTensorInfo.GetNumBytes()); |
nothing calls this directly
no test coverage detected