Stage

Applicability

Product

Supported or Not

Atlas A3 training products / Atlas A3 inference products

Atlas A2 training products / Atlas A2 inference products

Atlas 200I/500 A2 inference products

Atlas inference products

Atlas training products

Function Usage

Sets the execution phase of a custom pass.

Prototype

1
PassRegistrationData &Stage(const CustomPassStage stage)

Parameters

Parameter

Input/Output

Description

stage

Input

Execution phase of a custom pass.

  • kBeforeInferShape (default value): The custom pass is executed before InferShape at the framework entry.
  • kAfterInferShape: The custom pass is executed after InferShape.

    If the custom pass is executed after InferShape, the pass must ensure the shape continuity after graph modification. You can use the InferShapeAndType API to ensure the continuity.

    1
    2
    3
    4
    5
    6
    7
        // 1. Obtain the output description of an input node (node1).
        TensorDesc output_desc;
        node1.GetOutputDesc(0, output_desc);
        // 2. Update the input description of the current node (node 2).
        node2.UpdateInputDesc(0, output_desc);
        // 3. Deduce InferShape from the current node (node 2).
        operator2.InferShapeAndType();
    

    When the InferShape function is called, the input original shape is updated to the shape of the operator before InferShape, and the output shape of the operator is updated to the original shape of the operator after InferShape. Therefore, when setting InputDesc for an operator, you need to set the original shape.

  • kAfterAssignLogicStream: The custom pass is executed after the logical stream allocation phase. In this phase, only the pass allocated by the logical stream is received. (For details about how to register the execution function of the pass allocated by the custom logical stream, see CustomAllocateStreamPassFn.) A graph cannot be modified in this phase. If the graph is modified in other scenarios, an error is reported during pass verification.
  • kAfterBuiltinFusionPass: The custom pass can be executed after the built-in original graph fusion pass is executed.

Returns

Object of PassRegistrationData.

Constraints

None