--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __NEURUN_BACKEND_ATOMIC_STAGE_H__
+#define __NEURUN_BACKEND_ATOMIC_STAGE_H__
+
+#include <vector>
+#include <functional>
+
+#include "backend/interface/IStage.h"
+
+namespace neurun
+{
+namespace backend
+{
+
+class AtomicStage final : public IStage
+{
+public:
+ AtomicStage() = default;
+ template <typename F> AtomicStage(F f) : fn(f) {}
+
+ virtual void operator()(IExecutionBuilder &execution_builder) const override
+ {
+ fn(execution_builder);
+ }
+
+ virtual void operator<<(StageFn f) override { fn = f; }
+
+private:
+ StageFn fn = nullptr;
+};
+
+} // namespace backend
+} // namespace neurun
+
+#endif // __NEURUN_BACKEND_ATOMIC_STAGE_H__
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __NEURUN_BACKEND_STAGE_SEQUENCE_H__
+#define __NEURUN_BACKEND_STAGE_SEQUENCE_H__
+
+#include <vector>
+#include <functional>
+
+#include "backend/interface/IStage.h"
+#include "cpp14/memory.h"
+
+namespace neurun
+{
+namespace backend
+{
+
+class StageSequence final : public IStage
+{
+public:
+ StageSequence() = default;
+ template <typename F> StageSequence(F f)
+ {
+ stages.emplace_back(nnfw::cpp14::make_unique<AtomicStage>(f));
+ }
+
+ virtual void operator()(IExecutionBuilder &execution_builder) const override
+ {
+ for (const auto &stage : stages)
+ (*stage)(execution_builder);
+ }
+
+ virtual void operator<<(StageFn f) override
+ {
+ stages.emplace_back(nnfw::cpp14::make_unique<AtomicStage>(f));
+ }
+
+private:
+ std::vector<std::unique_ptr<IStage>> stages;
+};
+
+} // namespace backend
+} // namespace neurun
+
+#endif // __NEURUN_BACKEND_STAGE_SEQUENCE_H__
--- /dev/null
+/*
+ * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __NEURUN_BACKEND_ISTAGE_H__
+#define __NEURUN_BACKEND_ISTAGE_H__
+
+#include <functional>
+
+struct IExecutionBuilder;
+
+namespace neurun
+{
+namespace backend
+{
+
+using StageFn = std::function<void(IExecutionBuilder &)>;
+
+struct IStage
+{
+ IStage() = default;
+ virtual ~IStage() = default;
+
+ virtual void operator()(IExecutionBuilder &execution_builder) const = 0;
+ virtual void operator<<(StageFn f) = 0;
+};
+
+} // namespace backend
+} // namespace neurun
+
+#endif // __NEURUN_BACKEND_ISTAGE_H__
virtual void append(std::unique_ptr<::neurun::exec::IFunction> &&f) = 0;
};
+// TODO: Replace as IStage
using Stage = std::function<void(IExecutionBuilder &)>;
namespace neurun