Skip to content

Commit

Permalink
review remarks
Browse files Browse the repository at this point in the history
  • Loading branch information
mbencer committed Dec 12, 2024
1 parent 577a67f commit 155497b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions runtime/onert/backend/cpu/BackendContext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include "backend/basic/BackendContextHelpers.h"
#include "backend/basic/TensorRegistry.h"

#include <misc/polymorphic_downcast.h>

namespace onert
{
namespace backend
Expand All @@ -46,8 +48,8 @@ FunctionMap BackendContext::genKernels()
tensor_builder->getSharedMemoryOperandIndexes());

// TODO: Change type of tensor_registry field to TensorRegistry
auto tensor_registry_concreted = dynamic_cast<basic::TensorRegistry *>(tensor_registry.get());
assert(tensor_registry_concreted);
auto tensor_registry_concreted =
nnfw::misc::polymorphic_downcast<basic::TensorRegistry *>(tensor_registry.get());
basic::initSharedMemoryConsts(graph()->operands(), external_operands(), tensor_registry_concreted,
tensor_builder->getSharedMemoryOperandIndexes());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,21 +178,21 @@ void planTensors(const std::shared_ptr<T_TensorBuilder> &tensor_builder, const i
}

template <typename T_TensorBuilder>
ir::OperandIndexSequence register_source_memory_tensors(
util::Set<ir::OperandIndex> register_source_memory_tensors(
const std::shared_ptr<T_TensorBuilder> &tensor_builder, const ir::Graph &graph,
const util::Set<ir::OperandIndex> &external_operands,
const ir::OperandIndexMap<ir::OperandIndex> &shared_memory_operand_idx)
{
// process source tensors that share memory at first
ir::OperandIndexSequence registered_source_ind;
util::Set<ir::OperandIndex> registered_source_ind;
for (const auto &[_, source_ind] : shared_memory_operand_idx)
{
if (external_operands.contains(source_ind))
continue;
if (tensor_builder->isRegistered(source_ind)) // some tensors can have the same source
continue;
tensor_builder->registerTensorInfo(source_ind, graph.operands().at(source_ind).info());
registered_source_ind.append(source_ind);
registered_source_ind.add(source_ind);
}
return registered_source_ind;
}
Expand Down

0 comments on commit 155497b

Please sign in to comment.