This commit applies finding frontend layout of operand.
Signed-off-by: jiseob.jang <jiseob.jang@samsung.com>
else
{
const auto info = obj.info();
- const auto layout = lower_info->def_factors().getOnlyElement().layout();
- // TODO Support NCHW frontend
- tensor_builder->registerTensorInfo(ind, info, model::Layout::NHWC, layout);
+ // NOTE This assumes an operand can have one layout, and only PermutateNode can have
+ // different layouts for input and output
+ const auto &def = *obj.getDef().list().cbegin();
+ auto frontend_layout =
+ graph.subgraphs().at(graph.subgraphs().getOperation(def)).getLayout();
+ if (frontend_layout == model::Layout::UNKNOWN)
+ {
+ const auto &use = *obj.getUses().list().cbegin();
+ frontend_layout = graph.subgraphs().at(graph.subgraphs().getOperation(use)).getLayout();
+ }
+ const auto backend_layout = lower_info->def_factors().getOnlyElement().layout();
+ tensor_builder->registerTensorInfo(ind, info, frontend_layout, backend_layout);
// To make this never be deallocated, this is a workaround to use static memory planner
tensor_builder->notifyFirstUse(ind);
}
else
{
const auto info = obj.info();
- const auto layout = lower_info->def_factors().getOnlyElement().layout();
- // TODO Support NCHW frontend
- tensor_builder->registerTensorInfo(ind, info, model::Layout::NHWC, layout);
+
+ // NOTE This assumes an operand can have one layout, and only PermutateNode can have
+ // different layouts for input and output
+ const auto &def = *obj.getDef().list().cbegin();
+ auto frontend_layout = _subgraphs->at(_subgraphs->getOperation(def)).getLayout();
+ if (frontend_layout == model::Layout::UNKNOWN)
+ {
+ const auto &use = *obj.getUses().list().cbegin();
+ frontend_layout = _subgraphs->at(_subgraphs->getOperation(use)).getLayout();
+ }
+ const auto backend_layout = lower_info->def_factors().getOnlyElement().layout();
+ tensor_builder->registerTensorInfo(ind, info, frontend_layout, backend_layout);
}
tensor_builder_map[ind] = tensor_builder;
}
// Find PermuteNode information
- const auto input_layout =
- _graph.getLowerInfo(operand_index)->def_factors().getOnlyElement().layout();
- const auto output_layout = factor.layout();
auto input_backend = _graph.getLowerInfo(operand_index)->def_factors().getOnlyElement().backend();
auto output_backend = factor.backend();
// NOTE PermuteNode may not have specific layout because the layout of input and output may be
// different.
- const auto permute_node_layout =
- input_layout == output_layout ? output_layout : model::Layout::UNKNOWN;
+ const auto permute_node_layout = model::Layout::UNKNOWN;
const auto permute_node_backend = backend::BackendManager::instance().getDefault();
const operand::PermuteFactor permute_node_factor{permute_node_backend, permute_node_layout};