CanFuse
Applicable Products
All processors
Header File/Library File
- Header file: #include <ge/fusion/graph_fuse_inspector_utils.h>
- Library file: libgraph_base.so
Function Usage
Determines whether the set of nodes to be fused can be fused. Determination conditions:
- The stream label indicates the branch strategy in the graph. If the stream labels of the input nodes are inconsistent, the user intent cannot be determined. Specifically, which label the fused node should inherit. Therefore, nodes with inconsistent stream labels are considered not eligible for fusion.
- If fusing the input node set into a single node introduces a cycle in the graph, the fusion is not allowed. Note that this check only applies to the scenario where the node set is fused into a single node; other scenarios (for example, replacing the input nodes with multiple nodes) are not covered by this cycle detection.
Prototype
1 | static bool CanFuse(const std::vector<GNode> &nodes_before_fuse, AscendString &failed_reason) |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
nodes_before_fuse |
Input |
List of nodes before fusion (all nodes in the list must be connected). |
failed_reason |
Output |
Reason of unsupported fusion. |
Returns
Parameter |
Type |
Description |
|---|---|---|
- |
bool |
|
You need to print the preceding reason. You can add the following code after the API:
1 2 3 4 5 6 7 | // Perform the CanFuse check. AscendString failed_reason; bool can_fuse = fusion::GraphFuseInspectorUtils::CanFuse(nodes_before_fuse, failed_reason); if (!can_fuse) { std::cerr << "[FuseNodes] CanFuse check failed: " << failed_reason.GetString() << std::endl; return false; } |
Restrictions
None
Parent topic: GraphFuseInspectorUtils