2 * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "NodeExecution.h"
19 #include "NodeDataImpl.h"
20 #include "NodeDomain.h"
21 #include "Validation.h"
29 using namespace locomotiv;
31 void execute_node(loco::BiasEncode *bias_enc)
33 auto input_data = annot_data(bias_enc->input());
35 validate(input_data, "Input not ready");
36 validate(annot_domain(bias_enc->input()) == loco::Domain::Tensor,
37 "Input domain should be Tensor");
38 validate(input_data->shape()->rank() == 1, "Input data rank must be 1");
40 std::unique_ptr<NodeData> bias_enc_data = nullptr;
42 switch (input_data->dtype())
44 case loco::DataType::S32:
46 auto input_bufptr = input_data->as_s32_bufptr();
47 bias_enc_data = make_data(*input_bufptr);
50 case loco::DataType::FLOAT32:
52 auto input_bufptr = input_data->as_f32_bufptr();
53 bias_enc_data = make_data(*input_bufptr);
57 throw std::runtime_error("NYI for this DataType");
60 assert(bias_enc_data != nullptr);
61 annot_data(bias_enc, std::move(bias_enc_data));
62 annot_domain(bias_enc, loco::Domain::Bias);
70 void NodeExecution::execute(loco::BiasEncode *bias_enc) { execute_node(bias_enc); }
72 } // namespace locomotiv