capture_tensor
Applicable Products
All processors
Function Usage
Marks the tensor to be captured in a pattern graph. The captured tensors are saved in the call sequence and can be read later using match_result.get_captured_tensor(index).
Prototype
1 | capture_tensor(source: Union[TensorHolder, Node, NodeIo], index: Optional[int] = None) -> Pattern |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
source |
Input |
Source of the tensor to be captured. TensorHolder, Node, or NodeIo is supported. |
index |
Input |
Output index. When source is set to TensorHolder or Node, you can specify the output index. If the index is not specified, the default value 0 is used. When source is set to NodeIo, you do not need to pass the index. |
Returns
Type |
Description |
|---|---|
Pattern |
The current pattern. Chain calls are supported. |
Restrictions
None
Example
1 2 3 4 5 6 | from ge.passes import create_pattern # builder is the pattern graph constructor, and add and matmul are the nodes that have been constructed in the pattern graph. pat = create_pattern(builder.build_and_reset([add])) pat.capture_tensor(matmul) pat.capture_tensor(add) |
Parent topic: Pattern