replacement

Applicable Products

All processors

Function Usage

Generates a replacement subgraph.

Prototype

1
replacement(self, match_result: MatchResult) -> Graph

The expression pattern can also be written as follows:

1
2
3
4
# Perform a simple replacement. There is no need to match details.
def replacement(self, inputs) -> TensorHolder: ...
# Read the captured tensor or node attributes.
def replacement(self, inputs, match_result) -> TensorHolder: ...

Parameters

Parameter

Input/Output

Description

self

Input

Pass instance object of the PatternFusionPass subclass. It is used to access the pass configuration and call methods.

inputs

Input

Replacement graph input set of the PatternInputs type, which is used to create the input tensor of the replacement graph.

match_result

Input

Pattern match result of the MatchResult type, which includes the matched node and edge information.

Returns

Type

Description

Graph

Returns the subgraph after replacement. The type is ge.graph.Graph.

Restrictions

The expression replacement(self, inputs) can return a TensorHolder or a non-empty TensorHolder list or tuple. The Python layer automatically constructs the replacement graph. The match_result parameter is required when the match details need to be read.