ONE - On-device Neural Engine
Loading...
Searching...
No Matches
nnfw::cker::BCast Class Reference

#include <BCast.h>

Collaboration diagram for nnfw::cker::BCast:

Public Types

typedef std::vector< int32_t > Vec
 
- Public Types inherited from nnfw::cker::BCastList< 2 >
typedef std::vector< int32_t > Vec
 

Public Member Functions

 BCast (const Vec &x, const Vec &y, const bool fewer_dims_optimization=true, const bool return_flattened_batch_indices=false)
 
 ~BCast ()
 
const Vecx_reshape () const
 
const Vecx_bcast () const
 
const Vecy_reshape () const
 
const Vecy_bcast () const
 
const Vecresult_shape () const
 
const Vecoutput_shape () const
 
const Vecgrad_x_reduce_idx () const
 
const Vecgrad_y_reduce_idx () const
 
const std::vector< int32_t > & x_batch_indices () const
 
const std::vector< int32_t > & y_batch_indices () const
 
- Public Member Functions inherited from nnfw::cker::BCastList< 2 >
 BCastList (const Vec(&x)[N], const bool fewer_dims_optimization=true, const bool return_flattened_batch_indices=false)
 
 ~BCastList ()
 
bool IsValid () const
 
bool IsBroadcastingRequired () const
 
const Vecreshape (int i) const
 
const Vecbcast (int i) const
 
const Vecresult_shape () const
 
const Vecoutput_shape () const
 
const Vecgrad_reduce_idx (int i) const
 
int32_t output_batch_size () const
 
const std::vector< int32_t > & batch_indices (int i) const
 

Static Public Member Functions

template<typename IndexType , int NDIMS>
static Eigen::array< IndexType, NDIMS > ToIndexArrayType (const BCast::Vec &vec)
 
template<int NDIMS>
static Eigen::array< Eigen::DenseIndex, NDIMS > ToIndexArray (const BCast::Vec &vec)
 
static Vec FromShape (const Shape &shape)
 
static Shape ToShape (const BCastList::Vec &vec)
 

Additional Inherited Members

- Static Protected Member Functions inherited from nnfw::cker::BCastList< 2 >
static void Reverse (Vec *shape)
 
- Protected Attributes inherited from nnfw::cker::BCastList< 2 >
bool valid_
 
bool broadcasting_required_
 
Vec reshape_ [N]
 
Vec bcast_ [N]
 
Vec result_
 
Vec output_
 
Vec grad_reduce_idx_ [N]
 
int32_t output_batch_size_
 
std::vector< int32_t > batch_indices_ [N]
 

Detailed Description

Definition at line 381 of file BCast.h.

Member Typedef Documentation

◆ Vec

typedef std::vector<int32_t> nnfw::cker::BCast::Vec

Definition at line 392 of file BCast.h.

Constructor & Destructor Documentation

◆ BCast()

nnfw::cker::BCast::BCast ( const Vec x,
const Vec y,
const bool  fewer_dims_optimization = true,
const bool  return_flattened_batch_indices = false 
)
inline

Definition at line 394 of file BCast.h.

396 : BCastList<2>({x, y}, fewer_dims_optimization, return_flattened_batch_indices)
397 {
398 }

◆ ~BCast()

nnfw::cker::BCast::~BCast ( )
inline

Definition at line 400 of file BCast.h.

400{}

Member Function Documentation

◆ FromShape()

static Vec nnfw::cker::BCast::FromShape ( const Shape shape)
inlinestatic

Definition at line 444 of file BCast.h.

445 {
446 const int N = shape.DimensionsCount();
447 BCastList::Vec ret(N);
448 for (int i = 0; i < N; ++i)
449 {
450 ret[i] = shape.Dims(i);
451 }
452 return ret;
453 }
std::vector< int32_t > Vec
Definition BCast.h:76

References nnfw::cker::Shape::DimensionsCount(), and nnfw::cker::Shape::Dims().

Referenced by nnfw::cker::BroadcastTo(), and nnfw::cker::train::CategoricalCrossEntropyWithLogits().

◆ grad_x_reduce_idx()

const Vec & nnfw::cker::BCast::grad_x_reduce_idx ( ) const
inline

Definition at line 411 of file BCast.h.

411{ return grad_reduce_idx_[0]; }

References nnfw::cker::BCastList< 2 >::grad_reduce_idx_.

◆ grad_y_reduce_idx()

const Vec & nnfw::cker::BCast::grad_y_reduce_idx ( ) const
inline

Definition at line 412 of file BCast.h.

412{ return grad_reduce_idx_[1]; }

References nnfw::cker::BCastList< 2 >::grad_reduce_idx_.

◆ output_shape()

const Vec & nnfw::cker::BCast::output_shape ( ) const
inline

Definition at line 410 of file BCast.h.

410{ return output_; }

References nnfw::cker::BCastList< 2 >::output_.

Referenced by nnfw::cker::BroadcastTo().

◆ result_shape()

const Vec & nnfw::cker::BCast::result_shape ( ) const
inline

◆ ToIndexArray()

template<int NDIMS>
static Eigen::array< Eigen::DenseIndex, NDIMS > nnfw::cker::BCast::ToIndexArray ( const BCast::Vec vec)
inlinestatic

Definition at line 438 of file BCast.h.

439 {
440 return ToIndexArrayType<Eigen::DenseIndex, NDIMS>(vec);
441 }

◆ ToIndexArrayType()

template<typename IndexType , int NDIMS>
static Eigen::array< IndexType, NDIMS > nnfw::cker::BCast::ToIndexArrayType ( const BCast::Vec vec)
inlinestatic

Definition at line 428 of file BCast.h.

429 {
430 assert(vec.size() == NDIMS);
431 Eigen::array<IndexType, NDIMS> ret;
432 for (int i = 0; i < NDIMS; ++i)
433 ret[i] = vec[i];
434 return ret;
435 }

◆ ToShape()

static Shape nnfw::cker::BCast::ToShape ( const BCastList::Vec vec)
inlinestatic

Definition at line 455 of file BCast.h.

456 {
457 const int N = vec.size();
458 Shape shape(N);
459
460 for (int i = 0; i < N; ++i)
461 {
462 shape.SetDim(i, vec[i]);
463 }
464 return shape;
465 }
Definition Shape.h:28

References nnfw::cker::Shape::SetDim().

Referenced by nnfw::cker::BroadcastTo().

◆ x_batch_indices()

const std::vector< int32_t > & nnfw::cker::BCast::x_batch_indices ( ) const
inline

Definition at line 420 of file BCast.h.

420{ return batch_indices_[0]; }
std::vector< int32_t > batch_indices_[N]
Definition BCast.h:127

References nnfw::cker::BCastList< 2 >::batch_indices_.

◆ x_bcast()

const Vec & nnfw::cker::BCast::x_bcast ( ) const
inline

◆ x_reshape()

const Vec & nnfw::cker::BCast::x_reshape ( ) const
inline

◆ y_batch_indices()

const std::vector< int32_t > & nnfw::cker::BCast::y_batch_indices ( ) const
inline

Definition at line 425 of file BCast.h.

425{ return batch_indices_[1]; }

References nnfw::cker::BCastList< 2 >::batch_indices_.

◆ y_bcast()

const Vec & nnfw::cker::BCast::y_bcast ( ) const
inline

Definition at line 408 of file BCast.h.

408{ return bcast_[1]; }

References nnfw::cker::BCastList< 2 >::bcast_.

Referenced by nnfw::cker::train::CategoricalCrossEntropyWithLogits().

◆ y_reshape()

const Vec & nnfw::cker::BCast::y_reshape ( ) const
inline

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