45 auto layer = CloneBase<TransposeConvolution2dLayer>(graph,
m_Param,
GetName());
49 if (layer->m_Param.m_BiasEnabled)
54 return std::move(layer);
58 const std::vector<TensorShape>& inputShapes)
const 64 ARMNN_ASSERT_MSG(inputShape.GetNumDimensions() == 4,
"Transpose convolutions will always have 4D input");
68 const unsigned int batches = inputShape[0];
70 const unsigned int wInput = inputShape[dataLayoutIndex.GetWidthIndex()];
71 const unsigned int hInput = inputShape[dataLayoutIndex.GetHeightIndex()];
73 const unsigned int wKernel = kernelShape[dataLayoutIndex.GetWidthIndex()];
74 const unsigned int hKernel = kernelShape[dataLayoutIndex.GetHeightIndex()];
79 unsigned int wOutput = (wInput - 1) *
m_Param.
m_StrideX + wKernel - wPadding;
80 unsigned int hOutput = (hInput - 1) *
m_Param.
m_StrideY + hKernel - hPadding;
81 unsigned int cOutput = kernelShape[0];
84 TensorShape( { batches, hOutput, wOutput, cOutput } ) :
85 TensorShape( { batches, cOutput, hOutput, wOutput });
87 return std::vector<TensorShape>({ tensorShape });
100 std::vector<TensorShape> expectedOutputShape;
106 expectedOutputShape.push_back(shapeAsTensorShape);
111 m_Weight->GetTensorInfo().GetShape() });
143 std::vector<armnn::ConstTensor> constTensors { { managedWeight.
GetTensorInfo(), managedWeight.
Map() } };
ConstantTensors GetConstantTensorsByRef() override
Retrieve the handles to the constant values stored by the layer.
TransposeConvolution2dDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
const TransposeConvolution2dDescriptor & GetParameters() const
This layer represents a 2D transpose convolution operation.
A TransposeConvolution2dDescriptor for the TransposeConvolution2dLayer.
const TensorShape & GetShape() const
void ExecuteStrategy(IStrategy &strategy) const override
Apply a visitor to this layer.
virtual void ExecuteStrategy(const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0)=0
bool m_BiasEnabled
Enable/disable bias.
std::vector< unsigned int > m_OutputShape
bool m_OutputShapeEnabled
Output shape if it has been specified.
void Accept(ILayerVisitor &visitor) const override
Apply a visitor to this layer.
void VerifyShapeInferenceType(const TensorShape &outputShape, ShapeInferenceMethod shapeInferenceMethod)
const TensorInfo & GetTensorInfo() const
Copyright (c) 2021 ARM Limited and Contributors.
uint32_t m_PadBottom
Padding bottom value in the height dimension.
void ValidateAndCopyShape(const TensorShape &outputShape, const TensorShape &inferredShape, const ShapeInferenceMethod shapeInferenceMethod, const std::string &layerName, const unsigned int outputSlotIndex=0)
void ValidateTensorShapesFromInputs() override
Check if the input tensor shape(s) will lead to a valid configuration of TransposeConvolution2dLayer...
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.
TransposeConvolution2dLayer(const TransposeConvolution2dDescriptor ¶m, const char *name)
Constructor to create a TransposeConvolution2dLayer.
std::vector< std::reference_wrapper< std::shared_ptr< ConstTensorHandle > >> ConstantTensors
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const override
Makes a workload for the TransposeConvolution2d type.
#define ARMNN_ASSERT_MSG(COND, MSG)
std::shared_ptr< ConstTensorHandle > m_Bias
A unique pointer to store bias values.
Provides access to the appropriate indexes for Channels, Height and Width based on DataLayout...
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
uint32_t m_PadTop
Padding top value in the height dimension.
#define ARMNN_ASSERT(COND)
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
void SetAdditionalInfo(QueueDescriptor &descriptor) const
uint32_t m_PadLeft
Padding left value in the width dimension.
EmptyOptional is used to initialize the Optional class in case we want to have default value for an O...
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
virtual void VisitTransposeConvolution2dLayer(const IConnectableLayer *layer, const TransposeConvolution2dDescriptor &descriptor, const ConstTensor &weights, const Optional< ConstTensor > &biases, const char *name=nullptr)=0
Function that a 2D transpose convolution layer should call back to when its Accept(ILayerVisitor&) fu...
virtual std::unique_ptr< IWorkload > CreateTransposeConvolution2d(const TransposeConvolution2dQueueDescriptor &descriptor, const WorkloadInfo &info) const
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *LayerCreateWorkload.
uint32_t m_PadRight
Padding right value in the width dimension.
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
virtual const TensorInfo & GetTensorInfo() const =0
const char * GetName() const override
Returns the name of the layer.
const ConstTensorHandle * m_Weight
const void * Map(bool blocking=true)
RAII Managed resource Unmaps MemoryArea once out of scope.
TransposeConvolution2dLayer * Clone(Graph &graph) const override
Creates a dynamically-allocated copy of this layer.
const ConstTensorHandle * m_Bias
std::vector< TensorShape > InferOutputShapes(const std::vector< TensorShape > &inputShapes) const override
Infers the output shapes from given input shapes and layer properties.
const TensorInfo & GetTensorInfo() const override
std::shared_ptr< ConstTensorHandle > m_Weight
A unique pointer to store weight values.
ShapeInferenceMethod m_ShapeInferenceMethod
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below...