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,
  • Arguments of the Scalar and InputScalar types are automatically converted into Exprs. For example, if the argument name is a, it is converted into a!=0.
  • Arguments of the Expr type are automatically converted into Exprs with !=0. For example, if the argument is scalar // 2, it is converted to scalar // 2!=0.
NOTICE:

The Expr supports the following operators:

  • Comparison operators: >, <, !=, ==, >=, <=
  • Arithmetic operators: +, , *, /, //, %
  • Bitwise operators: &, |, <<, >>

Applicability

Atlas training product

Atlas inference product AI Core

Atlas inference product Vector Core

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

Restrictions

The Atlas training product does not support Scalars of type float16 or Exprs including Scalars of this type.

The Atlas inference product AI Core does not support Scalars of type float16 or Exprs including Scalars of this type.

The Atlas inference product Vector Core does not support Scalars of type float16 or Exprs including Scalars of this type.

The Atlas A2 training product/Atlas A2 inference product does not support Scalars of type float16 or Exprs including Scalars of this type.

The Atlas 200I/500 A2 inference product does not support Scalars of type float16 or Exprs including Scalars of this type.

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])