Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

[1.x] Backport Faster pointwise fusion graph pass (#19269) #19413

Merged
merged 4 commits into from
Nov 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 4 additions & 12 deletions src/executor/exec_pass.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,22 +222,14 @@ Graph DetectInplaceAddTo(Graph g);
Graph EliminateCommonExpr(Graph && g);

/*!
* \brief Fuse pointwise operations in the forward pass.
* \brief Fuse pointwise operations in the graph.
*
* \param g input graph (needs to be entire graph, not just forward part)
* \param num_forward_outputs number of outputs in the graph produced by the forward pass
*
* \return graph with fused pointwise operations in the forward pass
* \return copy of the graph with fused pointwise operations
*/
Graph FusePointwiseForward(Graph&& g);

/*!
* \brief Fuse pointwise operations in the backward pass.
*
* \param g input graph (needs to be entire graph, not just forward part)
*
* \return graph with fused pointwise operations in the backward pass
*/
Graph FusePointwiseBackward(Graph&& g);
Graph FusePointwise(const Graph& g, const size_t num_forward_outputs);

/*!
* \brief Issue a one-time warning that fusion is not possible for this platform or build.
Expand Down
5 changes: 1 addition & 4 deletions src/executor/graph_executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1009,10 +1009,7 @@ Graph GraphExecutor::InitGraph(nnvm::Symbol symbol,
common::CopyGraph(&unoptimized_graph, g, false);

if (common::CheckForInputNameDuplicates(unoptimized_graph.indexed_graph())) {
g.attrs["num_forward_outputs"] = std::make_shared<nnvm::any>(num_forward_outputs_);
g = FusePointwiseForward(std::move(g));
g.attrs["num_forward_outputs"] = std::make_shared<nnvm::any>(num_forward_outputs_);
g = FusePointwiseBackward(std::move(g));
g = exec::FusePointwise(std::move(g), num_forward_outputs_);
// Check the topological order of inputs
const auto &original_inputs = unoptimized_graph.indexed_graph().input_nodes();
const auto &new_inputs = g.indexed_graph().input_nodes();
Expand Down
Loading