Skip to content
This repository was archived by the owner on Nov 17, 2023. It is now read-only.
This repository was archived by the owner on Nov 17, 2023. It is now read-only.

Feature Request: 'arange_like/enumerate' operator #14574

@fhieber

Description

@fhieber

It would be quite useful to have an operator that can create ranges based on an existing 'shape_like' symbol, similar to the ops zeros_like, ones_like, and other *_like.

For example, I would like to enumerate the positions of a symbol with dynamic shape:

x = mx.sym.Variable('x')
r = mx.sym.arange_like(x, start=0)
r.eval(x=mx.nd.ones((4,))) # should give: [0, 1, 2, 3]
r.eval(x=mx.nd.ones((2,))) # should give: [0, 1]
r2 = mx.sym.arange_like(x, start=5)
r.eval(x=mx.nd.ones((2, 2))) # should give: [[5, 6], [7, 8]]

Another name could be 'enumerate'.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions