Giter Site home page Giter Site logo

How does mx.pad work? about mlx HOT 4 OPEN

ml-explore avatar ml-explore commented on July 17, 2024
How does mx.pad work?

from mlx.

Comments (4)

machineko avatar machineko commented on July 17, 2024

Padding with constant in almost every framework use scalar value and its same here (I feel like passing array is some sort of performance optimisation (?) or maybe extra usability cause original code still use only first array element)
You can check original code -> https://github.com/ml-explore/mlx/blob/430bfb494431fbe36c3f635bd7296a356dd772e6/mlx/ops.cpp#L571C1-L577C34

from mlx.

sck-at-ucy avatar sck-at-ucy commented on July 17, 2024

Thanks for pointing me to the original code, I think you're right, I had hopes that the reference to an array was hinting at something more exciting :)

from mlx.

awni avatar awni commented on July 17, 2024

Good question, right now the constant_values is really just a scalar.

We should probably throw or something if the wrong shape is provided.

I think in Numpy the constant_values need to be broadcastable to the shape of the pad_width. So if pad_width is ((a, b), (c, d))then theconstant_valuesneeds to broadcast to a shape of[2, 2]`. We can add this as a feature in the future if it's useful.

Also (unrelated) it looks like we should add a linspace :). If that's pretty useful for you, feel free to file another issue.

from mlx.

sck-at-ucy avatar sck-at-ucy commented on July 17, 2024

Thank you this clarifies. Yes, MLX native linspace would be handy to have.

from mlx.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.