MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / iota

Function iota

imperative/python/megengine/xla/rules/tensor.py:231–243  ·  view source on GitHub ↗

do some thing like arange. for example: shape = (2, 3), dimension=1, output is [[0, 1, 2], [0, 1, 2]] shape = (2, 3), dimension=-1, output is [[0, 0, 0], [1, 1, 1]]

(dtype, shape, dimension)

Source from the content-addressed store, hash-verified

229
230
231def iota(dtype, shape, dimension):
232 """
233 do some thing like arange.
234 for example:
235 shape = (2, 3), dimension=1, output is [[0, 1, 2], [0, 1, 2]]
236 shape = (2, 3), dimension=-1, output is [[0, 0, 0], [1, 1, 1]]
237 """
238 dimension = dimension + len(shape) if dimension < 0 else dimension
239 ret = hlo.IotaOp(
240 ir_utils.make_ir_type_according_meta(shape, dtype), ir_utils.i64_attr(dimension)
241 ).results
242 assert len(ret) == 1, f"{len(ret)}"
243 return HLOTensor(ret[0])
244
245
246def linspace(

Callers 11

resize_nearest_helperFunction · 0.70
resize_linear_helperFunction · 0.70
resize_nearestFunction · 0.70
resize_linearFunction · 0.70
resize_nearest_backwardFunction · 0.70
resize_linear_backwardFunction · 0.70
argsortFunction · 0.70
argsort_backward_lowerFunction · 0.70
linspaceFunction · 0.70
apply_on_var_nodeFunction · 0.50
apply_on_physical_tensorFunction · 0.50

Calls 1

HLOTensorClass · 0.85

Tested by

no test coverage detected