24.02
|
Go to the documentation of this file.
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
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;
101 std::vector<TensorShape> outputShapeGivenAsInput;
104 m_Weight->GetTensorInfo().GetShape() });
113 outputShapeGivenAsInput.push_back(shapeAsTensorShape);
117 "TransposeConvolution2dLayer: output calculated by InferOutputShapes and "
118 "the output given as an input parameter to the layer are not matching");
133 std::vector<armnn::ConstTensor> constTensors { { managedWeight.
GetTensorInfo(), managedWeight.
Map() } };
#define ARMNN_ASSERT(COND)
uint32_t m_PadLeft
Padding left value in the width dimension.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
void ValidateTensorShapesFromInputs() override
Check if the input tensor shape(s) will lead to a valid configuration of TransposeConvolution2dLayer.
const TensorInfo & GetTensorInfo() const override
ImmutableConstantTensors GetConstantTensorsByRef() const override
Retrieve the handles to the constant values stored by the layer.
const ConstTensorHandle * m_Weight
Provides access to the appropriate indexes for Channels, Height and Width based on DataLayout.
void ValidateAndCopyShape(const TensorShape &outputShape, const TensorShape &inferredShape, const ShapeInferenceMethod shapeInferenceMethod, const std::string &layerName, const unsigned int outputSlotIndex=0)
This layer represents a 2D transpose convolution operation.
const OutputSlot & GetOutputSlot(unsigned int index=0) const override
Get the const output slot handle by slot index.
#define ARMNN_ASSERT_MSG(COND, MSG)
const InputSlot & GetInputSlot(unsigned int index) const override
Get a const input slot handle by slot index.
const TransposeConvolution2dDescriptor & GetParameters() const override
uint32_t m_PadBottom
Padding bottom value in the height dimension.
const char * GetName() const override
Returns the name of the layer.
unsigned int GetHeightIndex() const
std::vector< std::reference_wrapper< const std::shared_ptr< ConstTensorHandle > >> ImmutableConstantTensors
std::shared_ptr< ConstTensorHandle > m_Bias
A unique pointer to store bias values.
TransposeConvolution2dDescriptor m_Param
The parameters for the layer (not including tensor-valued weights etc.).
unsigned int GetNumDimensions() const
Function that returns the tensor rank.
WorkloadInfo PrepInfoAndDesc(QueueDescriptor &descriptor) const
Helper function to reduce duplication in *Layer::CreateWorkload.
virtual std::unique_ptr< IWorkload > CreateWorkload(const IWorkloadFactory &factory) const override
Makes a workload for the TransposeConvolution2d type.
void VerifyShapeInferenceType(const TensorShape &outputShape, ShapeInferenceMethod shapeInferenceMethod)
const void * Map(bool blocking=true)
RAII Managed resource Unmaps MemoryArea once out of scope.
void SetAdditionalInfo(QueueDescriptor &descriptor) const
std::vector< TensorShape > InferOutputShapes(const std::vector< TensorShape > &inputShapes) const override
Infers the output shapes from given input shapes and layer properties.
unsigned int GetWidthIndex() const
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
const ConstTensorHandle * m_Bias
TransposeConvolution2dLayer(const TransposeConvolution2dDescriptor ¶m, const char *name)
Constructor to create a TransposeConvolution2dLayer.
std::vector< unsigned int > m_OutputShape
std::shared_ptr< ConstTensorHandle > m_Weight
A unique pointer to store weight values.
const TensorShape & GetShape() const
void ExecuteStrategy(IStrategy &strategy) const override
Apply a visitor to this layer.
uint32_t m_PadTop
Padding top value in the height dimension.
uint32_t m_PadRight
Padding right value in the width dimension.
Copyright (c) 2021 ARM Limited and Contributors.
A TransposeConvolution2dDescriptor for the TransposeConvolution2dLayer.
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
void VerifyLayerConnections(unsigned int expectedConnections, const CheckLocation &location) const
bool m_OutputShapeEnabled
Output shape if it has been specified.
bool m_BiasEnabled
Enable/disable bias.
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
ShapeInferenceMethod m_ShapeInferenceMethod
LayerType
When adding a new layer, adapt also the LastLayer enum value in the enum class LayerType below.
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
const TensorInfo & GetTensorInfo() const
TransposeConvolution2dLayer * Clone(Graph &graph) const override
Creates a dynamically-allocated copy of this layer.