Vectorisation like `np.vectorize` or `jax.vmap`

Aperta
#1,111 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
25/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
numpy, python, rust
Ambito
data

Direzione di ricerca

The issue mentions no files, tests, or entry points in the ndarray repository. Start by surveying the existing array and function APIs, then clarify the proposed vectorisation interface, supported argument patterns, parallelisation expectations, and tests needed to define when the feature is complete.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement help wanted

This is a feature suggestion.

One of the important feature of numpy and jax in Python is to provide a vectorisation scheme for function.

Here is a mini example in Python:

import jax.numpy as np

# This function takes two float arguments and output a float
def func(x: float, y: float) -> float:
    return x - y

# This vmap will give a vectorised func, now this vectorised_func
# can take an array as input and produce an array output.
# Here[0, None] means that we vectorise func's first argument only.
vectorised_func = jax.vmap(func, in_axes=[0, None])

# Test arrays
a = jnp.array([1., 2., 3])
b = 2.

vectorised_func(a, b)  # This will output an array([-1, 0, 1])

# You can even do more to vectorise the y argument of func also
even_more_vectorised_func = jax.vmap(vectorised_func, in_axes=[None, 0])

# 
c = jnp.array([3., 2., 1.])
even_more_vectorised_func(a, c) # This will output a matrix ([[-2, -1, 2], [-1, 0, 2], [0, 1, 2]])

In numpy, this is similar to np.vectorize, but np.vectorize is actually not using any parallelisation scheme unlike jax.vmap.

This feature, in my opinion, is very important for scientific computing. For example, if you have two arrays, you can use this to compute their pairwise distances. As an another example, in multidimensional numerical quadrature, computing \int f(x) dx requires to evaluting the function f by a number of node points, this could be significantly improved by vectorisation.

I am a researcher in signal processing and machine learning, and I can definetly say this feature is valuable.

Lingua principale
Rust
Stelle
4.3k
Fork
391
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di rust-ndarray/ndarray

Tutte le issue di rust-ndarray/ndarray

Issue simili

Altre issue su Rust

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.