MCPcopy Create free account
hub / github.com/apache/tvm / assert_op

Function assert_op

python/tvm/relax/op/base.py:581–617  ·  view source on GitHub ↗

Create a call to Relax's assert_op operation (`assert` is reserved in Python, so the name must be distinct). Parameters ---------- condition: Union[Expr, PrimExpr] The assertion condition. format_args: Optional[Union[Expr, List[Expr]]] Format arguments for

(
    condition: Expr | PrimExpr,
    format_args: Expr | list[Expr] | None = None,
    format: str | Expr = "",
)

Source from the content-addressed store, hash-verified

579
580
581def assert_op(
582 condition: Expr | PrimExpr,
583 format_args: Expr | list[Expr] | None = None,
584 format: str | Expr = "",
585) -> Expr:
586 """
587 Create a call to Relax's assert_op operation (`assert` is reserved in Python,
588 so the name must be distinct).
589
590 Parameters
591 ----------
592 condition: Union[Expr, PrimExpr]
593 The assertion condition.
594
595 format_args: Optional[Union[Expr, List[Expr]]]
596 Format arguments for the error message if the condition fails.
597
598 format: Union[str, Expr]
599 The format string or StringImm for the error message.
600
601 Returns
602 -------
603 result : Expr
604 A Call to the Relax assert operation.
605 """
606 if not isinstance(condition, Expr):
607 condition = tvm.relax.PrimValue(condition)
608
609 if format_args is None:
610 format_args = []
611 elif isinstance(format_args, Expr):
612 format_args = [format_args]
613
614 if isinstance(format, str):
615 format = StringImm(format)
616
617 return _ffi_api.assert_op(condition, format_args, format) # type: ignore
618
619
620def shape_of(expr: Expr) -> Expr:

Callers

nothing calls this directly

Calls 1

StringImmClass · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…