Spence
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: computes the Spence function (dilogarithm) value of each element in the input tensor and outputs the result.
-
Computation formula:
Spence(x)=∫1xlnt1−t dt=Li2(1−x)\text{Spence}(x) = \int_1^x \frac{\ln t}{1 - t} \, dt = \text{Li}_2(1 - x)
Special values:
- Outputs NaN when x<0x < 0
- Outputs π2/6≈1.6449\pi^2/6 \approx 1.6449 when x=0x = 0
- Outputs 00 when x=1x = 1
- Outputs NaN when x=+∞x = +\infty
Parameter Description
| Parameter Name | Input/Output/Attribute | Description | Data Type | Data Format |
|---|---|---|---|---|
| x | Input | Independent variable of the Spence function, corresponding to x in the formula. Elements with x < 0 output NaN. | FLOAT16, FLOAT, BFLOAT16 | ND |
| y | Output | Computation result of the Spence function, corresponding to Spence(x) in the formula. | FLOAT16, FLOAT, BFLOAT16 | ND |
Constraint Description
- FLOAT16 and BFLOAT16 inputs are promoted to FLOAT32 for computation inside the kernel, and the results are converted back to the original data type.
- The number of input dimensions must not be greater than 8; otherwise, the operator reports an error. Scalar inputs (processed as a Tensor with one element), empty tensors, dynamic shapes, and dynamic ranks are supported.
- Non-contiguous inputs are automatically made contiguous by the framework before computation.
Invocation Description
| Invocation Method | Sample Code | Description |
|---|---|---|
| GE graph mode | test_geir_spence | Invokes the Spence operator in GE graph mode. The prototype file that defines the operator IR is spence_proto.h. |