set_error_message

Applicable Products

All processors

Function Usage

Sets an error message for GE to record or report.

Prototype

1
set_error_message(message: str) -> None

Parameters

Parameter

Input/Output

Description

message

Input

Error message to be set, which is of the string type.

Returns

None

Restrictions

It can be used only in the current run call stack.

Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
from ge.passes import FusionBasePass, PassContext


class MyPass(FusionBasePass):
    def run(self, graph, context: PassContext):
        # self._ok is a custom graph verification method. If the verification fails, set the error message.
        if not self._ok(graph):
            context.set_error_message("my pass: invariant violated")
            return False
        return True