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 "backend/cpu_common/ConstantInitializer.h"
18 #include "backend/cpu_common/Tensor.h"
27 ConstantInitializer::ConstantInitializer(const ir::Operands &operands,
28 const std::shared_ptr<ITensorRegistry> &tensor_reg)
29 : ConstantInitializerBase{operands}, _tensor_reg{tensor_reg}
34 void ConstantInitializer::registerDefaultInitializer(const ir::OperandIndex &index,
35 const ir::Operand &obj)
37 registerExternalInitializer(index, obj);
40 void ConstantInitializer::registerExternalInitializer(const ir::OperandIndex &index,
41 const ir::Operand &obj)
44 // TODO Add to check if tensor has been allocated
45 if (!obj.isConstant())
48 _init_map[index] = [](const onert::ir::Operand &model_obj, onert::backend::ITensor &itensor) {
49 auto data = model_obj.shareData();
50 assert(data && data->base());
51 ExternalTensor &tensor = dynamic_cast<ExternalTensor &>(itensor);
56 } // namespace cpu_common
57 } // namespace backend