Apollo
6.0
Open source self driving car software
|
A wrapper around SyncedMemory holders serving as the basic computational unit for images, feature maps, etc. More...
#include <blob.h>
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< SyncedMemory > | data_ |
std::shared_ptr< SyncedMemory > | shape_data_ |
std::vector< int > | shape_ |
int | count_ |
int | capacity_ |
bool | use_cuda_host_malloc_ |
A wrapper around SyncedMemory holders serving as the basic computational unit for images, feature maps, etc.
TODO(dox): more thorough description.
|
inline |
|
inlineexplicit |
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)
.
|
explicit |
|
delete |
|
inline |
create RoI Blob.
roi_begin | begin of roi |
roi_end | end of roi Returns the 'canonical' version of a (usually) user-specified axis, allowing for negative indexing (e.g., -1 for the last axis). |
axis_index | the 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. |
|
inline |
Deprecated legacy shape accessor channels: use shape(1) instead.
void apollo::perception::base::Blob< Dtype >::CopyFrom | ( | const Blob< Dtype > & | source, |
bool | reshape = false |
||
) |
|
inline |
|
inline |
Compute the volume of a slice; i.e., the product of dimensions among a range of axes.
start_axis | The first axis to include in the slice. |
end_axis | The first axis to exclude from the slice. |
|
inline |
Compute the volume of a slice spanning from a particular first axis to the final axis.
start_axis | The first axis to include in the slice. |
const Dtype* apollo::perception::base::Blob< Dtype >::cpu_data | ( | ) | const |
|
inline |
|
inline |
|
inline |
const Dtype* apollo::perception::base::Blob< Dtype >::gpu_data | ( | ) | const |
const int* apollo::perception::base::Blob< Dtype >::gpu_shape | ( | ) | const |
|
inline |
|
inline |
Deprecated legacy shape accessor height: use shape(2) instead.
|
inline |
Dtype* apollo::perception::base::Blob< Dtype >::mutable_cpu_data | ( | ) |
Dtype* apollo::perception::base::Blob< Dtype >::mutable_gpu_data | ( | ) |
|
inline |
Deprecated legacy shape accessor num: use shape(0) instead.
|
inline |
|
inline |
|
inline |
|
delete |
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)
.
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.
void apollo::perception::base::Blob< Dtype >::ReshapeLike | ( | const Blob< Dtype > & | other | ) |
void apollo::perception::base::Blob< Dtype >::set_cpu_data | ( | Dtype * | data | ) |
void apollo::perception::base::Blob< Dtype >::set_gpu_data | ( | Dtype * | data | ) |
|
inline |
|
inline |
|
inline |
|
inline |
Returns the dimension of the index-th axis (or the negative index-th axis from the end, if index is negative).
index | the axis index, which may be negative as it will be "canonicalized" using CanonicalAxisIndex. Dies on out of range index. |
|
inline |
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.
|
inline |
Deprecated legacy shape accessor width: use shape(3) instead.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |