ONE - On-device Neural Engine
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
nnfw::cker::functor::BroadcastTo< Device, T > Struct Template Reference

#include <BroadcastTo.h>

Public Member Functions

template<int NDIMS>
void DoBCast32Bit (const Device &device, typename TTypes< T, NDIMS >::Tensor out, typename TTypes< T, NDIMS >::ConstTensor in, const typename Eigen::array< int, NDIMS > &bcast) const
 
template<int NDIMS>
void DoBCast (const Device &device, typename TTypes< T, NDIMS >::Tensor out, typename TTypes< T, NDIMS >::ConstTensor in, const typename Eigen::array< Eigen::DenseIndex, NDIMS > &bcast) const
 
template<int NDIMS>
void ReshapeAndBCast (const Device &device, Tensor &output_tensor, const Tensor &input_tensor, const BCast &bcast) const
 
void operator() (const Device &device, Tensor &output_tensor, const Shape &output_shape, const Tensor &input_tensor, const Shape &input_shape, const BCast &bcast) const
 

Detailed Description

template<typename Device, typename T>
struct nnfw::cker::functor::BroadcastTo< Device, T >

Definition at line 58 of file BroadcastTo.h.

Member Function Documentation

◆ DoBCast()

template<typename Device , typename T >
template<int NDIMS>
void nnfw::cker::functor::BroadcastTo< Device, T >::DoBCast ( const Device &  device,
typename TTypes< T, NDIMS >::Tensor  out,
typename TTypes< T, NDIMS >::ConstTensor  in,
const typename Eigen::array< Eigen::DenseIndex, NDIMS > &  bcast 
) const
inline

Definition at line 69 of file BroadcastTo.h.

72 {
73 out.device(device) = in.broadcast(bcast);
74 }

◆ DoBCast32Bit()

template<typename Device , typename T >
template<int NDIMS>
void nnfw::cker::functor::BroadcastTo< Device, T >::DoBCast32Bit ( const Device &  device,
typename TTypes< T, NDIMS >::Tensor  out,
typename TTypes< T, NDIMS >::ConstTensor  in,
const typename Eigen::array< int, NDIMS > &  bcast 
) const
inline

Definition at line 61 of file BroadcastTo.h.

64 {
65 To32Bit(out).device(device) = To32Bit(in).broadcast(bcast);
66 }
TTypes< typenameTensorType::Scalar, TensorType::NumIndices >::Tensor32Bit To32Bit(TensorType in)
Definition Tensor.h:178

References nnfw::cker::To32Bit().

◆ operator()()

template<typename Device , typename T >
void nnfw::cker::functor::BroadcastTo< Device, T >::operator() ( const Device &  device,
Tensor output_tensor,
const Shape output_shape,
const Tensor input_tensor,
const Shape input_shape,
const BCast bcast 
) const
inline

Definition at line 100 of file BroadcastTo.h.

102 {
103 const int ndims = bcast.y_reshape().size();
104 switch (ndims)
105 {
106 case 1:
107 ReshapeAndBCast<1>(device, output_tensor, input_tensor, bcast);
108 break;
109 case 2:
110 ReshapeAndBCast<2>(device, output_tensor, input_tensor, bcast);
111 break;
112 case 3:
113 ReshapeAndBCast<3>(device, output_tensor, input_tensor, bcast);
114 break;
115 case 4:
116 ReshapeAndBCast<4>(device, output_tensor, input_tensor, bcast);
117 break;
118 case 5:
119 ReshapeAndBCast<5>(device, output_tensor, input_tensor, bcast);
120 break;
121 default:
122 // NOTE : UNUSED leaves for maintenance purposes.
124 UNUSED(input_shape);
125 break;
126 }
127 }
#define UNUSED(x)
const luci_interpreter::RuntimeShape output_shape

References output_shape, UNUSED, and nnfw::cker::BCast::y_reshape().

◆ ReshapeAndBCast()

template<typename Device , typename T >
template<int NDIMS>
void nnfw::cker::functor::BroadcastTo< Device, T >::ReshapeAndBCast ( const Device &  device,
Tensor output_tensor,
const Tensor input_tensor,
const BCast bcast 
) const
inline

Definition at line 77 of file BroadcastTo.h.

79 {
80 const bool can_use_32bit = std::is_same<Eigen::GpuDevice, Device>::value &&
81 output_tensor.shape.FlatSize() < kint32max &&
82 input_tensor.shape.FlatSize() < kint32max;
83 if (can_use_32bit)
84 {
85 DoBCast32Bit<NDIMS>(device, output_tensor.template shaped<T, NDIMS>(bcast.result_shape()),
86 input_tensor.template shaped<T, NDIMS>(bcast.x_reshape()),
87 BCast::ToIndexArrayType<int, NDIMS>(bcast.x_bcast()));
88 }
89 else
90 {
91 DoBCast<NDIMS>(device, output_tensor.template shaped<T, NDIMS>(bcast.result_shape()),
92 input_tensor.template shaped<T, NDIMS>(bcast.x_reshape()),
93 BCast::ToIndexArrayType<Eigen::DenseIndex, NDIMS>(bcast.x_bcast()));
94 }
95 }

References nnfw::cker::Shape::FlatSize(), nnfw::cker::BCast::result_shape(), nnfw::cker::Tensor::shape, nnfw::cker::BCast::x_bcast(), and nnfw::cker::BCast::x_reshape().


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