23.05
|
Shape of a tensor. More...
#include <TensorShape.h>
Public Member Functions | |
template<typename... Ts> | |
TensorShape (Ts... dims) | |
Constructor to initialize the tensor shape. More... | |
TensorShape (const TensorShape &)=default | |
Allow instances of this class to be copy constructed. More... | |
TensorShape & | operator= (const TensorShape &)=default |
Allow instances of this class to be copied. More... | |
TensorShape (TensorShape &&)=default | |
Allow instances of this class to be move constructed. More... | |
TensorShape & | operator= (TensorShape &&)=default |
Allow instances of this class to be moved. More... | |
~TensorShape ()=default | |
Default destructor. More... | |
TensorShape & | set (size_t dimension, size_t value, bool apply_dim_correction=true, bool increase_dim_unit=true) |
Accessor to set the value of one of the dimensions. More... | |
void | remove_dimension (size_t n) |
Accessor to remove the dimension n from the tensor shape. More... | |
void | collapse (size_t n, size_t first=0) |
Collapse the first n dimensions. More... | |
void | shift_right (size_t step) |
Shifts right the tensor shape increasing its dimensions. More... | |
TensorShape | collapsed_from (size_t start) const |
Return a copy with collapsed dimensions starting from a given point. More... | |
size_t | total_size () const |
Collapses all dimensions to a single linear total size. More... | |
size_t | total_size_upper (size_t dimension) const |
Collapses given dimension and above. More... | |
size_t | total_size_lower (size_t dimension) const |
Compute size of dimensions lower than the given one. More... | |
![]() | |
Dimensions (Ts... dims) | |
Constructor to initialize the tensor shape. More... | |
Dimensions (const Dimensions &)=default | |
Allow instances of this class to be copy constructed. More... | |
Dimensions (Dimensions &&)=default | |
Allow instances of this class to be move constructed. More... | |
Dimensions & | operator= (const Dimensions &)=default |
Allow instances of this class to be copied. More... | |
Dimensions & | operator= (Dimensions &&)=default |
Allow instances of this class to be moved. More... | |
void | set (size_t dimension, size_t value, bool increase_dim_unit=true) |
Accessor to set the value of one of the dimensions. More... | |
size_t | x () const |
Alias to access the size of the first dimension. More... | |
size_t | y () const |
Alias to access the size of the second dimension. More... | |
size_t | z () const |
Alias to access the size of the third dimension. More... | |
void | increment (size_t dim, size_t step=1) |
Increments the given dimension by a step size, avoiding overflows. More... | |
const size_t & | operator[] (size_t dimension) const |
Generic accessor to get the size of any dimension. More... | |
size_t & | operator[] (size_t dimension) |
Generic accessor to get the size of any dimension. More... | |
unsigned int | num_dimensions () const |
Returns the effective dimensionality of the tensor. More... | |
void | set_num_dimensions (size_t num_dimensions) |
Set number of dimensions. More... | |
void | collapse (const size_t n, const size_t first=0) |
Collapse dimensions. More... | |
void | collapse_from (size_t start) |
Collapse dimensions starting from a given point. More... | |
void | remove (size_t idx) |
Remove dimension of a given index. More... | |
std::array< size_t, num_max_dimensions >::iterator | begin () |
Returns a read/write iterator that points to the first element in the dimension array. More... | |
std::array< size_t, num_max_dimensions >::const_iterator | begin () const |
Returns a read-only (constant) iterator that points to the first element in the dimension array. More... | |
std::array< size_t, num_max_dimensions >::const_iterator | cbegin () const |
Returns a read-only (constant) iterator that points to the first element in the dimension array. More... | |
std::array< size_t, num_max_dimensions >::iterator | end () |
Returns a read/write iterator that points one past the last element in the dimension array. More... | |
std::array< size_t, num_max_dimensions >::const_iterator | end () const |
Returns a read-only (constant) iterator that points one past the last element in the dimension array. More... | |
std::array< size_t, num_max_dimensions >::const_iterator | cend () const |
Returns a read-only (constant) iterator that points one past the last element in the dimension array. More... | |
Static Public Member Functions | |
template<typename... Shapes> | |
static TensorShape | broadcast_shape (const Shapes &... shapes) |
If shapes are broadcast compatible, return the broadcasted shape. More... | |
Additional Inherited Members | |
![]() | |
static constexpr size_t | num_max_dimensions |
Number of dimensions the tensor has. More... | |
Shape of a tensor.
Definition at line 39 of file TensorShape.h.
|
inline |
Constructor to initialize the tensor shape.
[in] | dims | Values to initialize the dimensions. |
Definition at line 47 of file TensorShape.h.
References arm_compute::test::validation::fill(), TensorShape::operator=(), and TensorShape::~TensorShape().
|
default |
Allow instances of this class to be copy constructed.
|
default |
Allow instances of this class to be move constructed.
|
default |
Default destructor.
Referenced by TensorShape::TensorShape().
|
inlinestatic |
If shapes are broadcast compatible, return the broadcasted shape.
Two tensor shapes are broadcast compatible if for each dimension, they're equal or one of them is 1.
If two shapes are compatible, each dimension in the broadcasted shape is the max of the original dimensions.
[in] | shapes | Tensor shapes. |
Definition at line 211 of file TensorShape.h.
References arm_compute::utility::for_each(), Dimensions< T >::num_dimensions(), Dimensions< size_t >::num_max_dimensions, TensorShape::set(), and arm_compute::U.
Referenced by PostOpCLKernelUtils::are_post_op_shapes_compliant(), arm_compute::test::validation::reference::arithmetic_division(), arm_compute::test::validation::reference::arithmetic_operation(), ITensorInfo::broadcast_shape_and_valid_region(), arm_compute::test::validation::reference::compare(), NELogicalKernel::configure(), CpuSubKernel::configure(), CpuMulKernel::configure(), CpuAddKernel::configure(), ClMulKernel::configure(), ClComplexMulKernel::configure(), CpuComplexMulKernel::configure(), EltwiseLayerNode::configure_output(), CpuComparisonKernel::get_available_kernels(), arm_compute::intersect_valid_regions(), arm_compute::test::validation::reference::logical_and(), arm_compute::test::validation::reference::logical_or(), CpuMulKernel::name(), arm_compute::test::validation::reference::pixel_wise_multiplication(), ClMulKernel::run_op(), NELogicalKernel::validate(), and ClComponentElementwiseBinary::validate().
|
inline |
Collapse the first n dimensions.
[in] | n | Number of dimensions to collapse into first |
[in] | first | Dimensions into which the following n are collapsed. |
Definition at line 133 of file TensorShape.h.
References Dimensions< T >::collapse(), and arm_compute::test::validation::fill().
Referenced by TensorShape::collapsed_from(), arm_compute::misc::shape_calculator::compute_softmax_shape(), arm_compute::misc::shape_calculator::compute_weights_reshaped_shape(), ClTransposedConvolutionKernel::configure(), CpuGemmLowpMatrixMultiplyKernel::configure(), ClIndirectConv2dKernel::configure(), ClDirectConv2dKernel::configure(), FlattenLayerNode::configure_output(), and ClTemplateElementwiseBinary::get_window().
|
inline |
Return a copy with collapsed dimensions starting from a given point.
[in] | start | Starting point of collapsing dimensions. |
Definition at line 161 of file TensorShape.h.
References TensorShape::collapse(), arm_compute::test::validation::reference::copy(), and Dimensions< size_t >::num_dimensions().
Referenced by CpuMatMul::configure(), CpuMatMul::run(), CLComparisonKernel::run(), ClElementwiseKernel::run_op(), ClMulKernel::run_op(), and ClComplexMulKernel::run_op().
|
default |
Allow instances of this class to be copied.
Referenced by TensorShape::TensorShape().
|
default |
Allow instances of this class to be moved.
|
inline |
Accessor to remove the dimension n from the tensor shape.
[in] | n | Dimension to remove |
Definition at line 111 of file TensorShape.h.
References ARM_COMPUTE_ERROR_ON, arm_compute::test::validation::reference::copy(), arm_compute::test::validation::fill(), and arm_compute::test::validation::n.
Referenced by arm_compute::misc::shape_calculator::calculate_reduce_mean_shape(), arm_compute::misc::shape_calculator::calculate_unstack_shape(), arm_compute::misc::shape_calculator::compute_lhs_reshaped_shape(), arm_compute::misc::shape_calculator::compute_reductionA_shape(), arm_compute::misc::shape_calculator::compute_reductionB_shape(), NEReduceMean::configure(), CLReduceMean::configure(), NEFFTConvolutionLayer::configure(), and CLFFTConvolutionLayer::configure().
|
inline |
Accessor to set the value of one of the dimensions.
[in] | dimension | Dimension for which the value is set. |
[in] | value | Value to be set for the dimension. |
[in] | apply_dim_correction | (Optional) Flag to state whether apply dimension correction after setting one dimension. E.g. when permuting NCHW -> NHWC, 1x1x2 would become 2x1x1, but _num_dimensions should be 3 rather than 1. |
[in] | increase_dim_unit | (Optional) Set to true if new unit dimensions increase the number of dimensions of the shape. |
Definition at line 79 of file TensorShape.h.
References arm_compute::test::validation::fill(), and Dimensions< T >::set().
Referenced by GraphBuilder::add_convolution_node(), GraphBuilder::add_deconvolution_node(), GraphBuilder::add_depthwise_convolution_node(), GraphBuilder::add_scale_layer(), arm_compute::adjust_odd_shape(), TensorShape::broadcast_shape(), ITensorInfo::broadcast_shape_and_valid_region(), arm_compute::misc::shape_calculator::calculate_concatenate_shape(), arm_compute::misc::shape_calculator::calculate_reduce_mean_shape(), arm_compute::calculate_subsampled_shape(), arm_compute::calculate_valid_region_scale(), arm_compute::misc::shape_calculator::compute_deconvolution_upsampled_shape(), arm_compute::misc::shape_calculator::compute_gather_shape(), arm_compute::misc::shape_calculator::compute_interleaved_shape(), arm_compute::misc::shape_calculator::compute_lhs_reshaped_shape(), ReorgLayerNode::compute_output_descriptor(), DetectionOutputLayerNode::compute_output_descriptor(), PoolingLayerNode::compute_output_descriptor(), PriorBoxLayerNode::compute_output_descriptor(), DeconvolutionLayerNode::compute_output_descriptor(), SplitLayerNode::compute_output_descriptor(), FusedConvolutionBatchNormalizationWithPostOpsNode::compute_output_descriptor(), FusedConvolutionBatchNormalizationNode::compute_output_descriptor(), FusedDepthwiseConvolutionBatchNormalizationNode::compute_output_descriptor(), DepthwiseConvolutionLayerNode::compute_output_descriptor(), ConvolutionLayerNode::compute_output_descriptor(), FusedConvolutionWithPostOpNode::compute_output_descriptor(), arm_compute::misc::shape_calculator::compute_padded_shape(), arm_compute::misc::shape_calculator::compute_reductionB_shape(), arm_compute::misc::shape_calculator::compute_rhs_reshaped_shape(), arm_compute::misc::shape_calculator::compute_split_shape(), arm_compute::misc::shape_calculator::compute_stack_shape(), arm_compute::helpers::tensor_transform::compute_strided_slice_output_shape(), arm_compute::misc::shape_calculator::compute_tiled_shape(), arm_compute::misc::shape_calculator::compute_transpose1xW_shape(), arm_compute::misc::shape_calculator::compute_transpose1xW_with_element_size_shape(), arm_compute::misc::shape_calculator::compute_transposed_shape(), arm_compute::misc::shape_calculator::compute_unpool_shape(), AccessWindowTranspose::compute_valid_region(), AccessWindowStatic::compute_valid_region(), AccessWindowRectangle::compute_valid_region(), arm_compute::misc::shape_calculator::compute_vector_to_tensor_output_shape(), arm_compute::misc::shape_calculator::compute_weights_reshaped_shape(), CpuGemmMatrixMultiplyKernel::configure(), CpuSoftmaxGeneric< IS_LOG >::configure(), NEReduceMean::configure(), CLReduceMean::configure(), ClGemmConv2d::configure(), CpuGemmConv2d::configure(), ResizeLayerNode::configure_output(), PadLayerNode::configure_output(), ROIAlignLayerNode::configure_output(), SplitLayerNode::configure_output(), GpuSoftmax::create_op(), arm_compute::test::validation::DATA_TEST_CASE(), arm_compute::test::validation::reference::deconvolution_layer(), NPYLoader::fill_tensor(), arm_compute::test::index2coord(), arm_compute::index2coords(), NPYLoader::init_tensor(), arm_compute::intersect_valid_regions(), GpuSoftmax::is_supported_op(), arm_compute::permute(), arm_compute::test::validation::reference::scale_core(), GraphEdsr::setup(), Window::shape(), arm_compute::test::shape_to_valid_region(), arm_compute::test::validation::transpose(), ClSoftmax::validate(), CpuSoftmaxGeneric< IS_LOG >::validate(), NEReductionOperation::validate(), CLArgMinMaxLayer::validate(), ClGemmConv2d::validate(), CpuGemmConv2d::validate(), and CpuGemmLowpMatrixMultiplyCore::validate().
|
inline |
Shifts right the tensor shape increasing its dimensions.
[in] | step | Rotation step |
Definition at line 144 of file TensorShape.h.
References ARM_COMPUTE_ERROR_ON, Dimensions< size_t >::begin(), Dimensions< size_t >::end(), Dimensions< size_t >::num_dimensions(), Dimensions< size_t >::num_max_dimensions, and arm_compute::cpu::step.
Referenced by arm_compute::misc::shape_calculator::compute_col2im_shape(), arm_compute::misc::shape_calculator::compute_output_stage_shape(), and arm_compute::misc::shape_calculator::compute_softmax_shape().
|
inline |
Collapses all dimensions to a single linear total size.
Definition at line 172 of file TensorShape.h.
References arm_compute::test::validation::reference::accumulate().
Referenced by arm_compute::auto_init_if_empty(), TensorInfo::auto_padding(), arm_compute::test::validation::reference::col2im(), arm_compute::misc::shape_calculator::compute_gather_shape(), ClMatMulLowpNativeKernel::configure(), CLSelectKernel::configure(), NESpaceToBatchLayer::configure(), CLSpaceToBatchLayer::configure(), GenerateProposalsLayerNode::configure_output(), EltwiseLayerNode::configure_output(), arm_compute::test::coord2index(), arm_compute::coords2index(), arm_compute::test::validation::DATA_TEST_CASE(), arm_compute::export_to_cl_image(), CpuComparisonKernel::get_available_kernels(), ClTemplateCast::get_window(), ClTemplateLogits1DMaxShiftExpSum::get_window(), ClTemplateLogits1DNorm::get_window(), ClTemplateReshape::get_window(), ClTemplateDepthwiseConv2d::get_window(), ClTemplateDirectConv2d::get_window(), ClTemplateElementwiseBinary::get_window(), ClTemplateResize::get_window(), ClTemplateActivation::get_window(), ClTemplatePool2d::get_window(), arm_compute::test::index2coord(), arm_compute::index2coords(), CpuMulKernel::name(), Accessor::num_elements(), CLAccessor::num_elements(), NumPyAccessor::NumPyAccessor(), arm_compute::test::validation::reference::reshape_layer(), CLComparisonKernel::run(), ClElementwiseKernel::run_op(), ClMulKernel::run_op(), ClComplexMulKernel::run_op(), arm_compute::set_shape_if_empty(), SubTensorInfo::set_tensor_shape(), SubTensorInfo::set_valid_region(), arm_compute::test::validation::TEST_CASE(), CPPSplit< CLSlice, ICLTensor >::validate(), NELogicalKernel::validate(), CpuConcatenate::validate(), ClConcatenate::validate(), ClComponentActivation::validate(), ClComponentResize::validate(), ClComponentElementwiseBinary::validate(), ClComponentLogits1DNorm::validate(), ClComponentLogits1DMaxShiftExpSum::validate(), and NEDeconvolutionLayer::validate().
|
inline |
Compute size of dimensions lower than the given one.
[in] | dimension | Upper boundary. |
Definition at line 194 of file TensorShape.h.
References arm_compute::test::validation::reference::accumulate(), ARM_COMPUTE_ERROR_ON, and Dimensions< size_t >::num_max_dimensions.
Referenced by ClPool2dKernel::configure(), CpuConvertFullyConnectedWeightsKernel::validate(), and ClConvertFullyConnectedWeightsKernel::validate().
|
inline |
Collapses given dimension and above.
[in] | dimension | Size of the wanted dimension |
Definition at line 182 of file TensorShape.h.
References arm_compute::test::validation::reference::accumulate(), ARM_COMPUTE_ERROR_ON, and Dimensions< size_t >::num_max_dimensions.
Referenced by ClKernelRuntime::configure(), ClWinogradInputTransformKernel::configure(), ClWinogradOutputTransformKernel::configure(), ITensor::copy_from(), arm_compute::test::validation::reference::fully_connected_layer(), and ClWinogradInputTransformKernel::run_op().