18#ifndef __NNFW_CKER_BROADCAST_TO_H__
19#define __NNFW_CKER_BROADCAST_TO_H__
32#define UNUSED(x) (void)(x)
40static const int32_t kint32max = ((int32_t)0x7FFFFFFF);
54 out.device(d) = out.constant(in());
63 const typename Eigen::array<int, NDIMS> &bcast)
const
71 const typename Eigen::array<Eigen::DenseIndex, NDIMS> &bcast)
const
73 out.device(device) = in.broadcast(bcast);
78 const BCast &bcast)
const
80 const bool can_use_32bit = std::is_same<Eigen::GpuDevice, Device>::value &&
81 output_tensor.shape.FlatSize() < kint32max &&
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()));
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()));
101 const Tensor &input_tensor,
const Shape &input_shape,
const BCast &bcast)
const
103 const int ndims = bcast.
y_reshape().size();
107 ReshapeAndBCast<1>(device, output_tensor, input_tensor, bcast);
110 ReshapeAndBCast<2>(device, output_tensor, input_tensor, bcast);
113 ReshapeAndBCast<3>(device, output_tensor, input_tensor, bcast);
116 ReshapeAndBCast<4>(device, output_tensor, input_tensor, bcast);
119 ReshapeAndBCast<5>(device, output_tensor, input_tensor, bcast);
135 const int input_flatsize = input_shape.
FlatSize();
139 memcpy(output_data, input_data, input_flatsize *
sizeof(T));
153 input_tensor.
buffer = input_data;
156 output_tensor.buffer = output_data;
161 if (input_flatsize == 0)
164 input_tensor.
scalar<T>());
176 input_tensor, input_shape, bcast);
static Vec FromShape(const Shape &shape)
static Shape ToShape(const BCastList::Vec &vec)
const Vec & result_shape() const
const Vec & x_reshape() const
const Vec & y_reshape() const
const Vec & output_shape() const
const Vec & x_bcast() const
int32_t DimensionsCount() const
void ReplaceWith(int dimensions_count, const int32_t *dims_data)
const luci_interpreter::RuntimeShape output_shape
const Eigen::ThreadPoolDevice * GetThreadPoolDevice()
void BroadcastTo(const Shape &input_shape, T *input_data, const Shape &output_shape, T *output_data)
TTypes< typenameTensorType::Scalar, TensorType::NumIndices >::Tensor32Bit To32Bit(TensorType in)
Eigen::TensorMap< Eigen::TensorFixedSize< const T, Eigen::Sizes<>, Eigen::RowMajor, IndexType >, Eigen::Aligned > ConstScalar
Eigen::TensorMap< Eigen::Tensor< const T, NDIMS, Eigen::RowMajor, IndexType >, Eigen::Aligned > ConstTensor
Eigen::TensorMap< Eigen::Tensor< T, 1, Eigen::RowMajor, IndexType >, Eigen::Aligned > Flat
Eigen::TensorMap< Eigen::Tensor< T, NDIMS, Eigen::RowMajor, IndexType >, Eigen::Aligned > Tensor
TTypes< T >::ConstScalar scalar() const
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
void operator()(const Device &device, Tensor &output_tensor, const Shape &output_shape, const Tensor &input_tensor, const Shape &input_shape, const BCast &bcast) const
void ReshapeAndBCast(const Device &device, Tensor &output_tensor, const Tensor &input_tensor, const BCast &bcast) const
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
void operator()(const Eigen::ThreadPoolDevice &d, typename TTypes< T >::Flat out, typename TTypes< T >::ConstScalar in)
void operator()(const Device &d, typename TTypes< T >::Flat out, typename TTypes< T >::ConstScalar in)