any
Description
Returns False if all arguments are false; True if one of the arguments is true.
This API is generally used as the conditional statement (cond) of the if_scope and elif_scope statements.
Prototype
any(*args)
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
*args |
Input |
Supports multiple arguments separated by commas (,). It supports the InputScalar, Scalar, Expr, bool, and immediate (int and float) data types, and all and negate functions. Specifically,
NOTICE:
The Expr supports the following operators:
|
Applicability
Restrictions
The
The
Returns
An Expr.
Example
tik_instance = tik.Tik()
scalar = tik_instance.Scalar("uint32", init_value=0)
scalar2 = tik_instance.Scalar("uint32", init_value=1)
scalar3 = tik_instance.Scalar("uint32", init_value=0)
gm = tik_instance.Tensor(dtype, shape, name="gm_b", scope=tik.scope_gm)
ub = tik_instance.Tensor(dtype, shape, name="ub_b", scope=tik.scope_ubuf)
# scalar = 0 is a false statement; scalar2! = 0 is a true statement.
# If there is argument passed to tik.any is true, it returns True and runs the if_scope statement.
with tik_instance.if_scope(tik.any(scalar, scalar2)):
scalar3.set_as(1)
tik_instance.vec_dup(64, ub, scalar3, 1, 8)
tik_instance.data_move(gm, ub, 0, 1, 8, 0, 0)
tik_instance.BuildCCE(kernel_name="tik_any", inputs=[], outputs=[gm])