FilesLast commitLast update
5 days ago
14 days ago
2 days ago
2 days ago
2 days ago
2 days ago
2 days ago
1 month ago
5 days ago
5 days ago
README

Scale

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: performs the scale and bias computation on the input tensor. If bias is not input, y=x⋅scaley = x \cdot scale. If bias is input, y=x⋅scale+biasy = x \cdot scale + bias.

  • Operator formula:

    If bias is not input:

    yi=xi⋅scaleiy_i = x_i \cdot scale_i

    If bias is input:

    yi=xi⋅scalei+biasiy_i = x_i \cdot scale_i + bias_i

    Here:

    • xix_i is the input tensor;
    • scaleiscale_i is the scaling factor tensor, and broadcast with x is supported;
    • biasibias_i is an optional bias tensor, and its shape is the same as that of scale;
    • yiy_i is the output tensor, and its shape is the same as that of x.

Parameter Description

Parameter Name Input/Output/Attribute Description Data Type Data Format
x Input Input tensor of the operator. Empty tensors are supported. FLOAT16, FLOAT, BFLOAT16 ND
scale Input Scaling factor tensor. Its data type follows the constraints below, and its shape must meet the broadcast requirements. FLOAT16, FLOAT, BFLOAT16 ND
bias Optional input Optional bias tensor, omitted by default. Its data type follows the constraints below. Its shape constraints are defined by the corresponding interface. FLOAT16, FLOAT, BFLOAT16 ND
y Output Output tensor. Its shape and data type are the same as those of x. FLOAT16, FLOAT, BFLOAT16 ND
axis Optional attribute Specifies the start axis for scaling. The default is 1, and the value range is [-x_rank, x_rank). INT64 -
num_axes Optional attribute
  • Specifies the number of axes for scaling. The default is 1, and the value range is greater than or equal to -1. If axis is negative, axis is first normalized to x_rank + axis. The following axis refers to the normalized value.
  • When scale_from_blob is True, -1 scales through the last axis and 0 denotes scalar scaling. See the corresponding interface for shape rules.
  • When scale_from_blob is False, num_axes does not participate in the shape derivation of scale.
INT64 -
scale_from_blob Optional attribute The default is True. True derives the shape of scale using num_axes and axis. False derives the shape from axis based on the rank of scale; num_axes does not participate in shape derivation. BOOL -

The attribute defaults apply to GE graphs. The aclnn API requires explicit axis, numAxes, and scaleFromBlob arguments, corresponding to axis, num_axes, and scale_from_blob.

Atlas inference products: The aclnn API does not support BFLOAT16.

Constraint Description

  • The shapes of x and y must be exactly the same.
  • Each input uses FLOAT16/FLOAT/BFLOAT16, and y has the dtype of x. The aclnn API requires matching input dtypes. GE graphs allow each input to independently use these dtypes; GE adapts them before kernel dispatch.
  • When bias is present and has nonzero elements, its shape must match scale. See the corresponding interface for zero-element tensor handling.
  • The shape of scale must satisfy the broadcast window rules defined by axis and num_axes. See the corresponding interface for details.
  • The aclnn API supports at most eight dimensions for x and scale. For GE graph rank constraints, see the Scale IR definition.
  • The value range of axis is [-x_rank, x_rank).
  • The value range of num_axes is >=-1.
  • Only the ND format is supported.
  • GE graphs support -1 for unknown dimensions and [-2] for unknown rank. Runtime concrete shapes must satisfy the Scale IR definition.
  • The aclnn API supports non-contiguous tensors with at most eight dimensions.

Invocation Description

Invocation Method Invocation Sample Description
aclnn invocation test_aclnn_scale Invokes the Scale operator through the aclnnScale API.
GE graph - Uses the Scale IR definition; graph descriptor and runtime shape constraints are defined there.

Atlas 200I/500 A2 inference products and Atlas training products support GE graphs but do not support the aclnn API.