This commit extracts Plan and related classes from arm_compute namespace into ::internal.
namespace acl_cl
{
-TensorBuilder::TensorBuilder(::internal::arm_compute::Plan &plan) : _plan(plan)
+TensorBuilder::TensorBuilder(::internal::Plan &plan) : _plan(plan)
{
// DO NOTHING
}
#define __NEURUN_BACKEND_ACL_CL_TENSOR_BUILDER_H__
#include "internal/ITensorBuilder.h"
-#include "internal/arm_compute.h"
+#include "internal/Plan.h"
#include <unordered_map>
#include <unordered_set>
class TensorBuilder : public ::internal::ITensorBuilder
{
public:
- TensorBuilder(::internal::arm_compute::Plan &plan);
+ TensorBuilder(::internal::Plan &plan);
virtual void mark(const ::internal::tflite::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 ::internal::tflite::operand::Index &ind);
private:
- ::internal::arm_compute::Plan &_plan;
+ ::internal::Plan &_plan;
std::unordered_set<int> _inds;
std::unordered_map<int, std::shared_ptr<::arm_compute::CLTensor>> _tensors;
};
namespace cpu
{
-TensorBuilder::TensorBuilder(::internal::arm_compute::Plan &plan) : _plan(plan)
+TensorBuilder::TensorBuilder(::internal::Plan &plan) : _plan(plan)
{
// DO NOTHING
}
#include "internal/ITensorBuilder.h"
#include "internal/cpu.h"
-#include "internal/arm_compute.h"
+#include "internal/Plan.h"
namespace neurun
{
class TensorBuilder : public ::internal::ITensorBuilder
{
public:
- TensorBuilder(::internal::arm_compute::Plan &plan);
+ TensorBuilder(::internal::Plan &plan);
virtual void mark(const ::internal::tflite::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 ::internal::tflite::operand::Index &ind);
private:
- ::internal::arm_compute::Plan &_plan;
+ ::internal::Plan &_plan;
std::unordered_set<int> _inds;
std::unordered_map<int, std::shared_ptr<::internal::cpu::Tensor>> _tensors;
};
class ExecutionBuilder final : public IExecutionBuilder
{
public:
- ExecutionBuilder(::internal::arm_compute::Plan &plan) : _plan{plan}
+ ExecutionBuilder(::internal::Plan &plan) : _plan{plan}
{
// DO NOTHING
}
}
private:
- ::internal::arm_compute::Plan &_plan;
+ ::internal::Plan &_plan;
};
class PlanBuilder final : public IPlanBuilder
{
public:
- PlanBuilder(::internal::arm_compute::Plan &plan) : _plan{plan}
+ PlanBuilder(::internal::Plan &plan) : _plan{plan}
{
// DO NOTHING
}
const std::map<int, ::arm_compute::TensorInfo> &tensor_info_ctx() { return _tensor_info_ctx; }
private:
- ::internal::arm_compute::Plan &_plan;
+ ::internal::Plan &_plan;
private:
std::map<int, ::arm_compute::TensorInfo> _tensor_info_ctx;
#define __COMPILATION_H__
#include "internal/Model.h"
-#include "internal/arm_compute.h"
+#include "internal/Plan.h"
struct ANeuralNetworksCompilation
{
public:
ANeuralNetworksCompilation(const std::shared_ptr<internal::tflite::Model> &model)
- : _plan{new internal::arm_compute::Plan{model}}
+ : _plan{new internal::Plan{model}}
{
// DO NOTHING
}
public:
- internal::arm_compute::Plan &plan(void) { return *_plan; }
+ internal::Plan &plan(void) { return *_plan; }
public:
- void publish(std::shared_ptr<const internal::arm_compute::Plan> &plan) { plan = _plan; }
+ void publish(std::shared_ptr<const internal::Plan> &plan) { plan = _plan; }
int finish();
private:
- std::shared_ptr<internal::arm_compute::Plan> _plan;
+ std::shared_ptr<internal::Plan> _plan;
};
#endif
#ifndef __EXECUTION_H__
#define __EXECUTION_H__
-#include "internal/arm_compute.h"
+#include "internal/Plan.h"
#include "internal/Source.h"
#include "internal/Sink.h"
struct ANeuralNetworksExecution
{
public:
- ANeuralNetworksExecution(const std::shared_ptr<const internal::arm_compute::Plan> &plan)
- : _plan{plan}
+ ANeuralNetworksExecution(const std::shared_ptr<const internal::Plan> &plan) : _plan{plan}
{
_sources.resize(_plan->model().inputs.size());
_sinks.resize(_plan->model().outputs.size());
}
public:
- const internal::arm_compute::Plan &plan(void) const { return *_plan; }
+ const internal::Plan &plan(void) const { return *_plan; }
private:
- std::shared_ptr<const internal::arm_compute::Plan> _plan;
+ std::shared_ptr<const internal::Plan> _plan;
public:
// TODO Use InputIndex instead of int
return ANEURALNETWORKS_UNEXPECTED_NULL;
}
- std::shared_ptr<const ::internal::arm_compute::Plan> plan;
+ std::shared_ptr<const ::internal::Plan> plan;
compilation->publish(plan);
namespace internal
{
-BackendManager::BackendManager(::internal::arm_compute::Plan &plan) : _plan(plan)
+BackendManager::BackendManager(::internal::Plan &plan) : _plan(plan)
{
const auto &operands = _plan.model().operands();
#include <memory>
-#include "internal/arm_compute.h"
+#include "internal/Plan.h"
#include "internal/IInitializerGenerator.h"
#include "internal/IStageGenerator.h"
#include "internal/ITensorBuilder.h"
class BackendManager
{
public:
- BackendManager(::internal::arm_compute::Plan &plan);
+ BackendManager(::internal::Plan &plan);
Backend get(const std::string &key);
std::shared_ptr<::internal::common::TensorBuilder> getCommonTensorBuilder();
private:
- ::internal::arm_compute::Plan &_plan;
+ ::internal::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 ::internal::tflite::operand::Index &id,
+ const std::shared_ptr<::internal::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 "internal/Model.h"
+#include "internal/IObject.h"
+
+#include <map>
+
+namespace internal
+{
+namespace operand
+{
+
+class Context
+{
+public:
+ Context &set(const ::internal::tflite::operand::Index &ind,
+ const std::shared_ptr<::internal::IObject> &object);
+
+public:
+ bool exist(const ::internal::tflite::operand::Index &ind) const
+ {
+ return _objects.find(ind.asInt()) != _objects.end();
+ }
+
+public:
+ const std::vector<std::shared_ptr<IObject>> &
+ at(const ::internal::tflite::operand::Index &ind) const
+ {
+ return _objects.at(ind.asInt());
+ }
+
+ std::vector<std::shared_ptr<IObject>> &at(const ::internal::tflite::operand::Index &ind)
+ {
+ return _objects.at(ind.asInt());
+ }
+
+private:
+ std::map<int, std::vector<std::shared_ptr<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<::internal::tflite::Model> &model) : _model(model)
+ {
+ // DO NOTHING
+ }
+
+public:
+ ::internal::tflite::Model &model(void) { return *_model; }
+ const ::internal::tflite::Model &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<::internal::tflite::Model> _model;
+ operand::Context _operands;
+ operand::Context _common_operands;
+ op::Sequence _ops;
+};
+
+} // namespace internal
+
+#endif // __INTERNAL_PLAN_H__
} // namespace operand
} // namepsace arm_compute
} // namespace internal
-
-namespace internal
-{
-namespace arm_compute
-{
-namespace operand
-{
-
-Context &Context::set(const ::internal::tflite::operand::Index &id,
- const std::shared_ptr<::internal::IObject> &object)
-{
- _objects[id.asInt()].emplace_back(object);
- return (*this);
-}
-
-} // namespace operand
-} // namepsace arm_compute
-} // namespace internal
} // namepsace arm_compute
} // namespace internal
-#include "internal/Model.h"
-
-#include <map>
-
-namespace internal
-{
-namespace arm_compute
-{
-namespace operand
-{
-
-class Context
-{
-public:
- Context &set(const ::internal::tflite::operand::Index &ind,
- const std::shared_ptr<::internal::IObject> &object);
-
-public:
- bool exist(const ::internal::tflite::operand::Index &ind) const
- {
- return _objects.find(ind.asInt()) != _objects.end();
- }
-
-public:
- const std::vector<std::shared_ptr<IObject>> &
- at(const ::internal::tflite::operand::Index &ind) const
- {
- return _objects.at(ind.asInt());
- }
-
- std::vector<std::shared_ptr<IObject>> &at(const ::internal::tflite::operand::Index &ind)
- {
- return _objects.at(ind.asInt());
- }
-
-private:
- std::map<int, std::vector<std::shared_ptr<IObject>>> _objects;
-};
-
-} // namespace operand
-} // namepsace arm_compute
-} // namespace internal
-
-#include <arm_compute/runtime/IFunction.h>
-
-namespace internal
-{
-namespace arm_compute
-{
-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
-} // namepsace arm_compute
-} // namespace internal
-
-namespace internal
-{
-namespace arm_compute
-{
-
-// TODO class Plan should not be in `::internal::arm_compute`, we should put it in `::internal`
-class Plan
-{
-public:
- Plan(const std::shared_ptr<::internal::tflite::Model> &model) : _model(model)
- {
- // DO NOTHING
- }
-
-public:
- ::internal::tflite::Model &model(void) { return *_model; }
- const ::internal::tflite::Model &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<::internal::tflite::Model> _model;
- operand::Context _operands;
- operand::Context _common_operands;
- op::Sequence _ops;
-};
-
-} // namepsace arm_compute
-} // namespace internal
-
#endif // __INTERNAL_ARM_COMPUTE_H__
namespace common
{
-TensorBuilder::TensorBuilder(::internal::arm_compute::Plan &plan) : _plan(plan)
+TensorBuilder::TensorBuilder(::internal::Plan &plan) : _plan(plan)
{
// DO NOTHING
}
#include "internal/ITensorBuilder.h"
#include "internal/common/Tensor.h"
#include "internal/common/common.h"
-#include "internal/arm_compute.h"
+#include "internal/Plan.h"
namespace internal
{
class TensorBuilder : public ::internal::ITensorBuilder
{
public:
- TensorBuilder(::internal::arm_compute::Plan &plan);
+ TensorBuilder(::internal::Plan &plan);
virtual void mark(const ::internal::tflite::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 ::internal::tflite::operand::Index &ind);
private:
- ::internal::arm_compute::Plan &_plan;
+ ::internal::Plan &_plan;
std::unordered_set<int> _inds;
std::unordered_map<int, std::shared_ptr<::internal::common::Tensor>> _tensors;
};