FilesLast commitLast update
2 months ago
2 months ago
16 days ago
4 months ago
3 months ago
16 days ago
1 month ago
8 days ago
README

StatelessTruncatedNormalV2

English | 简体中文

Product Support Status

Product Supported
Ascend 950PR&950DT products √
Atlas A3 products ×
Atlas A2 products ×
Atlas 200I/500 A2 inference products ×
Atlas inference products ×
Atlas training products ×

Function Description

  • Operator function: stateless truncated normal distribution random number generator. It uses the Philox4x32 algorithm and takes key and counter as inputs to generate uint32 random numbers that follow the uniform distribution. It converts the uniform distribution into the standard normal distribution through the Box-Muller transform, generating random numbers that follow the standard normal distribution N(0,1). Samples whose absolute values are greater than 2.0 are truncated, discarded, and resampled.
  • Stateless feature: random number generation is fully determined by the externally passed key/counter. The same input is guaranteed to produce the same output (deterministic).
  • Benchmark: TensorFlow tf.raw_ops.StatelessTruncatedNormalV2

Parameter Description

Parameter Name Input/Output/Attribute Description Data Type Data Format
shape Input Shape of the output tensor. INT32, INT64 ND
key Input Key of the Philox random number generator, shape=[1]. UINT64 ND
counter Input Counter of the Philox random number generator, shape=[2]. UINT64 ND
alg Input Random number algorithm ID (1=Philox; currently only Philox is supported). INT32 ND
dtype Attribute Specifies the data type of the output (0=float32, 1=float16, 27=bfloat16 ,11=float64). INT ND
y Output Generated truncated normal distribution random number sequence. FLOAT16, FLOAT, BF16, FLOAT64 ND

Constraint Description

  • The alg parameter currently supports only the Philox algorithm (alg=1).
  • The shape of key must be [1].
  • The shape of counter must be [2] (required by the Philox algorithm).
  • When the number of elements in the output shape is 0, an empty tensor is directly returned.

Invocation Description

Invocation Method Sample Code Description
Graph-mode invocation test_geir_stateless_truncated_normal_v2 Invokes the StatelessTruncatedNormalV2 operator by building a graph through the operator IR.