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)
| 229 | |
| 230 | |
| 231 | def 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 | |
| 246 | def linspace( |
no test coverage detected