| Files | Last commit | Last update |
|---|---|---|
| 16 days ago | ||
| 2 months ago | ||
| 13 days ago | ||
| 2 months ago | ||
| 22 days ago | ||
| 2 months ago | ||
| 13 days ago | ||
| 25 days ago | ||
| 1 month ago | ||
| 8 days ago |
Cdist
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 p-norm distance between each pair of vectors in two sets of vectors.
-
Computation formula: For the input tensors x1 and x2, their shapes are [B,P,M][B, P, M] and [B,R,M][B, R, M] respectively, and the shape of the output tensor y is [B,P,R][B, P, R].
When p>0p>0:
yb,i,j=(∑k=1M∣x1b,i,k−x2b,j,k∣p)1py_{b,i,j}=\left(\sum_{k=1}^{M}|x1_{b,i,k}-x2_{b,j,k}|^p\right)^{\frac{1}{p}}
When p=0p=0, the output is the number of unequal elements in the corresponding vectors; when p=+∞p=+\infty, the output is the maximum of the absolute differences between the elements of the corresponding vectors.
Parameter Description
| Parameter Name | Input/Output/Attribute | Description | Data Type | Data Format |
|---|---|---|---|---|
| x1 | Input | The first input tensor, whose shape is [B, P, M]. | BFLOAT16, FLOAT16, FLOAT | ND |
| x2 | Input | The second input tensor, whose shape is [B, R, M]. | BFLOAT16, FLOAT16, FLOAT | ND |
| y | Output | p-norm distance computation result, whose shape is [B, P, R]. | BFLOAT16, FLOAT16, FLOAT | ND |
| p | Optional attribute | Norm order. The value range is [0, +∞], and the default value is 2.0. | FLOAT | - |
Constraint Description
- The data types of x1, x2, and y must be the same.
- The dimensions of x1 and x2 range from 2 to 8, and the lengths of the last dimensions must be the same.
- The dimensions of x1 and x2 except the last two dimensions must satisfy the broadcast relationship; the corresponding output dimensions are the broadcast shape.
- If the second-to-last dimension of x1 is P and the second-to-last dimension of x2 is R, the last two dimensions of the output are [P, R].
- p must be greater than or equal to 0. +∞ is supported, and common values are 0, 1.0, 2.0, and +∞.
Invocation Description
| Invocation Method | Invocation Sample | Description |
|---|---|---|
| aclnn invocation | test_aclnn_cdist | Invokes the Cdist operator through the aclnnCdist API. |