Apollo  6.0
Open source self driving car software
Public Member Functions | Protected Attributes | List of all members
apollo::perception::base::Blob< Dtype > Class Template Reference

A wrapper around SyncedMemory holders serving as the basic computational unit for images, feature maps, etc. More...

#include <blob.h>

Collaboration diagram for apollo::perception::base::Blob< Dtype >:
Collaboration graph

Public Member Functions

 Blob ()
 
 Blob (bool use_cuda_host_malloc)
 
 Blob (const int num, const int channels, const int height, const int width, const bool use_cuda_host_malloc=false)
 Deprecated; use Blob(const std::vector<int>& shape). More...
 
 Blob (const std::vector< int > &shape, const bool use_cuda_host_malloc=false)
 
 Blob (const Blob &)=delete
 
void operator= (const Blob &)=delete
 
void Reshape (const int num, const int channels, const int height, const int width)
 Deprecated; use Reshape(const std::vector<int>& shape). More...
 
void Reshape (const std::vector< int > &shape)
 Change the dimensions of the blob, allocating new memory if necessary. More...
 
void ReshapeLike (const Blob &other)
 
std::string shape_string () const
 
const std::vector< int > & shape () const
 
int shape (int index) const
 Returns the dimension of the index-th axis (or the negative index-th axis from the end, if index is negative). More...
 
int num_axes () const
 
int count () const
 
int count (int start_axis, int end_axis) const
 Compute the volume of a slice; i.e., the product of dimensions among a range of axes. More...
 
int count (int start_axis) const
 Compute the volume of a slice spanning from a particular first axis to the final axis. More...
 
int CanonicalAxisIndex (int axis_index) const
 create RoI Blob. More...
 
int num () const
 Deprecated legacy shape accessor num: use shape(0) instead. More...
 
int channels () const
 Deprecated legacy shape accessor channels: use shape(1) instead. More...
 
int height () const
 Deprecated legacy shape accessor height: use shape(2) instead. More...
 
int width () const
 Deprecated legacy shape accessor width: use shape(3) instead. More...
 
int LegacyShape (int index) const
 
int offset (const int n, const int c=0, const int h=0, const int w=0) const
 
int offset (const std::vector< int > &indices) const
 
void CopyFrom (const Blob< Dtype > &source, bool reshape=false)
 Copy from a source Blob. More...
 
Dtype data_at (const int n, const int c, const int h, const int w) const
 
Dtype data_at (const std::vector< int > &index) const
 
const std::shared_ptr< SyncedMemory > & data () const
 
const Dtype * cpu_data () const
 
void set_cpu_data (Dtype *data)
 
const int * gpu_shape () const
 
const Dtype * gpu_data () const
 
void set_gpu_data (Dtype *data)
 
Dtype * mutable_cpu_data ()
 
Dtype * mutable_gpu_data ()
 
void set_head_gpu ()
 
void set_head_cpu ()
 
SyncedMemory::SyncedHead head () const
 
void ShareData (const Blob &other)
 Set the data_ std::shared_ptr to point to the SyncedMemory holding the data_ of Blob other – useful in Layers which simply perform a copy in their Forward pass. More...
 

Protected Attributes

std::shared_ptr< SyncedMemorydata_
 
std::shared_ptr< SyncedMemoryshape_data_
 
std::vector< int > shape_
 
int count_
 
int capacity_
 
bool use_cuda_host_malloc_
 

Detailed Description

template<typename Dtype>
class apollo::perception::base::Blob< Dtype >

A wrapper around SyncedMemory holders serving as the basic computational unit for images, feature maps, etc.

TODO(dox): more thorough description.

Constructor & Destructor Documentation

◆ Blob() [1/5]

template<typename Dtype>
apollo::perception::base::Blob< Dtype >::Blob ( )
inline

◆ Blob() [2/5]

template<typename Dtype>
apollo::perception::base::Blob< Dtype >::Blob ( bool  use_cuda_host_malloc)
inlineexplicit

◆ Blob() [3/5]

template<typename Dtype>
apollo::perception::base::Blob< Dtype >::Blob ( const int  num,
const int  channels,
const int  height,
const int  width,
const bool  use_cuda_host_malloc = false 
)

Deprecated; use Blob(const std::vector<int>& shape).

◆ Blob() [4/5]

template<typename Dtype>
apollo::perception::base::Blob< Dtype >::Blob ( const std::vector< int > &  shape,
const bool  use_cuda_host_malloc = false 
)
explicit

◆ Blob() [5/5]

template<typename Dtype>
apollo::perception::base::Blob< Dtype >::Blob ( const Blob< Dtype > &  )
delete

Member Function Documentation

◆ CanonicalAxisIndex()

template<typename Dtype>
int apollo::perception::base::Blob< Dtype >::CanonicalAxisIndex ( int  axis_index) const
inline

create RoI Blob.

Parameters
roi_beginbegin of roi
roi_endend of roi Returns the 'canonical' version of a (usually) user-specified axis, allowing for negative indexing (e.g., -1 for the last axis).
axis_indexthe axis index. If 0 <= index < num_axes(), return index. If -num_axes <= index <= -1, return (num_axes() - (-index)), e.g., the last axis index (num_axes() - 1) if index == -1, the second to last if index == -2, etc. Dies on out of range index.

◆ channels()

template<typename Dtype>
int apollo::perception::base::Blob< Dtype >::channels ( ) const
inline

Deprecated legacy shape accessor channels: use shape(1) instead.

◆ CopyFrom()

template<typename Dtype>
void apollo::perception::base::Blob< Dtype >::CopyFrom ( const Blob< Dtype > &  source,
bool  reshape = false 
)

Copy from a source Blob.

Parameters
sourcethe Blob to copy from
reshapeif false, require this Blob to be pre-shaped to the shape of other (and die otherwise); if true, Reshape this Blob to other's shape if necessary

◆ count() [1/3]

template<typename Dtype>
int apollo::perception::base::Blob< Dtype >::count ( ) const
inline

◆ count() [2/3]

template<typename Dtype>
int apollo::perception::base::Blob< Dtype >::count ( int  start_axis,
int  end_axis 
) const
inline

Compute the volume of a slice; i.e., the product of dimensions among a range of axes.

Parameters
start_axisThe first axis to include in the slice.
end_axisThe first axis to exclude from the slice.

◆ count() [3/3]

template<typename Dtype>
int apollo::perception::base::Blob< Dtype >::count ( int  start_axis) const
inline

Compute the volume of a slice spanning from a particular first axis to the final axis.

Parameters
start_axisThe first axis to include in the slice.

◆ cpu_data()

template<typename Dtype>
const Dtype* apollo::perception::base::Blob< Dtype >::cpu_data ( ) const

◆ data()

template<typename Dtype>
const std::shared_ptr<SyncedMemory>& apollo::perception::base::Blob< Dtype >::data ( ) const
inline

◆ data_at() [1/2]

template<typename Dtype>
Dtype apollo::perception::base::Blob< Dtype >::data_at ( const int  n,
const int  c,
const int  h,
const int  w 
) const
inline

◆ data_at() [2/2]

template<typename Dtype>
Dtype apollo::perception::base::Blob< Dtype >::data_at ( const std::vector< int > &  index) const
inline

◆ gpu_data()

template<typename Dtype>
const Dtype* apollo::perception::base::Blob< Dtype >::gpu_data ( ) const

◆ gpu_shape()

template<typename Dtype>
const int* apollo::perception::base::Blob< Dtype >::gpu_shape ( ) const

◆ head()

template<typename Dtype>
SyncedMemory::SyncedHead apollo::perception::base::Blob< Dtype >::head ( ) const
inline

◆ height()

template<typename Dtype>
int apollo::perception::base::Blob< Dtype >::height ( ) const
inline

Deprecated legacy shape accessor height: use shape(2) instead.

◆ LegacyShape()

template<typename Dtype>
int apollo::perception::base::Blob< Dtype >::LegacyShape ( int  index) const
inline

◆ mutable_cpu_data()

template<typename Dtype>
Dtype* apollo::perception::base::Blob< Dtype >::mutable_cpu_data ( )

◆ mutable_gpu_data()

template<typename Dtype>
Dtype* apollo::perception::base::Blob< Dtype >::mutable_gpu_data ( )

◆ num()

template<typename Dtype>
int apollo::perception::base::Blob< Dtype >::num ( ) const
inline

Deprecated legacy shape accessor num: use shape(0) instead.

◆ num_axes()

template<typename Dtype>
int apollo::perception::base::Blob< Dtype >::num_axes ( ) const
inline

◆ offset() [1/2]

template<typename Dtype>
int apollo::perception::base::Blob< Dtype >::offset ( const int  n,
const int  c = 0,
const int  h = 0,
const int  w = 0 
) const
inline

◆ offset() [2/2]

template<typename Dtype>
int apollo::perception::base::Blob< Dtype >::offset ( const std::vector< int > &  indices) const
inline

◆ operator=()

template<typename Dtype>
void apollo::perception::base::Blob< Dtype >::operator= ( const Blob< Dtype > &  )
delete

◆ Reshape() [1/2]

template<typename Dtype>
void apollo::perception::base::Blob< Dtype >::Reshape ( const int  num,
const int  channels,
const int  height,
const int  width 
)

Deprecated; use Reshape(const std::vector<int>& shape).

◆ Reshape() [2/2]

template<typename Dtype>
void apollo::perception::base::Blob< Dtype >::Reshape ( const std::vector< int > &  shape)

Change the dimensions of the blob, allocating new memory if necessary.

This function can be called both to create an initial allocation of memory, and to adjust the dimensions of a top blob during Layer::Reshape or Layer::Forward. When changing the size of blob, memory will only be reallocated if sufficient memory does not already exist, and excess memory will never be freed.

Note that reshaping an input blob and immediately calling Net::Backward is an error; either Net::Forward or Net::Reshape need to be called to propagate the new input shape to higher layers.

◆ ReshapeLike()

template<typename Dtype>
void apollo::perception::base::Blob< Dtype >::ReshapeLike ( const Blob< Dtype > &  other)

◆ set_cpu_data()

template<typename Dtype>
void apollo::perception::base::Blob< Dtype >::set_cpu_data ( Dtype *  data)

◆ set_gpu_data()

template<typename Dtype>
void apollo::perception::base::Blob< Dtype >::set_gpu_data ( Dtype *  data)

◆ set_head_cpu()

template<typename Dtype>
void apollo::perception::base::Blob< Dtype >::set_head_cpu ( )
inline

◆ set_head_gpu()

template<typename Dtype>
void apollo::perception::base::Blob< Dtype >::set_head_gpu ( )
inline

◆ shape() [1/2]

template<typename Dtype>
const std::vector<int>& apollo::perception::base::Blob< Dtype >::shape ( ) const
inline

◆ shape() [2/2]

template<typename Dtype>
int apollo::perception::base::Blob< Dtype >::shape ( int  index) const
inline

Returns the dimension of the index-th axis (or the negative index-th axis from the end, if index is negative).

Parameters
indexthe axis index, which may be negative as it will be "canonicalized" using CanonicalAxisIndex. Dies on out of range index.

◆ shape_string()

template<typename Dtype>
std::string apollo::perception::base::Blob< Dtype >::shape_string ( ) const
inline

◆ ShareData()

template<typename Dtype>
void apollo::perception::base::Blob< Dtype >::ShareData ( const Blob< Dtype > &  other)

Set the data_ std::shared_ptr to point to the SyncedMemory holding the data_ of Blob other – useful in Layers which simply perform a copy in their Forward pass.

This deallocates the SyncedMemory holding this Blob's data_, as std::shared_ptr calls its destructor when reset with the "=" operator.

◆ width()

template<typename Dtype>
int apollo::perception::base::Blob< Dtype >::width ( ) const
inline

Deprecated legacy shape accessor width: use shape(3) instead.

Member Data Documentation

◆ capacity_

template<typename Dtype>
int apollo::perception::base::Blob< Dtype >::capacity_
protected

◆ count_

template<typename Dtype>
int apollo::perception::base::Blob< Dtype >::count_
protected

◆ data_

template<typename Dtype>
std::shared_ptr<SyncedMemory> apollo::perception::base::Blob< Dtype >::data_
protected

◆ shape_

template<typename Dtype>
std::vector<int> apollo::perception::base::Blob< Dtype >::shape_
protected

◆ shape_data_

template<typename Dtype>
std::shared_ptr<SyncedMemory> apollo::perception::base::Blob< Dtype >::shape_data_
protected

◆ use_cuda_host_malloc_

template<typename Dtype>
bool apollo::perception::base::Blob< Dtype >::use_cuda_host_malloc_
protected

The documentation for this class was generated from the following file: