MCPcopy Create free account
hub / github.com/apache/tvm / eye_like

Function eye_like

python/tvm/relax/op/create.py:201–230  ·  view source on GitHub ↗

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,
)

Source from the content-addressed store, hash-verified

199
200
201def 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
233def arange(

Callers

nothing calls this directly

Calls 1

PrimValueClass · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…