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 "exec/FunctionSequence.h"
19 #include "ir/Operation.h"
20 #include "backend/ITensorRegistry.h"
21 #include "util/logging.h"
28 void FunctionSequence::run()
30 if (_enable_dynamic_shape_inferer && _dynamic_tensor_ctx)
32 // acl_cl and acl_neon backend don't support dynamic shape.
33 // _dynamic_tensor_ctx is always nullptr for acl_cl and acl_neon
34 // Thus, those two bakends cannot reach here.
36 // Do dynamic shape inference
37 _dynamic_tensor_ctx->op->accept(*_dynamic_tensor_ctx->dynamic_shape_inferer);
39 for (const auto &function : _functions)
41 // NOTE the function could be also FunctionSequence so we do this
42 // TODO Remove this or do this recursively
43 auto *sub_func_seq = dynamic_cast<FunctionSequence *>(function.get());
44 if (sub_func_seq != nullptr)
46 sub_func_seq->enableDynamicShapeInferer(true);
47 sub_func_seq->dynamic_tensor_ctx(dynamic_tensor_ctx());
56 for (const auto &function : _functions)
63 void FunctionSequence::prepare()
65 for (const auto &function : _functions)
71 void FunctionSequence::append(std::unique_ptr<IFunction> &&function)
73 _functions.push_back(std::move(function));
76 void FunctionSequence::iterate(const std::function<void(IFunction &)> &fn)
78 for (const auto &func : _functions)