From 04d79e609975166ba2be5c380c35760aa2f908f6 Mon Sep 17 00:00:00 2001 From: Jihoon Lee Date: Tue, 9 Nov 2021 14:44:14 +0900 Subject: [PATCH] [Tp] rename externallyAllocated -> placeholder This patch renames externallyAllocated -> placeholder **Self evaluation:** 1. Build test: [X]Passed [ ]Failed [ ]Skipped 2. Run test: [X]Passed [ ]Failed [ ]Skipped Signed-off-by: Jihoon Lee --- nntrainer/tensor/manager.cpp | 20 ++++---------------- nntrainer/tensor/tensor_pool.cpp | 14 ++------------ nntrainer/tensor/tensor_pool.h | 16 ---------------- 3 files changed, 6 insertions(+), 44 deletions(-) diff --git a/nntrainer/tensor/manager.cpp b/nntrainer/tensor/manager.cpp index 80f718b..c940a84 100644 --- a/nntrainer/tensor/manager.cpp +++ b/nntrainer/tensor/manager.cpp @@ -453,12 +453,8 @@ Manager::requestInputs(const GraphNode &node, Tensor::Initializer::ZEROS /// tensor initializer ); } else { - /** requesting externally allocated tensor for input */ - var = tensor_pool.requestExternallyAllocateTensor( - dim, /// tensor dim - var_name, /// name - Tensor::Initializer::NONE /// tensor initializer - ); + /** requesting placeholder for input */ + var = tensor_pool.placeholder(var_name, dim); #ifdef ENABLE_TEST grad = tensor_pool.requestTensor( @@ -468,11 +464,7 @@ Manager::requestInputs(const GraphNode &node, Tensor::Initializer::ZEROS /// tensor initializer ); #else - grad = tensor_pool.requestExternallyAllocateTensor( - dim, /// tensor dim - var_name + Var_Grad::grad_suffix, /// name - Tensor::Initializer::ZEROS /// tensor initializer - ); + grad = tensor_pool.placeholder(var_name + Var_Grad::grad_suffix, dim); #endif } @@ -562,11 +554,7 @@ Manager::requestOutputs(const GraphNode &node, ); } else { /** requesting externally allocated tensor for label */ - grad = tensor_pool.requestExternallyAllocateTensor( - dim, /// tensor dim - var_name + Var_Grad::grad_suffix, /// name - Tensor::Initializer::ZEROS /// tensor initializer - ); + grad = tensor_pool.placeholder(var_name + Var_Grad::grad_suffix, dim); } } diff --git a/nntrainer/tensor/tensor_pool.cpp b/nntrainer/tensor/tensor_pool.cpp index b7be963..2202762 100644 --- a/nntrainer/tensor/tensor_pool.cpp +++ b/nntrainer/tensor/tensor_pool.cpp @@ -44,14 +44,9 @@ Tensor *TensorPool::requestTensor(const TensorDim &dim, * @brief Request tensor with the given spec * * @note returns empty tensor which will be filled when allocate is called. - * @note we assume that the caller checks if the exec_order and lifespan are - * compatible. */ -Tensor * -TensorPool::requestExternallyAllocateTensor(const TensorDim &dim, - const std::string &name, - const Tensor::Initializer &init) { - return requestTensor(dim, {}, TensorLifespan::UNMANAGED, name, init); +Tensor *TensorPool::placeholder(const std::string &name, const TensorDim &dim) { + return requestTensor(dim, {}, TensorLifespan::UNMANAGED, name); } /** @@ -297,11 +292,6 @@ void TensorPool::fillPlaceholder(const std::string &name, const Tensor &t) { syncDependents(spec); } -Tensor *TensorPool::placeholder(const std::string &name, const TensorDim &dim) { - /// @todo rename requestExternallyAllocateTensor -> placeholder - return requestExternallyAllocateTensor(dim, name); -} - Tensor *TensorPool::request(const std::string &name, const TensorDim &dim, const std::vector &exec_order, TensorLifespan lifespan, diff --git a/nntrainer/tensor/tensor_pool.h b/nntrainer/tensor/tensor_pool.h index 3ec0866..60dad85 100644 --- a/nntrainer/tensor/tensor_pool.h +++ b/nntrainer/tensor/tensor_pool.h @@ -67,22 +67,6 @@ public: const Tensor::Initializer &init = Tensor::Initializer::NONE); /** - * @brief Request tensor with the given name which will be allocated - * externally - * - * @param dim Tensor dimensions - * @param name Name of this tensor - * @param init Initializer of the tensor - * - * @return ptr to the created tensor - * - * @note returns empty tensor which must be filled by the caller before use. - */ - Tensor *requestExternallyAllocateTensor( - const TensorDim &dim, const std::string &name, - const Tensor::Initializer &init = Tensor::Initializer::NONE); - - /** * @brief Request tensor which has been already requested with the given * spec * -- 2.7.4