24.08
|
Go to the documentation of this file.
53 const std::vector<TensorShape>& inputShapes)
const
55 if (inputShapes.size() != 1)
57 throw armnn::Exception(
"inputShapes' size is \"" + std::to_string(inputShapes.size()) +
58 "\" - should be \"1\".");
62 std::vector<unsigned int> outputShape;
63 unsigned int amountDimShrunk{0};
78 int realEllipsisMask = 0, realNewAxisMask = 0;
80 unsigned int ellipsisExpandedBy = 0;
81 for(
unsigned int i = 0; i < outputDims; ++i)
87 unsigned int endIdx = std::min(i + 1u + outputDims - inputShape.
GetNumDimensions(), outputDims);
90 ellipsisExpandedBy = endIdx - i - 1;
93 for(; i < endIdx; ++i)
95 realEllipsisMask |= (1 << i);
102 realNewAxisMask |= (1 << i);
107 unsigned int inputDimOffset = 0;
109 for (
unsigned int i = 0; i < outputDims; ++i)
112 if(realEllipsisMask & (1 << i))
114 outputShape.push_back(inputShape[i - inputDimOffset]);
118 if(realNewAxisMask & (1 << i))
120 outputShape.push_back(1);
129 if(realEllipsisMask > 0)
131 outputShape.push_back(1);
135 outputShape.push_back(inputShape[i - inputDimOffset]);
153 "StridedSlice: Attempting to take a larger slice than can fit in inferred output");
159 "StridedSlice: Stride can not be negative with Shrink Axis Mask set.");
164 int newSize = stride > 0 ? ((stop - start) + stride - 1) / stride :
165 ((start - stop) - stride - 1) / -stride;
168 newSize = std::max(0, newSize);
169 newSize = std::min(newSize, armnn::numeric_cast<int>(inputShape[i - inputDimOffset]));
171 outputShape.push_back(armnn::numeric_cast<unsigned int>(newSize));
174 if (outputShape.size() == 0 && (inputShape.
GetNumDimensions() - amountDimShrunk) == 0)
176 outputShape.push_back(1);
179 return std::vector<TensorShape>({
180 TensorShape(armnn::numeric_cast<unsigned int>(outputShape.size()), &outputShape[0]) });
193 if (inferredShapes.size() != 1)
196 + std::to_string(inferredShapes.size()) +
197 " elements - should only have 1.");
const TensorInfo & GetTensorInfo() const override
std::vector< int > m_Begin
Begin values for the input that will be sliced.
int32_t m_EllipsisMask
Ellipsis mask value.
void ValidateAndCopyShape(const TensorShape &outputShape, const TensorShape &inferredShape, const ShapeInferenceMethod shapeInferenceMethod, const std::string &layerName, const unsigned int outputSlotIndex=0)
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
int32_t m_BeginMask
Begin mask value.
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
const StridedSliceDescriptor & GetParameters() const override
StridedSliceLayer * Clone(Graph &graph) const override
Creates a dynamically-allocated copy of this layer.
const char * GetName() const override
Returns the name of the layer.
int GetStopForAxis(const TensorShape &inputShape, unsigned int axis, int startForAxis) const
StridedSliceDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
LayerDescriptor m_Parameters
unsigned int GetNumDimensions() const
Function that returns the tensor rank.
void ValidateTensorShapesFromInputs() override
Check if the input tensor shape(s) will lead to a valid configuration of StridedSliceLayer.
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *Layer::CreateWorkload.
void VerifyShapeInferenceType(const TensorShape &outputShape, ShapeInferenceMethod shapeInferenceMethod)
void SetAdditionalInfo(QueueDescriptor &descriptor) const
Base class for all ArmNN exceptions so that users can filter to just those.
int32_t m_EndMask
End mask value.
int32_t m_ShrinkAxisMask
Shrink axis mask value. If set, the nth specification shrinks the dimensionality by 1.
This layer represents a strided slice operation.
std::vector< int > m_Stride
Stride values for the input that will be sliced.
A StridedSliceDescriptor for the StridedSliceLayer.
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const override
Makes a workload for the StridedSlice type.
const TensorShape & GetShape() const
int GetStartForAxis(const TensorShape &inputShape, unsigned int axis) const
Copyright (c) 2021 ARM Limited and Contributors.
void StridedSlice(const TensorInfo &inputInfo, const StridedSliceDescriptor ¶ms, const void *inputData, void *outputData, unsigned int dataTypeSize)
std::vector< int > m_End
End values for the input that will be sliced.
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
StridedSliceLayer(const StridedSliceDescriptor ¶m, const char *name)
Constructor to create a StridedSliceLayer.
std::vector< TensorShape > InferOutputShapes(const std::vector< TensorShape > &inputShapes) const override
By default returns inputShapes if the number of inputs are equal to number of outputs,...
void ExecuteStrategy(IStrategy &strategy) const override
Apply a visitor to this layer.
ShapeInferenceMethod m_ShapeInferenceMethod
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below.
int32_t m_NewAxisMask
New axis mask value.
virtual std::unique_ptr< IWorkload > CreateWorkload(LayerType type, const QueueDescriptor &descriptor, const WorkloadInfo &info) const =0
Backends should implement their own CreateWorkload function with a switch statement.
virtual void ExecuteStrategy(const IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0)=0