Skip to content

Commit

Permalink
[luci/export] Revise exportNodes function (Samsung#8220)
Browse files Browse the repository at this point in the history
This commit revise `exportNodes` function with following updates.
- Integrate `exportNode` into `exportNodes`
- Substitute `OperationExporter` with `OperationExporterRule`

ONE-DCO-1.0-Signed-off-by: Seok NamKoong <[email protected]>
  • Loading branch information
llFreetimell authored Dec 27, 2021
1 parent 9e4a799 commit 09e37a6
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 additions & 2 deletions compiler/luci/export/src/CircleOperationExporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#include "CircleOperationExporter.h"
#include "CircleOperationExporterRule.h"
#include "CircleExporterUtils.h"
#include "Check.h"

Expand All @@ -31,6 +32,9 @@

#include <flatbuffers/flexbuffers.h>

// TODO Remove unused code
// NOTE This is for better code diff visualization
#if 0
using namespace flatbuffers;
using namespace circle;

Expand Down Expand Up @@ -1724,17 +1728,48 @@ void exportNode(loco::Node *node, flatbuffers::FlatBufferBuilder &builder, Seria
}

} // namespace
#endif

namespace luci
{

void exportNodes(loco::Graph *g, FlatBufferBuilder &builder, SerializedModelData &md,
void exportNodes(loco::Graph *g, flatbuffers::FlatBufferBuilder &builder, SerializedModelData &md,
SerializedGraphData &gd)
{
uint32_t node_position = 0;
for (auto node : loco::postorder_traversal(loco::output_nodes(g)))
{
exportNode(node, builder, md, gd, node_position);
// exportNode(node, builder, md, gd, node_position);
ExportContext ctx{builder, md, gd};
OperationExporterRule exporter_rule{ctx};

auto circle_node = loco::must_cast<luci::CircleNode *>(node);
circle_node->accept(&exporter_rule);

const auto ops_size = gd._operators.size();

if (has_origin(circle_node) && ops_size != gd._operators.size())
{
const auto node_id = gd._operators.size() - 1;
for (auto source : get_origin(circle_node)->sources())
{
md._metadata.add_op_table(node_id, source->id());
}
}
if (has_execution_plan(circle_node))
{
// Add to node (in node_position) metadata vector with execution_plan information:
// order of execution, and offsets output tensors.
const auto execution_plan = get_execution_plan(circle_node);
std::vector<uint32_t> execution_plan_vector;
execution_plan_vector.push_back(execution_plan.order_in_plan());
for (auto offset : execution_plan.offsets())
{
execution_plan_vector.push_back(offset);
}
md._metadata.add_execution_plan_table(node_position, execution_plan_vector);
}

node_position++;
}
}
Expand Down

0 comments on commit 09e37a6

Please sign in to comment.