12 #include <boost/numeric/conversion/cast.hpp> 46 const std::vector<TensorShape>& inputShapes)
const 48 BOOST_ASSERT(inputShapes.size() == 1);
51 std::vector<unsigned int> outputShape;
53 for (
unsigned int i = 0; i < inputShape.GetNumDimensions(); i++)
64 int newSize = stride > 0 ? ((stop - start) + stride - 1) / stride :
65 ((start - stop) - stride - 1) / -stride;
67 newSize = std::max(0, newSize);
69 outputShape.push_back(boost::numeric_cast<unsigned int>(newSize));
72 return std::vector<TensorShape>({
73 TensorShape(boost::numeric_cast<unsigned int>(outputShape.size()), &outputShape[0]) });
82 BOOST_ASSERT(inferredShapes.size() == 1);
84 ConditionalThrowIfNotEqual<LayerValidationException>(
85 "StridedSlice: TensorShape set on OutputSlot[0] does not match the inferred shape.",
StridedSliceDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
const StridedSliceDescriptor & GetParameters() const
const TensorShape & GetShape() const
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const override
Makes a workload for the StridedSlice type.
int32_t m_ShrinkAxisMask
Shrink axis mask value. If set, the nth specification shrinks the dimensionality by 1...
std::vector< int > m_Begin
Begin values for the input that will be sliced.
int GetStartForAxis(const TensorShape &inputShape, unsigned int axis) const
virtual std::unique_ptr< IWorkload > CreateStridedSlice(const StridedSliceQueueDescriptor &descriptor, const WorkloadInfo &Info) const
void ValidateTensorShapesFromInputs() override
Check if the input tensor shape(s) will lead to a valid configuration of StridedSliceLayer.
Copyright (c) 2020 ARM Limited.
int32_t m_BeginMask
Begin mask value.
int32_t m_EndMask
End mask value.
LayerDescriptor m_Parameters
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
virtual void VisitStridedSliceLayer(const IConnectableLayer *layer, const StridedSliceDescriptor &stridedSliceDescriptor, const char *name=nullptr)=0
Function a strided slice layer should call back to when its Accept(ILayerVisitor&) function is invoke...
int32_t m_NewAxisMask
New axis mask value.
int32_t m_EllipsisMask
Ellipsis mask value.
std::vector< int > m_Stride
Stride values for the input that will be sliced.
std::vector< int > m_End
End values for the input that will be sliced.
void Accept(ILayerVisitor &visitor) const override
Apply a visitor to this layer.
void StridedSlice(const TensorInfo &inputInfo, const StridedSliceDescriptor ¶ms, const void *inputData, void *outputData, unsigned int dataTypeSize)
StridedSliceLayer * Clone(Graph &graph) const override
Creates a dynamically-allocated copy of this layer.
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *LayerCreateWorkload.
This layer represents a strided slice operation.
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
A StridedSliceDescriptor for the StridedSliceLayer.
virtual const TensorInfo & GetTensorInfo() const =0
int GetStopForAxis(const TensorShape &inputShape, unsigned int axis, int startForAxis) const
const char * GetName() const override
Returns the name of the layer.
const TensorInfo & GetTensorInfo() const override
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, otherwise infers the output shapes from given input shapes and layer properties.