Skip to content

Commit

Permalink
[docs] update example code in docs (Samsung#5151)
Browse files Browse the repository at this point in the history
- Update cpu's KernelGenerator example code as it is outdated

ONE-DCO-1.0-Signed-off-by: dayo09 <[email protected]>
  • Loading branch information
dayo09 authored Nov 25, 2020
1 parent 8cddfda commit 518a70d
Showing 1 changed file with 11 additions and 22 deletions.
33 changes: 11 additions & 22 deletions docs/howto/how-to-introduce-a-new-operation-into-runtime.md
Original file line number Diff line number Diff line change
Expand Up @@ -419,32 +419,21 @@ void visit(const ir::operation::Select &) override;
```cpp
void KernelGenerator::visit(const ir::operation::Select &node)
{
const auto output_index{node.getOutputs().at(ir::operation::Select::Output::OUTPUT)};
const auto cond_index{node.getInputs().at(ir::operation::Select::Input::COND)};
const auto input1_index{node.getInputs().at(ir::operation::Select::Input::INPUT1)};
const auto input2_index{node.getInputs().at(ir::operation::Select::Input::INPUT2)};
const auto output_backend_descr = ::onert::backend::cpu::kernel::getTensorDescriptor(
_ctx.at(output_index), _current_op_seq_layout);
const auto cond_backend_descr = ::onert::backend::cpu::kernel::getTensorDescriptor(
_ctx.at(cond_index), _current_op_seq_layout);
const auto input1_backend_descr = ::onert::backend::cpu::kernel::getTensorDescriptor(
_ctx.at(input1_index), _current_op_seq_layout);
const auto input2_backend_descr = ::onert::backend::cpu::kernel::getTensorDescriptor(
_ctx.at(input2_index), _current_op_seq_layout);
const auto output_index{node.getOutputs().at(0)};
const auto condition_index{node.getInputs().at(ir::operation::Select::Input::CONDITION)};
const auto true_index{node.getInputs().at(ir::operation::Select::Input::INPUT_TRUE)};
const auto false_index{node.getInputs().at(ir::operation::Select::Input::INPUT_FALSE)};
auto output_alloc = _tensor_builder->at(output_index).get();
auto cond_alloc = _tensor_builder->at(cond_index).get();
auto input1_alloc = _tensor_builder->at(input1_index).get();
auto input2_alloc = _tensor_builder->at(input2_index).get();
auto output_tensor = _tensor_reg->getPortableTensor(output_index);
auto condition_tensor = _tensor_reg->getPortableTensor(condition_index);
auto true_tensor = _tensor_reg->getPortableTensor(true_index);
auto false_tensor = _tensor_reg->getPortableTensor(false_index);
auto fn = std::make_unique<::onert::backend::cpu::kernel::SelectLayer>();
auto fn = std::make_unique<ops::SelectLayer>();
fn->configure(cond_alloc->buffer(), cond_backend_descr, input1_alloc->buffer(),
input1_backend_descr, input2_alloc->buffer(), input2_backend_descr,
output_alloc->buffer(), output_backend_descr);
fn->configure(condition_tensor, true_tensor, false_tensor, output_tensor);
_execution_builder->append(std::move(fn));
_return_fn = std::move(fn);
}
```

Expand Down

0 comments on commit 518a70d

Please sign in to comment.