Commit d21f0ad5 by Yida Wang Committed by Tianqi Chen

[RELAY]impose a max op limit to the op fusion pass (#4002)

* impose a max op limit to op fusion

* use cross platform data type
parent f1d2d46b
......@@ -77,6 +77,8 @@ namespace relay {
using common::LinkNode;
using common::LinkedList;
constexpr uint32_t kMaxFusedOps = 256;
/*!
* \brief Indexed data flow graph in forward direction.
* This is a temporary data structure used for operator fusion analysis.
......@@ -544,6 +546,11 @@ class GraphPartitioner {
}
return root;
}
/*!
* \brief The number of nodes belonging to this group
*/
uint32_t num_nodes{1};
};
/*!
* \brief Partition a graph.
......@@ -616,6 +623,9 @@ class GraphPartitioner {
* \param parent The parent group.
*/
void MergeFromTo(Group* child, Group* parent) {
// refuse the fusion if too many ops are fused together
if (parent->num_nodes > kMaxFusedOps) return;
parent->num_nodes += child->num_nodes;
child = child->FindRoot();
parent = parent->FindRoot();
if (child == parent) return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment