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.",
int GetStopForAxis(const TensorShape &inputShape, unsigned int axis, int startForAxis) const
const char * GetName() const override
virtual const TensorInfo & GetTensorInfo() const =0
std::vector< int > m_Stride
Stride values for the input that will be sliced.
int32_t m_NewAxisMask
New axis mask value. If set, the begin, end and stride is disregarded and a new 1 dimension is insert...
LayerDescriptor m_Parameters
void Accept(ILayerVisitor &visitor) const override
std::vector< int > m_Begin
Begin values for the input that will be sliced.
StridedSliceLayer * Clone(Graph &graph) const override
void ValidateTensorShapesFromInputs() override
const StridedSliceDescriptor & GetParameters() const
std::vector< int > m_End
End values for the input that will be sliced.
StridedSliceDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
virtual void VisitStridedSliceLayer(const IConnectableLayer *layer, const StridedSliceDescriptor &stridedSliceDescriptor, const char *name=nullptr)=0
void StridedSlice(const TensorInfo &inputInfo, const StridedSliceDescriptor ¶ms, const void *inputData, void *outputData, unsigned int dataTypeSize)
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *LayerCreateWorkload.
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const override
int32_t m_EllipsisMask
Ellipsis mask value.
int32_t m_BeginMask
Begin mask value. If set, then the begin is disregarded and the fullest range is used for the dimensi...
This layer represents a strided slice operation.
std::vector< TensorShape > InferOutputShapes(const std::vector< TensorShape > &inputShapes) const override
int32_t m_ShrinkAxisMask
Shrink axis mask value. If set, the nth specification shrinks the dimensionality by 1...
virtual std::unique_ptr< IWorkload > CreateStridedSlice(const StridedSliceQueueDescriptor &descriptor, const WorkloadInfo &Info) const
const TensorShape & GetShape() const
StridedSliceLayer(const StridedSliceDescriptor ¶m, const char *name)
const TensorInfo & GetTensorInfo() const override
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
int32_t m_EndMask
End mask value. If set, then the end is disregarded and the fullest range is used for the dimension...
int GetStartForAxis(const TensorShape &inputShape, unsigned int axis) const
const InputSlot & GetInputSlot(unsigned int index) const override
A StridedSliceDescriptor for the StridedSliceLayer.