Return a 2-D tensor with ones on the diagonal and zeros elsewhere, with the same shape as the input tensor. Parameters ---------- x : relax.Expr The input tensor, which provides the shape, and dtype when the `dtype` field is not specified. k : PrimExprLike | Pri
(
x: Expr,
k: PrimExprLike | PrimValue = 0,
dtype: str | DataType | None = None,
)
| 199 | |
| 200 | |
| 201 | def eye_like( |
| 202 | x: Expr, |
| 203 | k: PrimExprLike | PrimValue = 0, |
| 204 | dtype: str | DataType | None = None, |
| 205 | ) -> Expr: |
| 206 | """Return a 2-D tensor with ones on the diagonal and zeros elsewhere, |
| 207 | with the same shape as the input tensor. |
| 208 | |
| 209 | Parameters |
| 210 | ---------- |
| 211 | x : relax.Expr |
| 212 | The input tensor, which provides the shape, and dtype |
| 213 | when the `dtype` field is not specified. |
| 214 | |
| 215 | k : PrimExprLike | PrimValue |
| 216 | Index of the diagonal: 0 (the default) refers to the main diagonal, |
| 217 | a positive value refers to an upper diagonal, and a negative value |
| 218 | to a lower diagonal. |
| 219 | |
| 220 | dtype : Optional[str | DataType] |
| 221 | The data type of the created tensor. |
| 222 | If dtype is not given, it will by default use the dtype of the input tensor. |
| 223 | |
| 224 | Returns |
| 225 | ------- |
| 226 | result : relax.Expr |
| 227 | The result tensor. |
| 228 | """ |
| 229 | k = k if isinstance(k, PrimValue) else PrimValue(k) |
| 230 | return _ffi_api.eye_like(x, k, dtype) # type: ignore |
| 231 | |
| 232 | |
| 233 | def arange( |
nothing calls this directly
no test coverage detected
searching dependent graphs…