all
Description
Returns True if all arguments are true; False if one of the arguments is false.
This API is generally used as the conditional statement (cond) of the if_scope and elif_scope statements.
Prototype
all(*args)
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
*args |
Input |
Supports multiple arguments. It supports the InputScalar, Scalar, Expr, bool, and immediate (int and float) data types, and any, all, and negate functions. Specifically,
NOTICE:
The Expr supports the following operators:
You can use supported operators to form a complex expression. However, the comparison operators cannot be used together. For example, if you want to express n > 1 and n < 4: |
Applicability
Restrictions
The
The
Returns
A TIK Expr.
For example: tik.all(scalar, scalar > 1, a == 0, i)
Returns: ((x != 0) && (x > 1)) && (i != 0))
Example
tik_instance = tik.Tik()
scalar = tik_instance.Scalar("uint32", init_value=0)
scalar2 = tik_instance.Scalar("uint32", init_value=4)
gm_b = tik_instance.Tensor(dtype, shape, name="gm_b", scope=tik.scope_gm)
ub_b = tik_instance.Tensor(dtype, shape, name="ub_b", scope=tik.scope_ubuf)
a = 1
# scalar2! = 0 is a true statement; a > 0 is a true statement as a equals 1; scalar = 0 is a true statement.
# If all arguments passed to tik.all are true, it returns True and runs the if_scope statement.
with tik_instance.if_scope(tik.all(scalar2, a > 0, scalar == 0)):
tik_instance.vec_dup(64, ub_b, scalar2, 1, 8)
tik_instance.data_move(gm_b, ub_b, 0, 1, 8, 0, 0)
tik_instance.BuildCCE(kernel_name="all", inputs=[], outputs=[gm_b])