From 787337910cc385174ed71c7d23602dab08e69cad Mon Sep 17 00:00:00 2001 From: Sergei Barannikov/AI Tools Lab /SRR/Engineer/Samsung Electronics Date: Wed, 4 Dec 2019 12:53:41 +0300 Subject: [PATCH] [neurun] Remove no longer used template parameter (#9384) Remove template parameter `T_Object` of TensorBuilder, TensorManager, MemoryManager classes. Signed-off-by: Sergei Barannikov --- runtime/neurun/backend/acl_cl/TensorBuilder.h | 4 +- runtime/neurun/backend/acl_cl/TensorManager.h | 13 +-- .../backend/acl_common/AclLinearMemoryManager.h | 8 +- .../neurun/backend/acl_common/AclMemoryManager.h | 2 +- .../neurun/backend/acl_common/AclTensorManager.h | 85 ++++++++--------- .../neurun/backend/acl_common/TemplTensorBuilder.h | 104 ++++++++++----------- runtime/neurun/backend/acl_neon/TensorBuilder.h | 5 +- runtime/neurun/backend/acl_neon/TensorManager.h | 16 ++-- 8 files changed, 110 insertions(+), 127 deletions(-) diff --git a/runtime/neurun/backend/acl_cl/TensorBuilder.h b/runtime/neurun/backend/acl_cl/TensorBuilder.h index 8ce69a6..3b1a9f2 100644 --- a/runtime/neurun/backend/acl_cl/TensorBuilder.h +++ b/runtime/neurun/backend/acl_cl/TensorBuilder.h @@ -31,9 +31,7 @@ namespace acl_cl { using TensorBuilder = - ::neurun::backend::acl_common::TemplTensorBuilder<::neurun::backend::acl_cl::operand::ICLTensor, - operand::CLTensor, operand::CLSubTensor, - operand::Object>; + acl_common::TemplTensorBuilder; } // namespace acl_cl } // namespace backend diff --git a/runtime/neurun/backend/acl_cl/TensorManager.h b/runtime/neurun/backend/acl_cl/TensorManager.h index 10145bb..e4ec338 100644 --- a/runtime/neurun/backend/acl_cl/TensorManager.h +++ b/runtime/neurun/backend/acl_cl/TensorManager.h @@ -42,23 +42,20 @@ namespace acl_cl { using MemoryManager = - ::neurun::backend::acl_common::AclMemoryManager; + acl_common::AclMemoryManager; -using LinearMemoryManager = ::neurun::backend::acl_common::AclLinearMemoryManager< - operand::ICLTensor, operand::CLTensor, operand::CLSubTensor, operand::Object, +using LinearMemoryManager = acl_common::AclLinearMemoryManager< + operand::ICLTensor, operand::CLTensor, operand::CLSubTensor, ::arm_compute::MemoryManagerOnDemand, ::arm_compute::PoolManager, ::arm_compute::BlobLifetimeManager, ::arm_compute::CLBufferAllocator, ::arm_compute::CLMemoryGroup>; -using InternalBufferManager = ::neurun::backend::acl_common::AclInternalBufferManager< +using InternalBufferManager = acl_common::AclInternalBufferManager< ::arm_compute::MemoryManagerOnDemand, ::arm_compute::PoolManager, ::arm_compute::BlobLifetimeManager, ::arm_compute::CLBufferAllocator>; using TensorManager = - ::neurun::backend::acl_common::AclTensorManager<::neurun::backend::acl_cl::operand::ICLTensor, - operand::CLTensor, operand::CLSubTensor, - operand::Object>; + acl_common::AclTensorManager; TensorManager *createTensorManager() { diff --git a/runtime/neurun/backend/acl_common/AclLinearMemoryManager.h b/runtime/neurun/backend/acl_common/AclLinearMemoryManager.h index 793c7b2..3ef9358 100644 --- a/runtime/neurun/backend/acl_common/AclLinearMemoryManager.h +++ b/runtime/neurun/backend/acl_common/AclLinearMemoryManager.h @@ -46,10 +46,10 @@ namespace backend namespace acl_common { -template -class AclLinearMemoryManager : public AclMemoryManager +template +class AclLinearMemoryManager : public AclMemoryManager { public: AclLinearMemoryManager() diff --git a/runtime/neurun/backend/acl_common/AclMemoryManager.h b/runtime/neurun/backend/acl_common/AclMemoryManager.h index 39662fc..910a990 100644 --- a/runtime/neurun/backend/acl_common/AclMemoryManager.h +++ b/runtime/neurun/backend/acl_common/AclMemoryManager.h @@ -33,7 +33,7 @@ namespace backend namespace acl_common { -template +template class AclMemoryManager : public backend::IMemoryManager { public: diff --git a/runtime/neurun/backend/acl_common/AclTensorManager.h b/runtime/neurun/backend/acl_common/AclTensorManager.h index 3849f18..ca77046 100644 --- a/runtime/neurun/backend/acl_common/AclTensorManager.h +++ b/runtime/neurun/backend/acl_common/AclTensorManager.h @@ -31,11 +31,11 @@ namespace backend namespace acl_common { -template +template class AclTensorManager : public backend::ITensorManager { public: - using T_AclMemoryManager = AclMemoryManager; + using T_AclMemoryManager = AclMemoryManager; AclTensorManager(T_AclMemoryManager *const_mgr, T_AclMemoryManager *nonconst_mgr, IInternalBufferManager *inter_mgr); @@ -95,8 +95,8 @@ namespace backend namespace acl_common { -template -AclTensorManager::AclTensorManager( +template +AclTensorManager::AclTensorManager( T_AclMemoryManager *const_mgr, T_AclMemoryManager *nonconst_mgr, IInternalBufferManager *inter_mgr) : _const_mgr{const_mgr}, _nonconst_mgr{nonconst_mgr}, _inter_mgr{inter_mgr} @@ -104,46 +104,44 @@ AclTensorManager::AclTensorManager( // DO NOTHING } -template -void AclTensorManager::allocateConsts(void) +template +void AclTensorManager::allocateConsts(void) { _const_mgr->allocate(); } -template -void AclTensorManager::allocateNonconsts(void) +template +void AclTensorManager::allocateNonconsts(void) { _nonconst_mgr->allocate(); } -template -void AclTensorManager::deallocateConsts(void) +template +void AclTensorManager::deallocateConsts(void) { _const_mgr->deallocate(); } -template -void AclTensorManager::deallocateNonconsts(void) +template +void AclTensorManager::deallocateNonconsts(void) { _nonconst_mgr->deallocate(); } -template -void AclTensorManager::allocateInternalBufferManager( - void) +template +void AclTensorManager::allocateInternalBufferManager(void) { _inter_mgr->allocate(); } -template -void AclTensorManager::deallocateInternalBufferManager( - void) +template +void AclTensorManager::deallocateInternalBufferManager(void) { _inter_mgr->deallocate(); } -template -void AclTensorManager::buildTensor( +template +void AclTensorManager::buildTensor( const model::OperandIndex &ind, const ::arm_compute::TensorInfo &info, size_t rank, bool as_const, size_t num_uses) { @@ -160,8 +158,8 @@ void AclTensorManager::buildTensor( } } -template -void AclTensorManager::buildSubtensor( +template +void AclTensorManager::buildSubtensor( const model::OperandIndex &parent, const model::OperandIndex &child, const ::arm_compute::TensorShape &shape, const ::arm_compute::Coordinates &coordinates, size_t rank, bool extent_parent) @@ -173,9 +171,8 @@ void AclTensorManager::buildSubtenso _ind_to_mgr.insert({child, *_nonconst_mgr}); } -template -std::shared_ptr -AclTensorManager::findTensorAsParent( +template +std::shared_ptr AclTensorManager::findTensorAsParent( const model::OperandIndex &ind) { @@ -197,25 +194,25 @@ AclTensorManager::findTensorAsParent } } -template -void AclTensorManager::startLifetime( +template +void AclTensorManager::startLifetime( const model::OperandIndex &ind) { assert(_ind_to_mgr.find(ind) != _ind_to_mgr.end()); _ind_to_mgr.at(ind).startLifetime(ind); } -template -void AclTensorManager::finishLifetime( +template +void AclTensorManager::finishLifetime( const model::OperandIndex &ind) { assert(_ind_to_mgr.find(ind) != _ind_to_mgr.end()); _ind_to_mgr.at(ind).finishLifetime(ind); } -template -std::shared_ptr AclTensorManager::at( - const ::neurun::model::OperandIndex &ind) +template +std::shared_ptr +AclTensorManager::at(const ::neurun::model::OperandIndex &ind) { assert(_ind_to_mgr.find(ind) != _ind_to_mgr.end()); @@ -230,36 +227,36 @@ std::shared_ptr AclTensorManager +template model::OperandIndexMap> & -AclTensorManager::constTensors(void) +AclTensorManager::constTensors(void) { return _const_mgr->tensors(); } -template +template model::OperandIndexMap> & -AclTensorManager::nonconstTensors(void) +AclTensorManager::nonconstTensors(void) { return _nonconst_mgr->tensors(); } -template +template model::OperandIndexMap> & -AclTensorManager::nonconstSubtensors(void) +AclTensorManager::nonconstSubtensors(void) { return _nonconst_mgr->subtensors(); } -template +template std::shared_ptr<::arm_compute::IMemoryManager> -AclTensorManager::internal_buffer_manager(void) +AclTensorManager::internal_buffer_manager(void) { return _inter_mgr->internal_buffer_manager(); } -template -void AclTensorManager::iterate( +template +void AclTensorManager::iterate( const std::function &fn) { for (auto it : _nonconst_mgr->tensors()) @@ -272,8 +269,8 @@ void AclTensorManager::iterate( fn(it.first); } -template -void AclTensorManager::tryDeallocConstants(void) +template +void AclTensorManager::tryDeallocConstants(void) { auto &tensors = _const_mgr->tensors(); diff --git a/runtime/neurun/backend/acl_common/TemplTensorBuilder.h b/runtime/neurun/backend/acl_common/TemplTensorBuilder.h index c770b52..2b9102a 100644 --- a/runtime/neurun/backend/acl_common/TemplTensorBuilder.h +++ b/runtime/neurun/backend/acl_common/TemplTensorBuilder.h @@ -40,11 +40,11 @@ enum class UsesType LAST }; -template +template class TemplTensorBuilder : public ITensorBuilder { public: - using T_AclTensorManager = AclTensorManager; + using T_AclTensorManager = AclTensorManager; TemplTensorBuilder(T_AclTensorManager *tensor_mgr); @@ -151,8 +151,8 @@ namespace backend namespace acl_common { -template -TemplTensorBuilder::TemplTensorBuilder( +template +TemplTensorBuilder::TemplTensorBuilder( T_AclTensorManager *tensor_mgr) : _tensor_mgr{tensor_mgr}, _executor_str(util::getConfigString(util::config::EXECUTOR)), _first_uses_num(0) @@ -160,8 +160,8 @@ TemplTensorBuilder::TemplTensorBuild assert(_tensor_mgr); } -template -void TemplTensorBuilder::registerTensorInfo( +template +void TemplTensorBuilder::registerTensorInfo( const model::OperandIndex &ind, const model::OperandInfo &info, model::Layout backend_layout, bool as_const) { @@ -178,8 +178,8 @@ void TemplTensorBuilder::registerTen _first_uses_visit[ind] = false; } -template -void TemplTensorBuilder::registerSubTensorInfo( +template +void TemplTensorBuilder::registerSubTensorInfo( const model::OperandIndex &ind, const compiler::SubTensorInfo &info) { assert(_tensor_mgr->constTensors().size() == 0); @@ -202,87 +202,85 @@ void TemplTensorBuilder::registerSub _parent_uses[parent_ind]++; } -template -void TemplTensorBuilder::notifyFirstUse( +template +void TemplTensorBuilder::notifyFirstUse( const model::OperandIndex &ind) { _first_uses_num++; _uses_queue.emplace(UsesType::FIRST, ind); } -template -void TemplTensorBuilder::notifyLastUse( +template +void TemplTensorBuilder::notifyLastUse( const model::OperandIndex &ind) { _uses_queue.emplace(UsesType::LAST, ind); } -template -bool TemplTensorBuilder::isRegistered( +template +bool TemplTensorBuilder::isRegistered( const model::OperandIndex &ind) const { return _tensor_info_map.find(ind) != _tensor_info_map.end() || _subtensor_info_map.find(ind) != _subtensor_info_map.end(); } -template -void TemplTensorBuilder::prepare(void) +template +void TemplTensorBuilder::prepare(void) { buildTensors(); buildSubtensors(); } -template -void TemplTensorBuilder::allocateConsts(void) +template +void TemplTensorBuilder::allocateConsts(void) { assert(_constants.size() == _tensor_mgr->constTensors().size()); _tensor_mgr->allocateConsts(); } -template -void TemplTensorBuilder::allocateNonconsts(void) +template +void TemplTensorBuilder::allocateNonconsts(void) { assert(_tensor_info_map.size() == _tensor_mgr->nonconstTensors().size() + _constants.size()); _tensor_mgr->allocateNonconsts(); } -template -void TemplTensorBuilder::postFunctionPrepare(void) +template +void TemplTensorBuilder::postFunctionPrepare(void) { _tensor_mgr->tryDeallocConstants(); } -template -void TemplTensorBuilder::finalize(void) +template +void TemplTensorBuilder::finalize(void) { validate(); _tensor_mgr->allocateInternalBufferManager(); } -template +template std::shared_ptr<::neurun::backend::operand::ITensor> -TemplTensorBuilder::tensorAt( - const model::OperandIndex &ind) +TemplTensorBuilder::tensorAt(const model::OperandIndex &ind) { return _tensor_mgr->at(ind); } -template -void TemplTensorBuilder::iterate( - const IterateFunction &fn) +template +void TemplTensorBuilder::iterate(const IterateFunction &fn) { _tensor_mgr->iterate(fn); } -template -std::shared_ptr TemplTensorBuilder::at( - const ::neurun::model::OperandIndex &ind) +template +std::shared_ptr +TemplTensorBuilder::at(const ::neurun::model::OperandIndex &ind) { return _tensor_mgr->at(ind); } -template -bool TemplTensorBuilder::isSubTensorOf( +template +bool TemplTensorBuilder::isSubTensorOf( const model::OperandIndex &parent, const model::OperandIndex &child) { if (_subtensor_info_map.find(child) == _subtensor_info_map.end()) @@ -304,22 +302,22 @@ bool TemplTensorBuilder::isSubTensor return true; } -template -void TemplTensorBuilder::dimCorrection( +template +void TemplTensorBuilder::dimCorrection( const model::OperandIndex &index, bool apply_dim_correction) { _apply_dim_correction_map[index] = apply_dim_correction; } -template +template std::unique_ptr -TemplTensorBuilder::releaseTensorManager(void) +TemplTensorBuilder::releaseTensorManager(void) { return std::move(_tensor_mgr); } -template -void TemplTensorBuilder::buildTensors(void) +template +void TemplTensorBuilder::buildTensors(void) { assert(_tensor_mgr->constTensors().size() == 0); assert(_tensor_mgr->nonconstTensors().size() == 0); @@ -338,8 +336,8 @@ void TemplTensorBuilder::buildTensor } } -template -void TemplTensorBuilder::buildSubtensors(void) +template +void TemplTensorBuilder::buildSubtensors(void) { // TODO Handle SubTensor(subsumption) // Currently this TemplTensorBuilder does not have subsumption info yet @@ -406,9 +404,8 @@ void TemplTensorBuilder::buildSubten } } -template -void TemplTensorBuilder::preVisit( - const model::Operation &node) +template +void TemplTensorBuilder::preVisit(const model::Operation &node) { // For now others executor doesn't need this step if (_executor_str != "Linear") @@ -481,9 +478,8 @@ void TemplTensorBuilder::preVisit( } } -template -void TemplTensorBuilder::postVisit( - const model::Operation &node) +template +void TemplTensorBuilder::postVisit(const model::Operation &node) { // For now others executor doesn't need this step if (_executor_str != "Linear") @@ -558,8 +554,8 @@ void TemplTensorBuilder::postVisit( } } -template -void TemplTensorBuilder::validate(void) +template +void TemplTensorBuilder::validate(void) { // For now others executor doesn't need this step if (_executor_str != "Linear") @@ -598,9 +594,9 @@ void TemplTensorBuilder::validate(vo [](std::pair it) { return it.second == 0; })); } -template -model::OperandIndex TemplTensorBuilder::findRootParent( - model::OperandIndex ind) +template +model::OperandIndex +TemplTensorBuilder::findRootParent(model::OperandIndex ind) { if (_subtensor_info_map.find(ind) == _subtensor_info_map.end()) return ind; diff --git a/runtime/neurun/backend/acl_neon/TensorBuilder.h b/runtime/neurun/backend/acl_neon/TensorBuilder.h index 3da30df..26b4248 100644 --- a/runtime/neurun/backend/acl_neon/TensorBuilder.h +++ b/runtime/neurun/backend/acl_neon/TensorBuilder.h @@ -31,9 +31,8 @@ namespace backend namespace acl_neon { -using TensorBuilder = ::neurun::backend::acl_common::TemplTensorBuilder< - ::neurun::backend::acl_neon::operand::INETensor, operand::NETensor, operand::NESubTensor, - ::neurun::backend::operand::Object>; +using TensorBuilder = + acl_common::TemplTensorBuilder; } // namespace acl_neon } // namespace backend diff --git a/runtime/neurun/backend/acl_neon/TensorManager.h b/runtime/neurun/backend/acl_neon/TensorManager.h index 3d5c40b..f8e30f8 100644 --- a/runtime/neurun/backend/acl_neon/TensorManager.h +++ b/runtime/neurun/backend/acl_neon/TensorManager.h @@ -42,23 +42,19 @@ namespace acl_neon { using MemoryManager = - ::neurun::backend::acl_common::AclMemoryManager; + acl_common::AclMemoryManager; -using LinearMemoryManager = ::neurun::backend::acl_common::AclLinearMemoryManager< - operand::INETensor, operand::NETensor, operand::NESubTensor, ::neurun::backend::operand::Object, +using LinearMemoryManager = acl_common::AclLinearMemoryManager< + operand::INETensor, operand::NETensor, operand::NESubTensor, ::arm_compute::MemoryManagerOnDemand, ::arm_compute::PoolManager, ::arm_compute::OffsetLifetimeManager, ::arm_compute::Allocator, ::arm_compute::MemoryGroup>; -using InternalBufferManager = ::neurun::backend::acl_common::AclInternalBufferManager< +using InternalBufferManager = acl_common::AclInternalBufferManager< ::arm_compute::MemoryManagerOnDemand, ::arm_compute::PoolManager, ::arm_compute::OffsetLifetimeManager, ::arm_compute::Allocator>; -using TensorManager = - ::neurun::backend::acl_common::AclTensorManager<::neurun::backend::acl_neon::operand::INETensor, - operand::NETensor, operand::NESubTensor, - ::neurun::backend::operand::Object>; +using TensorManager = acl_common::AclTensorManager; TensorManager *createTensorManager() { -- 2.7.4