API function: Draws binary random numbers (
[object Object]or[object Object]) from a Bernoulli distribution.[object Object]indicates the probability of generating[object Object]. The input tensor is used to specify the shape.Formula:
When
[object Object]is used,[object Object]and[object Object]in the formula correspond to those in the prototype of the first-phase API. When[object Object]is used,[object Object]and[object Object]in the formula correspond to[object Object]and[object Object]respectively in the prototype of the first-phase API.
- Each operator has calls. First,·
[object Object]or[object Object]is called to obtain the workspace size required for computation and the executor covering the operator computation process. Then,[object Object]or[object Object]is called to perform computation.
- Parameters:
For [object Object]Atlas training products[object Object], the data type cannot be UINT8, INT8, INT16, INT32, INT64, BOOL, or BFLOAT16.
For [object Object]Atlas A2 training products/Atlas A2 inference products[object Object] and [object Object]Atlas A3 training products/Atlas A3 inference products[object Object], the data type cannot be UINT8, INT8, INT16, INT32, INT64, or BOOL.
Returns:
[object Object]: status code. For details, see .
The first-phase API implements input parameter validation. The following error codes may be returned:
[object Object]- Parameters:
- Parameters:
[object Object]Atlas training products[object Object]: The data type cannot be BFLOAT16.
- Returns:
[object Object]: status code. For details, see .The first-phase API implements input parameter validation. The following error codes may be returned:
[object Object]
- Parameters:
- Deterministic computation:
[object Object]and[object Object]each default to a deterministic implementation.
- The values of elements in the input
[object Object]must be within the range [0, 1]. - When the shapes of
[object Object]and[object Object](or[object Object]) do not match, only the corresponding elements are computed, and the behavior for the remaining data is undefined. For example, when the shape of[object Object]is [4, 2] and that of[object Object]is [4, 4], only the first 8 elements are computed and the output shape is [4, 4]. When the shape of[object Object]is [4, 4, 2] and that of[object Object]is [4, 4], only the first 16 elements are computed and the output shape is [4, 4].
The following example is for reference only. For details, see .