FilesLast commitLast update
11 days ago
2 months ago
15 days ago
9 days ago
30 days ago
15 days ago
1 month ago
8 days ago
README

Bias

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

Bias derives the logical broadcast shape of bias according to axis, num_axes, and bias_from_blob, and computes y = x + broadcast(bias).

The computation formula is as follows:

yi=xi+biasiy_i = x_i + bias_i

The derivation rules of broadcast(bias) are as follows:

  • If axis < 0, execute axis += rank(x) first.
  • If bias_from_blob = true and num_axes = -1, broadcast_shape = [1] * axis + shape(bias).
  • If bias_from_blob = true and num_axes = 0, broadcast_shape = [1] * rank(x).
  • If bias_from_blob = true and num_axes > 0, broadcast_shape = [1] * axis + shape(bias) + [1] * (rank(x) - axis - num_axes).
  • If bias_from_blob = false and bias contains a single element, broadcast_shape = [1] * rank(x).
  • For other scenarios where bias_from_blob = false, broadcast_shape = [1] * axis + shape(bias) + [1] * (rank(x) - axis - rank(bias)).

Parameter Description

Parameter Name Input/Output/Attribute Description Data Type Data Format
x Input Input tensor for the Bias computation. FLOAT, FLOAT16, BFLOAT16 ND, NC1HWC0
bias Input Bias tensor that is broadcast according to the attributes and then added to x. FLOAT, FLOAT16, BFLOAT16 ND, NC1HWC0
axis Attribute Starting alignment axis of the logical shape of bias. The default value is 1. INT -
num_axes Attribute Number of axes covered by bias. The default value is 1; -1, 0, and positive integers are supported. INT -
bias_from_blob Attribute Whether to derive the logical broadcast shape according to the blob bias rules. The default value is true. BOOL -
y Output Output tensor, whose shape and data type follow those of x. FLOAT, FLOAT16, BFLOAT16 ND, NC1HWC0

Constraint Description

  • The ND and NC1HWC0 data formats are supported (NC1HWC0 is supported for 4D inputs), as well as inputs and outputs of the same data type among FLOAT, FLOAT16, and BFLOAT16; mixed data types are not supported.
  • After attribute-based derivation, each dimension of bias must be 1, or the same as the corresponding dimension of x.

Invocation Description

Invocation Method Invocation Sample Description
Graph-mode invocation test_geir_bias Invokes the Bias operator by building a graph through the operator IR.