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 "ConstantInitializer.h"
26 ConstantInitializer::ConstantInitializer(const ir::Operands &operands,
27 const std::shared_ptr<TensorBuilder> &tensor_builder)
28 : IConstantInitializer{operands}, _tensor_builder{tensor_builder}
33 void ConstantInitializer::visit(const ir::operation::Conv2D &node)
35 const auto &kernel_index = node.getInputs().at(ir::operation::Conv2D::KERNEL);
36 const auto &kernel_obj = _operands.at(kernel_index);
37 registerCopyInitializer(kernel_index, kernel_obj);
39 const auto &bias_index = node.getInputs().at(ir::operation::Conv2D::BIAS);
40 const auto &bias_obj = _operands.at(bias_index);
41 registerCopyInitializer(bias_index, bias_obj);
44 void ConstantInitializer::visit(const ir::operation::DepthwiseConv2D &node)
46 const auto &kernel_index = node.getInputs().at(ir::operation::DepthwiseConv2D::KERNEL);
47 const auto &kernel_obj = _operands.at(kernel_index);
48 registerCopyInitializer(kernel_index, kernel_obj);
50 const auto &bias_index = node.getInputs().at(ir::operation::DepthwiseConv2D::BIAS);
51 const auto &bias_obj = _operands.at(bias_index);
52 registerCopyInitializer(bias_index, bias_obj);
55 void ConstantInitializer::visit(const ir::operation::FullyConnected &node)
57 const auto &weight_index = node.getInputs().at(ir::operation::FullyConnected::WEIGHT);
58 const auto &weight_obj = _operands.at(weight_index);
59 registerCopyInitializer(weight_index, weight_obj);
61 const auto &bias_index = node.getInputs().at(ir::operation::FullyConnected::BIAS);
62 if (!bias_index.undefined())
64 const auto &bias_obj = _operands.at(bias_index);
65 registerCopyInitializer(bias_index, bias_obj);
70 } // namespace backend