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

オープン
#1,111 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
numpy, python, rust
領域
data

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
Rust
スター
4.3k
フォーク
391
PR マージ指標
30日以内にマージされた PR はありません

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

rust-ndarray/ndarray のほかの issue

rust-ndarray/ndarray の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。