Compute Library
 23.08
ITensor Class Referenceabstract

Interface for CPU tensor. More...

#include <ITensor.h>

Public Member Functions

virtual ITensorInfoinfo () const =0
 Interface to be implemented by the child class to return the tensor's metadata. More...
 
virtual ITensorInfoinfo ()=0
 Interface to be implemented by the child class to return the tensor's metadata. More...
 
virtual ~ITensor ()=default
 Default virtual destructor. More...
 
virtual uint8_t * buffer () const =0
 Interface to be implemented by the child class to return a pointer to CPU memory. More...
 
uint8_t * ptr_to_element (const Coordinates &id) const
 Return a pointer to the element at the passed coordinates. More...
 
void copy_from (const ITensor &src)
 Copy the content of another tensor. More...
 
void print (std::ostream &s, IOFormatInfo io_fmt=IOFormatInfo()) const
 Print a tensor to a given stream using user defined formatting information. More...
 
bool is_used () const
 Flags if the tensor is used or not. More...
 
void mark_as_unused () const
 Marks a tensor as unused. More...
 
void mark_as_used () const
 Marks a tensor as used. More...
 

Detailed Description

Interface for CPU tensor.

Definition at line 36 of file ITensor.h.

Constructor & Destructor Documentation

◆ ~ITensor()

virtual ~ITensor ( )
virtualdefault

Default virtual destructor.

Member Function Documentation

◆ buffer()

◆ copy_from()

void copy_from ( const ITensor src)

Copy the content of another tensor.

Note
The number of dimensions of the source tensor must be less or equal to those of the destination tensor.
All dimensions of the destination tensor must be greater or equal to the source tensor ones.
num_channels() and element_size() of both tensors must match.
Parameters
[in]srcSource tensor to copy from.

Definition at line 36 of file ITensor.cpp.

37 {
38  if(&src == this)
39  {
40  return;
41  }
42 
43  const ITensorInfo *src_info = src.info();
44  ITensorInfo *dst_info = this->info();
45 
46  ARM_COMPUTE_ERROR_ON(src_info->num_dimensions() > dst_info->num_dimensions());
47  ARM_COMPUTE_ERROR_ON(src_info->num_channels() != dst_info->num_channels());
48  ARM_COMPUTE_ERROR_ON(src_info->element_size() != dst_info->element_size());
49 
50  for(size_t d = 0; d < src_info->num_dimensions(); d++)
51  {
52  ARM_COMPUTE_ERROR_ON(src_info->dimension(d) > dst_info->dimension(d));
53  }
54 
55  // Copy information about valid region
56  dst_info->set_valid_region(src_info->valid_region());
57 
58  Window win_src;
59  win_src.use_tensor_dimensions(src_info->tensor_shape(), Window::DimY);
60  Window win_dst;
61  win_dst.use_tensor_dimensions(dst_info->tensor_shape(), Window::DimY);
62 
63  Iterator src_it(&src, win_src);
64  Iterator dst_it(this, win_dst);
65 
66  const size_t line_size = src_info->element_size() * src_info->dimension(0);
67 
69  win_src, [&](const Coordinates &)
70  {
71  memcpy(dst_it.ptr(), src_it.ptr(), line_size);
72  },
73  src_it, dst_it);
74 }

References ARM_COMPUTE_ERROR_ON, ITensorInfo::dimension(), TensorInfo::dimension(), Window::DimY, ITensorInfo::element_size(), TensorInfo::element_size(), arm_compute::execute_window_loop(), ITensor::info(), ITensorInfo::num_channels(), TensorInfo::num_channels(), ITensorInfo::num_dimensions(), TensorInfo::num_dimensions(), Iterator::ptr(), ITensorInfo::set_valid_region(), arm_compute::test::validation::src, arm_compute::test::validation::src_info, ITensorInfo::tensor_shape(), TensorInfo::tensor_shape(), Window::use_tensor_dimensions(), and TensorInfo::valid_region().

◆ info() [1/2]

virtual ITensorInfo* info ( ) const
pure virtual

Interface to be implemented by the child class to return the tensor's metadata.

Returns
A pointer to the tensor's metadata.

Implemented in CLSubTensor, CLTensor, SubTensor, OperatorTensor, and Tensor.

Referenced by arm_compute::cpu::add_qasymm8_signed_sve2(), arm_compute::cpu::add_qasymm8_sve2(), arm_compute::cpu::add_qsymm16_neon(), arm_compute::cpu::add_qsymm16_sve2(), arm_compute::cpu::add_same_neon(), arm_compute::cpu::add_same_sve(), arm_compute::cpu::add_sub_q8_neon_fixedpoint(), arm_compute::cpu::add_sub_qasymm8_neon(), arm_compute::cpu::add_sub_qasymm8_signed_neon(), arm_compute::cpu::avg_poolingMxNxD_q8_neon_ndhwc(), CLComparisonKernel::border_size(), arm_compute::cpu::bounding_box_transform(), arm_compute::cpu::bounding_box_transform_qsymm16(), CLAuxTensorHandler::CLAuxTensorHandler(), ICLTensor::clear(), arm_compute::colorconvert_iyuv_to_rgb(), arm_compute::colorconvert_nv12_to_rgb(), arm_compute::utils::compare_tensor(), arm_compute::cpu::compute_all_anchors(), arm_compute::cpu::compute_all_anchors_qasymm16(), CPPDetectionOutputLayer::configure(), ICLSimpleKernel::configure(), NETileKernel::configure(), NEReverseKernel::configure(), NEChannelShuffleLayerKernel::configure(), NEDepthToSpaceLayerKernel::configure(), NEPriorBoxLayerKernel::configure(), NESpaceToDepthLayerKernel::configure(), CPPTopKVKernel::configure(), NEInstanceNormalizationLayerKernel::configure(), NEComputeAllAnchorsKernel::configure(), NEReorgLayerKernel::configure(), CLInstanceNormalizationLayerKernel::configure(), CLMaxUnpoolingLayerKernel::configure(), CPPUpsampleKernel::configure(), NEBatchToSpaceLayerKernel::configure(), NEBitwiseNotKernel::configure(), NEFFTDigitReverseKernel::configure(), NEFFTScaleKernel::configure(), CLBitwiseKernel::configure(), NEQLSTMLayerNormalizationKernel::configure(), NESpaceToBatchLayerKernel::configure(), CPPPermuteKernel::configure(), NEBitwiseAndKernel::configure(), NEBitwiseOrKernel::configure(), NEBitwiseXorKernel::configure(), CLReverseKernel::configure(), CLSelectKernel::configure(), NENormalizationLayerKernel::configure(), CLChannelShuffleLayerKernel::configure(), CPPBoxWithNonMaximaSuppressionLimit::configure(), CLDepthToSpaceLayerKernel::configure(), CLSpaceToDepthLayerKernel::configure(), CLDeconvolutionLayerUpsampleKernel::configure(), NEPadLayerKernel::configure(), NERangeKernel::configure(), CLComputeAllAnchorsKernel::configure(), NEFlattenLayer::configure(), CLNormalizationLayerKernel::configure(), NEReshapeLayer::configure(), CLQLSTMLayerNormalizationKernel::configure(), NEBoundingBoxTransformKernel::configure(), NEFFTRadixStageKernel::configure(), NEMeanStdDevNormalizationKernel::configure(), CLFFTScaleKernel::configure(), CLSpaceToBatchLayerKernel::configure(), CLGatherKernel::configure(), NEROIPoolingLayerKernel::configure(), CPPBoxWithNonMaximaSuppressionLimitKernel::configure(), CLTileKernel::configure(), CLComparisonKernel::configure(), NEStackLayerKernel::configure(), CPPDetectionPostProcessLayer::configure(), NECopy::configure(), CLBatchToSpaceLayerKernel::configure(), NETranspose::configure(), CLFFTDigitReverseKernel::configure(), CLReorgLayerKernel::configure(), NEReductionOperationKernel::configure(), NESelectKernel::configure(), CPPNonMaximumSuppressionKernel::configure(), CLMeanStdDevNormalizationKernel::configure(), NELogicalAnd::configure(), NEQuantizationLayer::configure(), NEFuseBatchNormalizationKernel::configure(), CLComparison::configure(), CLNormalizePlanarYUVLayerKernel::configure(), NECropKernel::configure(), CLRangeKernel::configure(), CLReductionOperationKernel::configure(), NEGatherKernel::configure(), NEROIAlignLayerKernel::configure(), NEDequantizationLayer::configure(), NEBatchNormalizationLayerKernel::configure(), CLPadLayerKernel::configure(), NEPermute::configure(), NESlice::configure(), CLPriorBoxLayerKernel::configure(), CLFFTRadixStageKernel::configure(), CLL2NormalizeLayerKernel::configure(), NEFFT2D::configure(), NEPReluLayer::configure(), NEReduceMean::configure(), CLReshapeLayer::configure(), NEStridedSlice::configure(), CLBoundingBoxTransformKernel::configure(), NERNNLayer::configure(), CLArgMinMaxLayerKernel::configure(), NESpaceToBatchLayer::configure(), NESoftmaxLayerGeneric< IS_LOG >::configure(), NEElementwiseMax::configure(), NEPooling3dLayer::configure(), CLRsqrtLayer::configure(), CLFlattenLayer::configure(), NEMaxUnpoolingLayer::configure(), CLDepthwiseConvolutionLayerNativeKernel::configure(), CLROIPoolingLayerKernel::configure(), CLStackLayerKernel::configure(), CLReduceMean::configure(), NECropResize::configure(), NEScale::configure(), NEReductionOperation::configure(), NEConv3D::configure(), NEFFT1D::configure(), CLLogicalNot::configure(), CLLogicalAnd::configure(), CLLogicalOr::configure(), CLROIAlignLayerKernel::configure(), CLConv3D::configure(), NEDetectionPostProcessLayer::configure(), NEGEMM::configure(), NEGEMMLowpOutputStage::configure(), CLDequantizationLayer::configure(), NEPoolingLayer::configure(), CLDeconvolutionReshapeOutputKernel::configure(), CLFFT2D::configure(), NEArithmeticSubtraction::configure(), NEDepthwiseConvolutionLayer::configure(), CLPReluLayer::configure(), CLRNNLayer::configure(), NEAddMulAdd::configure(), CLFuseBatchNormalizationKernel::configure(), CLBatchNormalizationLayerKernel::configure(), CLDeconvolutionLayerUpsample::configure(), NEPadLayer::configure(), CLDeconvolutionLayer::configure(), CLFFT1D::configure(), CLPooling3dLayer::configure(), CLSpaceToBatchLayer::configure(), CLPoolingLayer::configure(), CLScale::configure(), CLFullyConnectedLayer::configure(), CLSlice::configure(), CLQuantizationLayer::configure(), NEDirectConvolutionLayer::configure(), NEGEMMConv2d::configure(), CLSoftmaxLayerGeneric< IS_LOG >::configure(), NEWinogradConvolutionLayer::configure(), CLMatMul::configure(), CLDepthwiseConvolutionLayer::configure(), CLPadLayer::configure(), CLIndirectConvolutionLayer::configure(), CLReductionOperation::configure(), CLArgMinMaxLayer::configure(), CLGEMM::configure(), NEFFTConvolutionLayer::configure(), CLDirectConvolutionLayer::configure(), NEGenerateProposalsLayer::configure(), CLGEMMLowpOutputStage::configure(), NEGEMMConvolutionLayer::configure(), NEPixelWiseMultiplication::configure(), NEGEMMLowpMatrixMultiplyCore::configure(), NEMatMul::configure(), CLCropResize::configure(), CLPixelWiseMultiplication::configure(), NELSTMLayerQuantized::configure(), CLWinogradConvolutionLayer::configure(), NELSTMLayer::configure(), CLComputeMeanVariance::configure(), CLArithmeticAddition::configure(), CLComparisonStatic< COP >::configure(), CLGEMMLowpMatrixMultiplyCore::configure(), CLFFTConvolutionLayer::configure(), NELogicalOr::configure(), NEDeconvolutionLayer::configure(), CLGenerateProposalsLayer::configure(), NEConvolutionLayer::configure(), CLGEMMConvolutionLayer::configure(), CLGEMMDeconvolutionLayer::configure(), CLDirectDeconvolutionLayer::configure(), NEFullyConnectedLayer::configure(), CLLSTMLayerQuantized::configure(), CLExpLayer::configure(), NEQLSTMLayer::configure(), NEElementwiseMin::configure(), CLConvolutionLayer::configure(), NEComplexPixelWiseMultiplication::configure(), CLComplexPixelWiseMultiplication::configure(), NELogicalNot::configure(), CLLSTMLayer::configure(), CLQLSTMLayer::configure(), CLNegLayer::configure(), NEElementwiseSquaredDiff::configure(), CLArithmeticSubtraction::configure(), CLSinLayer::configure(), NEElementwiseDivision::configure(), CLLogLayer::configure(), CLArithmeticDivision::configure(), NEElementwisePower::configure(), CLAbsLayer::configure(), NEElementwiseComparison::configure(), CLElementwiseMax::configure(), CLRoundLayer::configure(), NEElementwiseComparisonStatic< op >::configure(), CLElementwiseMin::configure(), CLElementwiseSquaredDiff::configure(), CLElementwisePower::configure(), NECropKernel::configure_output_shape(), arm_compute::cpu::kernels::convolve_nchw(), arm_compute::cpu::kernels::convolve_nhwc(), ITensor::copy_from(), CpuAuxTensorHandler::CpuAuxTensorHandler(), arm_compute::graph::backends::detail::create_detection_output_layer< CPPDetectionOutputLayer, CLTargetInfo >(), arm_compute::graph::backends::detail::create_detection_post_process_layer< CPPDetectionPostProcessLayer, CLTargetInfo >(), arm_compute::graph::backends::detail::create_normalization_layer< NENormalizationLayer, NETargetInfo >(), Accessor::data_layout(), Accessor::data_type(), arm_compute::cpu::directconv3d_float_neon_ndhwc(), arm_compute::cpu::directconv3d_quantized_neon_ndhwc(), Accessor::element_size(), arm_compute::cpu::elementwise_arithmetic_op(), arm_compute::cpu::elementwise_arithmetic_quantized_op(), arm_compute::cpu::elementwise_comp_quantized_signed(), arm_compute::cpu::elementwise_comparison_op(), arm_compute::cpu::elementwise_comparison_quantized_op(), arm_compute::cpu::elementwise_op(), arm_compute::cpu::elementwise_op< int8_t >(), arm_compute::cpu::elementwise_op< uint8_t >(), arm_compute::cpu::elementwise_op_quantized(), arm_compute::cpu::elementwise_op_quantized_signed(), arm_compute::error_on_mismatching_quantization_info(), arm_compute::error_on_mismatching_shapes(), Accessor::format(), arm_compute::cpu::fused_batch_normalization_conv(), arm_compute::cpu::fused_batch_normalization_dwc_nchw(), arm_compute::cpu::fused_batch_normalization_dwc_nhwc(), ITensorV2::get_size(), arm_compute::cpu::in_bounds_crop_window(), arm_compute::cpu::instance_normalization_nchw(), arm_compute::cpu::l2_normalize_x(), arm_compute::cpu::l2_normalize_yz(), arm_compute::cpu::matrix_matrix_multiply_f32(), arm_compute::cpu::max_poolingMxNxD_q8_neon_ndhwc(), arm_compute::cpu::max_unpooling(), arm_compute::cpu::neon_qasymm8_meanstddevnorm(), arm_compute::cpu::neon_softmax_logits_1d_float(), arm_compute::cpu::neon_softmax_logits_1d_quantized(), Accessor::num_channels(), Accessor::num_elements(), Accessor::padding(), arm_compute::cpu::poolingMxN_q8_neon_nhwc(), CpuDepthwiseConv2dAssemblyDispatch::prepare(), CpuWinogradConv2d::prepare(), ClGemmLowpMatrixMultiplyCore::prepare(), CLDepthwiseConvolutionLayer::prepare(), ITensor::ptr_to_element(), Accessor::quantization_info(), arm_compute::cpu::roi_align(), CpuElementwiseBase::run(), CpuElementwiseUnary::run(), CpuAddMulAdd::run(), CPPUpsampleKernel::run(), NEROIPoolingLayerKernel::run(), CPPDetectionOutputLayer::run(), CPPBoxWithNonMaximaSuppressionLimitKernel::run(), NETileKernel::run(), NEDepthToSpaceLayerKernel::run(), NESpaceToDepthLayerKernel::run(), NEChannelShuffleLayerKernel::run(), NEReverseKernel::run(), NEInstanceNormalizationLayerKernel::run(), NEComputeAllAnchorsKernel::run(), CPPTopKVKernel::run(), CLInstanceNormalizationLayerKernel::run(), NEReorgLayerKernel::run(), CLDeconvolutionLayerUpsampleKernel::run(), NERangeKernel::run(), CLQLSTMLayerNormalizationKernel::run(), NEMeanStdDevNormalizationKernel::run(), CpuMatMul::run(), CLROIPoolingLayerKernel::run(), CLComparisonKernel::run(), NEFillBorderKernel::run(), NESelectKernel::run(), CLMeanStdDevNormalizationKernel::run(), NEBoundingBoxTransformKernel::run(), NEFFTRadixStageKernel::run(), NEStackLayerKernel::run(), CLReductionOperationKernel::run(), CLPriorBoxLayerKernel::run(), CPPDetectionPostProcessLayer::run(), NEROIAlignLayerKernel::run(), CLArgMinMaxLayerKernel::run(), NECropKernel::run(), CLStackLayerKernel::run(), NEBatchNormalizationLayerKernel::run(), NEBatchToSpaceLayerKernel::run(), CLDepthwiseConvolutionLayerNativeKernel::run(), NESpaceToBatchLayerKernel::run(), CLROIAlignLayerKernel::run(), ClGemm::run(), CLComputeMeanVariance::run(), CpuGemmConv2d::run(), arm_compute::cpu::run_depthwise_quanitized8bit(), CPPBoxWithNonMaximaSuppressionLimitKernel::run_nmslimit(), CpuWinogradConv2dTransformInputKernel::run_op(), ClMatMulNativeKernel::run_op(), CpuGemmLowpOffsetContributionKernel::run_op(), CpuCastKernel::run_op(), CpuPool2dAssemblyWrapperKernel::run_op(), CpuDepthwiseConv2dAssemblyWrapperKernel::run_op(), CpuWinogradConv2dTransformOutputKernel::run_op(), arm_compute::run_reverse(), arm_compute::cpu::select_op_not_same_rank(), Accessor::shape(), Accessor::size(), arm_compute::cpu::sub_qsymm16_neon(), arm_compute::cpu::sub_same_neon(), arm_compute::cpu::sve2_softmax_logits_1d_quantized(), arm_compute::cpu::sve_softmax_logits_1d_float(), and arm_compute::cpu::vector_matrix_multiply_f32().

◆ info() [2/2]

virtual ITensorInfo* info ( )
pure virtual

Interface to be implemented by the child class to return the tensor's metadata.

Returns
A pointer to the tensor's metadata.

Implemented in CLSubTensor, CLTensor, SubTensor, OperatorTensor, and Tensor.

◆ is_used()

◆ mark_as_unused()

◆ mark_as_used()

void mark_as_used ( ) const

Marks a tensor as used.

Definition at line 174 of file ITensor.cpp.

175 {
176  _is_used = true;
177 }

◆ print()

void print ( std::ostream &  s,
IOFormatInfo  io_fmt = IOFormatInfo() 
) const

Print a tensor to a given stream using user defined formatting information.

Parameters
sOutput stream
io_fmtFormat information

Referenced by main().

◆ ptr_to_element()


The documentation for this class was generated from the following files:
arm_compute::test::validation::src
SimpleTensor< float > src
Definition: DFT.cpp:155
arm_compute::TensorInfo::num_channels
size_t num_channels() const override
The number of channels for each tensor element.
Definition: TensorInfo.h:231
arm_compute::ITensorInfo::offset_element_in_bytes
virtual int32_t offset_element_in_bytes(const Coordinates &pos) const =0
The offset in bytes from the beginning of the memory allocation to access the element at position (x,...
arm_compute::TensorInfo::valid_region
ValidRegion valid_region() const override
Valid region of the tensor.
Definition: TensorInfo.h:280
arm_compute::TensorInfo::dimension
size_t dimension(size_t index) const override
Return the size of the requested dimension.
Definition: TensorInfo.h:206
arm_compute::TensorInfo::num_dimensions
size_t num_dimensions() const override
The number of dimensions of the tensor (rank)
Definition: TensorInfo.h:227
arm_compute::ITensor::info
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
ARM_COMPUTE_ERROR_ON
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:467
arm_compute::Window::DimY
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
arm_compute::test::validation::src_info
TensorInfo src_info(src_shape, 1, data_type)
arm_compute::execute_window_loop
void execute_window_loop(const Window &w, L &&lambda_function, Ts &&... iterators)
Iterate through the passed window, automatically adjusting the iterators and calling the lambda_funct...
Definition: Helpers.inl:77
arm_compute::TensorInfo::tensor_shape
const TensorShape & tensor_shape() const override
Size for each dimension of the tensor.
Definition: TensorInfo.h:235
arm_compute::TensorInfo::element_size
size_t element_size() const override
Element size in bytes calculated as data_size() * num_channels()
Definition: TensorInfo.h:223
arm_compute::ITensor::buffer
virtual uint8_t * buffer() const =0
Interface to be implemented by the child class to return a pointer to CPU memory.