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 void NodeExecution::execute(loco::Pull *pull)
32 // TODO Remove deprecated code
34 validate(annot_data(pull), "Data for Pull is not ready");
36 validate(annot_domain(pull) == loco::Domain::Tensor, "Domain for Pull is not Tensor");
41 auto input_data = user_data(pull);
43 validate(input_data, "Input not ready");
44 // User always passes a "Tensor"
46 std::unique_ptr<NodeData> pull_data = nullptr;
48 // Q. Is it possible to use generic one?
49 switch (input_data->dtype())
51 case loco::DataType::S32:
53 auto input_bufptr = input_data->as_s32_bufptr();
54 pull_data = make_data(*input_bufptr);
57 case loco::DataType::FLOAT32:
59 auto input_bufptr = input_data->as_f32_bufptr();
60 pull_data = make_data(*input_bufptr);
64 throw std::runtime_error("NYI for this DataType");
67 assert(pull_data != nullptr);
68 annot_data(pull, std::move(pull_data));
69 annot_domain(pull, loco::Domain::Tensor);
72 } // namespace locomotiv