tvm.relay.scope_builder

The scope builder interface

class tvm.relay.scope_builder.ScopeBuilder

Scope builder class.

Enables users to build up a nested scope(let, if) expression easily.

Examples

else_scope()

Create a new else scope.

Returns:scope – The if scope.
Return type:WithScope
get()

Get the generated result.

Returns:value – The final result of the expression.
Return type:tvm.relay.expr.Expr
if_scope(cond)

Create a new if scope.

Parameters:cond (tvm.relay.expr.Expr) – The condition
Returns:scope – The if scope.
Return type:WithScope

Note

The user must follows with an else scope.

let(var, value)

Create a new let binding.

Parameters:
  • var (Union[Tuple[str, relay.Type], tvm.relay.Var]) – The variable or name of variable.
  • value (tvm.relay.Expr) – The value to be binded
ret(value)

Set the return value of this scope.

Parameters:value (tvm.relay.expr.Expr) – The return value.