ONE - On-device Neural Engine
Loading...
Searching...
No Matches
PALSelectV2.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef ONERT_MICRO_EXECUTE_PAL_SELECT_V2_H
18#define ONERT_MICRO_EXECUTE_PAL_SELECT_V2_H
19
20#include "PALUtils.h"
21#include "ProcessBroadcastShapes.h"
22#include "core/OMRuntimeShape.h"
23#include "core/OMKernelData.h"
24
25namespace onert_micro
26{
27namespace execute
28{
29namespace pal
30{
31
32template <typename D, typename T>
33void Select(const core::OMRuntimeShape &input_condition_shape, const D *input_condition_data,
34 const core::OMRuntimeShape &input_x_shape, const T *input_x_data,
35 const core::OMRuntimeShape &input_y_shape, const T *input_y_data,
36 const core::OMRuntimeShape &output_shape, T *output_data)
37{
38 int64_t flatsize;
39 // Allow select operator executions on mixed scalar tensors and one element
40 // tensors.
41 if (input_condition_shape.flatSize() == 1 && input_x_shape.flatSize() == 1 &&
42 input_y_shape.flatSize() == 1 && output_shape.flatSize() == 1)
43 {
44 flatsize = 1;
45 }
46 else
47 {
48 flatsize = input_condition_shape.flatSize();
49 }
50 for (int64_t i = 0; i < flatsize; ++i)
51 {
52 output_data[i] = input_condition_data[i] ? input_x_data[i] : input_y_data[i];
53 }
54}
55
56} // namespace pal
57} // namespace execute
58} // namespace onert_micro
59
60#endif // ONERT_MICRO_EXECUTE_PAL_SELECT_V2_H
const luci_interpreter::RuntimeShape output_shape
void Select(const core::OMRuntimeShape &input_condition_shape, const D *input_condition_data, const core::OMRuntimeShape &input_x_shape, const T *input_x_data, const core::OMRuntimeShape &input_y_shape, const T *input_y_data, const core::OMRuntimeShape &output_shape, T *output_data)
Definition PALSelectV2.h:33