18#ifndef __NNFW_CKER_SELECT_H__
19#define __NNFW_CKER_SELECT_H__
31template <
typename D,
typename T>
32void Select(
const Shape &input_condition_shape,
const D *input_condition_data,
33 const Shape &input_x_shape,
const T *input_x_data,
const Shape &input_y_shape,
36 const int64_t flatsize =
38 for (int64_t i = 0; i < flatsize; ++i)
40 output_data[i] = (input_condition_data[i] != 0) ? input_x_data[i] : input_y_data[i];
44template <
typename D,
typename T>
46 const Shape &input_x_shape,
const T *input_x_data,
const Shape &input_y_shape,
49 const int64_t outer_size = input_condition_shape.
FlatSize();
54 for (int64_t i = 0; i < outer_size; i++)
56 const T *input_data = (input_condition_data[i] != 0) ? input_x_data : input_y_data;
57 memcpy(output_data +
offset, input_data +
offset, inner_size *
sizeof(T));
62template <
typename D,
typename T>
64 const Shape &input_x_shape,
const T *input_x_data,
65 const Shape &input_y_shape,
const T *input_y_data,
79 &desc_condition, &desc_x, &desc_y);
92 for (
int b = 0; b < extended_output_shape.
Dims(0); ++b)
94 for (
int y = 0; y < extended_output_shape.
Dims(1); ++y)
96 for (
int x = 0; x < extended_output_shape.
Dims(2); ++x)
98 for (
int c = 0; c < extended_output_shape.
Dims(3); ++c)
103 output_data[
Offset(extended_output_shape, b, y, x, c)] =
104 input_condition_data[condition_index] ? input_x_data[x_index] : input_y_data[y_index];
int32_t DimensionsCount() const
int32_t Dims(int i) const
__global uchar * offset(const Image *img, int x, int y)
const luci_interpreter::RuntimeShape output_shape
int MatchingDim(const Shape &shape1, int index1, const Shape &shape2, int index2)
void Select(const Shape &input_condition_shape, const D *input_condition_data, const Shape &input_x_shape, const T *input_x_data, const Shape &input_y_shape, const T *input_y_data, const Shape &output_shape, T *output_data)
int Offset(const Shape &shape, int i0, int i1, int i2, int i3)
void RankOneSelect(const Shape &input_condition_shape, const D *input_condition_data, const Shape &input_x_shape, const T *input_x_data, const Shape &input_y_shape, const T *input_y_data, const Shape &output_shape, T *output_data)
void NdArrayDescsForElementwiseBroadcast(const Shape &input0_shape, const Shape &input1_shape, NdArrayDesc< N > *desc0_out, NdArrayDesc< N > *desc1_out)
int MatchingFlatSizeSkipDim(const Shape &shape, int skip_dim, const Shape &check_shape_0)
void BroadcastSelect4DSlow(const Shape &input_condition_shape, const D *input_condition_data, const Shape &input_x_shape, const T *input_x_data, const Shape &input_y_shape, const T *input_y_data, const Shape &output_shape, T *output_data)
int MatchingFlatSize(const Shape &shape, Ts... check_shapes)
int SubscriptToIndex(const NdArrayDesc< 4 > &desc, int i0, int i1, int i2, int i3)