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"
20 #include "NodeDataImpl.h"
21 #include "NodeDomain.h"
22 #include "Validation.h"
30 using namespace locomotiv;
32 void execute_node(loco::Pull *pull)
34 // TODO Remove deprecated code
36 validate(annot_data(pull), "Data for Pull is not ready");
38 validate(annot_domain(pull) == loco::Domain::Tensor, "Domain for Pull is not Tensor");
43 auto input_data = user_data(pull);
45 validate(input_data, "Input not ready");
46 // User always passes a "Tensor"
48 std::unique_ptr<NodeData> pull_data = nullptr;
50 // Q. Is it possible to use generic one?
51 switch (input_data->dtype())
53 case loco::DataType::S32:
55 auto input_bufptr = input_data->as_s32_bufptr();
56 pull_data = make_data(*input_bufptr);
59 case loco::DataType::FLOAT32:
61 auto input_bufptr = input_data->as_f32_bufptr();
62 pull_data = make_data(*input_bufptr);
66 throw std::runtime_error("NYI for this DataType");
69 assert(pull_data != nullptr);
70 annot_data(pull, std::move(pull_data));
71 annot_domain(pull, loco::Domain::Tensor);
79 void NodeExecution::execute(loco::Pull *pull) { execute_node(pull); }
81 } // namespace locomotiv