19#include "kernels/Utils.h"
30void evalGeneric(
const circle::Operator *cur_op,
BaseRuntimeGraph *runtime_graph)
32 const auto output_index = cur_op->outputs()->operator[](0);
33 assert(output_index != -1);
34 const auto output = runtime_graph->getCircleTensorByIndex(output_index);
36 const auto input_sizes = cur_op->inputs()->size();
38 auto input1_index = cur_op->inputs()->operator[](0);
39 const auto *tensor1 = runtime_graph->getCircleTensorByIndex(input1_index);
41 const int flat_size = Tensor::num_elements(tensor1);
43 std::vector<const T *> all_input_data;
44 for (int32_t i = 0; i < input_sizes; ++i)
47 const auto *
tensor = runtime_graph->getCircleTensorByIndex(input_index);
49 const auto *tensor_data = runtime_graph->getDataByTensor(tensor);
50 if (tensor_data ==
nullptr)
51 tensor_data = runtime_graph->getConstDataByTensor(tensor);
53 auto *
data =
reinterpret_cast<const T *
>(tensor_data);
54 all_input_data.push_back(
data);
57 auto *
output_data =
reinterpret_cast<T *
>(runtime_graph->getDataByTensor(output));
66 const int num_inputs = cur_op->inputs()->size();
71 const auto input1_index = cur_op->inputs()->operator[](0);
72 assert(input1_index != -1);
75 assert(input1_tensor !=
nullptr);
77 for (
int i = 1; i < num_inputs; ++i)
79 const auto input_index = cur_op->inputs()->operator[](i);
80 assert(input_index != -1);
83 assert(input_tensor !=
nullptr);
86 Tensor::element_type(input_tensor));
89 Tensor::num_elements(input_tensor));
95 const auto output_index = cur_op->outputs()->operator[](0);
96 assert(output_index != -1);
99 switch (Tensor::element_type(output))
102 case DataType::FLOAT32:
104 evalGeneric<float>(cur_op, runtime_graph);
109 assert(
false &&
"Unsupported type.");
const circle::Tensor * getCircleTensorByIndex(int32_t index)
#define LUCI_INTERPRETER_CHECK(cond)
const T * data(const std::vector< T, Alloc > &v)
void AddN(const size_t flat_size, const size_t num_inputs, const T *const *input_data, T *output_data)
void configure_kernel_CircleAddN(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)
RuntimeGraph BaseRuntimeGraph
void execute_kernel_CircleAddN(const circle::Operator *cur_op, BaseRuntimeGraph *runtime_graph)