Move and split classes in `internal/Plan.h` into separate files.
- `internal::Plan` to `neurun::codegen::Plan`
- `internal::operand::Context` to `neurun::codegen::operand::Context`
- `internal::op::Sequence` to `neurun::codegen::operation::Sequence`
Signed-off-by: Hanjoung Lee <hanjoung.lee@samsung.com>
namespace acl_cl
{
-TensorBuilder::TensorBuilder(::internal::Plan &plan) : _plan(plan)
+TensorBuilder::TensorBuilder(codegen::Plan &plan) : _plan(plan)
{
// DO NOTHING
}
#define __NEURUN_BACKEND_ACL_CL_TENSOR_BUILDER_H__
#include "backend/ITensorBuilder.h"
-#include "internal/Plan.h"
+#include "codegen/Plan.h"
#include <unordered_map>
#include <unordered_set>
class TensorBuilder : public ITensorBuilder
{
public:
- TensorBuilder(::internal::Plan &plan);
+ TensorBuilder(codegen::Plan &plan);
virtual void mark(const ::neurun::graph::operand::Index &ind) override;
virtual void markFromCommon(const ::internal::tflite::op::Node &op, int32_t ind) override;
std::shared_ptr<::arm_compute::CLTensor> at(const ::neurun::graph::operand::Index &ind);
private:
- ::internal::Plan &_plan;
+ codegen::Plan &_plan;
std::unordered_set<int> _inds;
std::unordered_map<int, std::shared_ptr<::arm_compute::CLTensor>> _tensors;
};
namespace cpu
{
-TensorBuilder::TensorBuilder(::internal::Plan &plan) : _plan(plan)
+TensorBuilder::TensorBuilder(codegen::Plan &plan) : _plan(plan)
{
// DO NOTHING
}
#include "backend/ITensorBuilder.h"
#include "internal/cpu.h"
-#include "internal/Plan.h"
+#include "codegen/Plan.h"
namespace neurun
{
class TensorBuilder : public ITensorBuilder
{
public:
- TensorBuilder(::internal::Plan &plan);
+ TensorBuilder(codegen::Plan &plan);
virtual void mark(const ::neurun::graph::operand::Index &ind) override;
virtual void markFromCommon(const ::internal::tflite::op::Node &op, int32_t ind) override;
std::shared_ptr<::internal::cpu::Tensor> at(const ::neurun::graph::operand::Index &ind);
private:
- ::internal::Plan &_plan;
+ codegen::Plan &_plan;
std::unordered_set<int> _inds;
std::unordered_map<int, std::shared_ptr<::internal::cpu::Tensor>> _tensors;
};
--- /dev/null
+#include "Plan.h"
+
+namespace neurun
+{
+namespace codegen
+{
+
+// NO IMPLEMENTATION YET
+
+} // namespace codegen
+} // namespace neurun
--- /dev/null
+#ifndef __NEURUN_CODEGEN_PLAN_H__
+#define __NEURUN_CODEGEN_PLAN_H__
+
+#include "graph/Graph.h"
+#include "codegen/operand/Context.h"
+#include "codegen/operation/Sequence.h"
+
+namespace neurun
+{
+namespace codegen
+{
+
+class Plan
+{
+public:
+ Plan(const std::shared_ptr<neurun::graph::Graph> &model) : _model(model)
+ {
+ // DO NOTHING
+ }
+
+public:
+ neurun::graph::Graph &model(void) { return *_model; }
+ const neurun::graph::Graph &model(void) const { return *_model; }
+
+public:
+ operand::Context &operands(void) { return _operands; }
+ const operand::Context &operands(void) const { return _operands; }
+
+public:
+ operand::Context &common_operands(void) { return _common_operands; }
+ const operand::Context &common_operands(void) const { return _common_operands; }
+
+public:
+ operation::Sequence &operations(void) { return _ops; }
+ const operation::Sequence &operations(void) const { return _ops; }
+
+private:
+ std::shared_ptr<neurun::graph::Graph> _model;
+ operand::Context _operands;
+ operand::Context _common_operands;
+ operation::Sequence _ops;
+};
+
+} // namespace codegen
+} // namespace neurun
+
+#endif // __NEURUN_CODEGEN_PLAN_H__
#define __NEURUN_CODEGEN_PLAN_BUILDER_H__
#include "IPlanBuilder.h"
-#include "internal/Plan.h"
+#include "codegen/Plan.h"
#include "codegen/BackendResolver.h"
#include "backend/IStageGenerator.h"
class ExecutionBuilder final : public IExecutionBuilder
{
public:
- ExecutionBuilder(::internal::Plan &plan) : _plan{plan}
+ ExecutionBuilder(codegen::Plan &plan) : _plan{plan}
{
// DO NOTHING
}
}
private:
- ::internal::Plan &_plan;
+ codegen::Plan &_plan;
};
class PlanBuilder final : public IPlanBuilder
{
public:
- PlanBuilder(::internal::Plan &plan) : _plan{plan}
+ PlanBuilder(codegen::Plan &plan) : _plan{plan}
{
// DO NOTHING
}
const std::map<int, ::arm_compute::TensorInfo> &tensor_info_ctx() { return _tensor_info_ctx; }
private:
- ::internal::Plan &_plan;
+ codegen::Plan &_plan;
private:
std::map<int, ::arm_compute::TensorInfo> _tensor_info_ctx;
--- /dev/null
+#include "Context.h"
+
+namespace neurun
+{
+namespace codegen
+{
+namespace operand
+{
+
+Context &Context::set(const graph::operand::Index &id,
+ const std::shared_ptr<backend::operand::IObject> &object)
+{
+ _objects[id.value()].emplace_back(object);
+ return (*this);
+}
+
+} // namespace operand
+} // namespace codegen
+} // namespace neurun
--- /dev/null
+#ifndef __NEURUN_CODEGEN_OPERAND_CONTEXT_H__
+#define __NEURUN_CODEGEN_OPERAND_CONTEXT_H__
+
+#include "backend/IObject.h"
+#include "graph/operand/Index.h"
+
+#include <map>
+
+namespace neurun
+{
+namespace codegen
+{
+namespace operand
+{
+
+class Context
+{
+public:
+ Context &set(const graph::operand::Index &ind,
+ const std::shared_ptr<backend::operand::IObject> &object);
+
+public:
+ bool exist(const ::neurun::graph::operand::Index &ind) const
+ {
+ return _objects.find(ind.asInt()) != _objects.end();
+ }
+
+public:
+ const std::vector<std::shared_ptr<backend::operand::IObject>> &
+ at(const graph::operand::Index &ind) const
+ {
+ return _objects.at(ind.asInt());
+ }
+
+ std::vector<std::shared_ptr<backend::operand::IObject>> &at(const graph::operand::Index &ind)
+ {
+ return _objects.at(ind.asInt());
+ }
+
+private:
+ std::map<int, std::vector<std::shared_ptr<backend::operand::IObject>>> _objects;
+};
+
+} // namespace operand
+} // namespace codegen
+} // namespace neurun
+
+#endif // __NEURUN_CODEGEN_OPERAND_CONTEXT_H__
--- /dev/null
+#include "Sequence.h"
+
+namespace neurun
+{
+namespace codegen
+{
+namespace operation
+{
+
+// NO IMPLEMENTATION YET
+
+} // namespace operation
+} // namespace codegen
+} // namespace neurun
--- /dev/null
+#ifndef __NEURUN_CODEGEN_OPERATION_SEQUENCE_H__
+#define __NEURUN_CODEGEN_OPERATION_SEQUENCE_H__
+
+#include <stdint.h>
+#include <arm_compute/runtime/IFunction.h>
+#include <memory>
+#include <vector>
+
+namespace neurun
+{
+namespace codegen
+{
+namespace operation
+{
+
+class Sequence
+{
+public:
+ uint32_t size(void) const { return _functions.size(); }
+
+public:
+ Sequence &append(std::unique_ptr<::arm_compute::IFunction> &&func)
+ {
+ _functions.emplace_back(std::move(func));
+ return (*this);
+ }
+
+public:
+ ::arm_compute::IFunction &at(uint32_t n) const { return *(_functions.at(n)); }
+
+private:
+ std::vector<std::unique_ptr<::arm_compute::IFunction>> _functions;
+};
+
+} // namespace operation
+} // namespace codegen
+} // namespace neurun
+
+#endif // __NEURUN_CODEGEN_OPERATION_SEQUENCE_H__
#ifndef __COMPILATION_H__
#define __COMPILATION_H__
-#include "internal/Plan.h"
+#include "codegen/Plan.h"
#include "graph/Graph.h"
struct ANeuralNetworksCompilation
{
public:
ANeuralNetworksCompilation(const std::shared_ptr<neurun::graph::Graph> &model)
- : _plan{new internal::Plan{model}}
+ : _plan{new neurun::codegen::Plan{model}}
{
// DO NOTHING
}
public:
- internal::Plan &plan(void) { return *_plan; }
+ neurun::codegen::Plan &plan(void) { return *_plan; }
public:
- void publish(std::shared_ptr<const internal::Plan> &plan) { plan = _plan; }
+ void publish(std::shared_ptr<const neurun::codegen::Plan> &plan) { plan = _plan; }
int finish();
private:
- std::shared_ptr<internal::Plan> _plan;
+ std::shared_ptr<neurun::codegen::Plan> _plan;
};
#endif
#ifndef __EXECUTION_H__
#define __EXECUTION_H__
-#include "internal/Plan.h"
+#include "codegen/Plan.h"
#include "internal/Source.h"
#include "internal/Sink.h"
struct ANeuralNetworksExecution
{
public:
- ANeuralNetworksExecution(const std::shared_ptr<const internal::Plan> &plan) : _plan{plan}
+ ANeuralNetworksExecution(const std::shared_ptr<const neurun::codegen::Plan> &plan) : _plan{plan}
{
_sources.resize(_plan->model().inputs().size());
_sinks.resize(_plan->model().outputs().size());
}
public:
- const internal::Plan &plan(void) const { return *_plan; }
+ const neurun::codegen::Plan &plan(void) const { return *_plan; }
private:
- std::shared_ptr<const internal::Plan> _plan;
+ std::shared_ptr<const neurun::codegen::Plan> _plan;
public:
// TODO Use InputIndex instead of int
return ANEURALNETWORKS_UNEXPECTED_NULL;
}
- std::shared_ptr<const ::internal::Plan> plan;
+ std::shared_ptr<const neurun::codegen::Plan> plan;
compilation->publish(plan);
namespace internal
{
-BackendManager::BackendManager(::internal::Plan &plan) : _plan(plan)
+BackendManager::BackendManager(neurun::codegen::Plan &plan) : _plan(plan)
{
const auto &operands = _plan.model().operands();
#include <memory>
-#include "internal/Plan.h"
+#include "codegen/Plan.h"
#include "backend/IInitializerGenerator.h"
#include "backend/IStageGenerator.h"
#include "backend/ITensorBuilder.h"
class BackendManager
{
public:
- BackendManager(::internal::Plan &plan);
+ BackendManager(neurun::codegen::Plan &plan);
Backend get(const std::string &key);
std::shared_ptr<::internal::common::TensorBuilder> getCommonTensorBuilder();
private:
- ::internal::Plan &_plan;
+ neurun::codegen::Plan &_plan;
std::map<std::string, Backend> _gen_map;
std::shared_ptr<::internal::common::TensorBuilder> _common_tensor_builder;
};
+++ /dev/null
-#include "Plan.h"
-
-namespace internal
-{
-namespace operand
-{
-
-Context &Context::set(const ::neurun::graph::operand::Index &id,
- const std::shared_ptr<neurun::backend::operand::IObject> &object)
-{
- _objects[id.asInt()].emplace_back(object);
- return (*this);
-}
-
-} // namespace operand
-} // namespace internal
+++ /dev/null
-#ifndef __INTERNAL_PLAN_H__
-#define __INTERNAL_PLAN_H__
-
-#include "graph/Graph.h"
-#include "backend/IObject.h"
-
-#include <map>
-
-namespace internal
-{
-namespace operand
-{
-
-class Context
-{
-public:
- Context &set(const ::neurun::graph::operand::Index &ind,
- const std::shared_ptr<neurun::backend::operand::IObject> &object);
-
-public:
- bool exist(const ::neurun::graph::operand::Index &ind) const
- {
- return _objects.find(ind.asInt()) != _objects.end();
- }
-
-public:
- const std::vector<std::shared_ptr<neurun::backend::operand::IObject>> &
- at(const ::neurun::graph::operand::Index &ind) const
- {
- return _objects.at(ind.asInt());
- }
-
- std::vector<std::shared_ptr<neurun::backend::operand::IObject>> &
- at(const ::neurun::graph::operand::Index &ind)
- {
- return _objects.at(ind.asInt());
- }
-
-private:
- std::map<int, std::vector<std::shared_ptr<neurun::backend::operand::IObject>>> _objects;
-};
-
-} // namespace operand
-} // namespace internal
-
-#include <arm_compute/runtime/IFunction.h>
-
-namespace internal
-{
-namespace op
-{
-
-class Sequence
-{
-public:
- uint32_t size(void) const { return _functions.size(); }
-
-public:
- Sequence &append(std::unique_ptr<::arm_compute::IFunction> &&func)
- {
- _functions.emplace_back(std::move(func));
- return (*this);
- }
-
-public:
- ::arm_compute::IFunction &at(uint32_t n) const { return *(_functions.at(n)); }
-
-private:
- std::vector<std::unique_ptr<::arm_compute::IFunction>> _functions;
-};
-
-} // namespace op
-} // namespace internal
-
-namespace internal
-{
-
-class Plan
-{
-public:
- Plan(const std::shared_ptr<neurun::graph::Graph> &model) : _model(model)
- {
- // DO NOTHING
- }
-
-public:
- neurun::graph::Graph &model(void) { return *_model; }
- const neurun::graph::Graph &model(void) const { return *_model; }
-
-public:
- operand::Context &operands(void) { return _operands; }
- const operand::Context &operands(void) const { return _operands; }
-
-public:
- operand::Context &common_operands(void) { return _common_operands; }
- const operand::Context &common_operands(void) const { return _common_operands; }
-
-public:
- op::Sequence &operations(void) { return _ops; }
- const op::Sequence &operations(void) const { return _ops; }
-
-private:
- std::shared_ptr<neurun::graph::Graph> _model;
- operand::Context _operands;
- operand::Context _common_operands;
- op::Sequence _ops;
-};
-
-} // namespace internal
-
-#endif // __INTERNAL_PLAN_H__
namespace common
{
-TensorBuilder::TensorBuilder(::internal::Plan &plan) : _plan(plan)
+TensorBuilder::TensorBuilder(neurun::codegen::Plan &plan) : _plan(plan)
{
// DO NOTHING
}
#include <unordered_map>
#include "backend/ITensorBuilder.h"
+#include "codegen/Plan.h"
#include "internal/common/Tensor.h"
#include "internal/common/common.h"
-#include "internal/Plan.h"
namespace internal
{
class TensorBuilder : public neurun::backend::ITensorBuilder
{
public:
- TensorBuilder(::internal::Plan &plan);
+ TensorBuilder(neurun::codegen::Plan &plan);
virtual void mark(const ::neurun::graph::operand::Index &ind) override;
virtual void markFromCommon(const ::internal::tflite::op::Node &op, int32_t ind) override;
std::shared_ptr<::internal::common::Tensor> at(const ::neurun::graph::operand::Index &ind);
private:
- ::internal::Plan &_plan;
+ neurun::codegen::Plan &_plan;
std::unordered_set<int> _inds;
std::unordered_map<int, std::shared_ptr<::internal::common::Tensor>> _tensors;
};