Poor slicing performance compared to NumPy
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 25/100
- Type d'issue
- Bug
- Clarté
- À clarifier
- Activité
- À l'abandon
- Stack technique
- python
- Domaine
- performance
Piste de recherche
Commencez par exécuter le benchmark Python fourni avec les backends CPU et GPU, en vous concentrant sur af_B[:, i], af_B[i, :] et af.matmul. Comme aucun fichier source ni test n’est indiqué dans l’issue, suivez ces points d’entrée à travers les bindings Python et comparez-les avec unsliced matmul. La tâche est considérée comme terminée lorsque vous avez reproduit la régression, identifié sa cause et ajouté un test de régression ou un benchmark qui démontre l’amélioration.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
reported by @floopcz on over here: https://github.com/arrayfire/arrayfire/issues/1428
ArrayFire slicing seems to suffer from a performance issue. Consider the following python code, that:
- calculates the dot product of two matrices, first using NumPy, than ArrayFire
- calculates each column/row of the dot product separately by slicing a single column/row from one of the matrices
#!/usr/bin/env python3
from time import time
import arrayfire as af
import numpy as np
af.set_backend('cpu')
af.info()
iters = 1000
n = 512
af_A = af.randu(n, n)
af_B = af.randu(n, n)
np_A = np.random.rand(n, n).astype(np.float32)
np_B = np.random.rand(n, n).astype(np.float32)
start = time()
for t in range(iters):
np_C = np.dot(np_A, np_B)
print('numpy - dot: {}'.format(time() - start))
af.sync()
start = time()
for t in range(iters):
af_C = af.matmul(af_A, af_B)
af.sync()
print('arrayfire - matmul: {}'.format(time() - start))
start = time()
for t in range(iters):
for i in range(np_B.shape[1]):
np_C = np.dot(np_A, np_B[:, i])
print('numpy - sliced dot - column major: {}'.format(time() - start))
af.sync()
start = time()
for t in range(iters):
for i in range(af_B.shape[1]):
af_C = af.matmul(af_A, af_B[:, i])
af.sync()
print('arrayfire - sliced matmul - column major: {}'.format(time() - start))
start = time()
for t in range(iters):
for i in range(np_B.shape[0]):
np_C = np.dot(np_B[i, :], np_A)
print('numpy - sliced dot - row major: {}'.format(time() - start))
af.sync()
start = time()
for t in range(iters):
for i in range(af_B.shape[0]):
af_C = af.matmul(af_B[i, :], af_A)
af.sync()
print('arrayfire - sliced matmul - row major: {}'.format(time() - start))
The results are following:
ArrayFire v3.3.2 (CPU, 64-bit Linux, build f65dd97)
[0] Unknown: Unknown, 15880 MB, Max threads(1)
numpy - dot: 1.3848536014556885
arrayfire - matmul: 1.325775146484375
numpy - sliced dot - column major: 7.156768798828125
arrayfire - sliced matmul - column major: 38.87605834007263
numpy - sliced dot - row major: 7.6784679889678955
arrayfire - sliced matmul - row major: 41.27544379234314
The results suggest that with slicing, arrayfire performance is significantly degraded compared to NumPy. I have achieved similarly distributed results also with the GPU backend. Both numpy and arrayfire are linked against Intel MKL.
Am I doing something "illegal" or is it an inefficiency of the library? Thanks.
- Langage dominant
- Python
- Étoiles
- 422
- Forks
- 63
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de arrayfire/arrayfire-python
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
arrayfire/arrayfire-python#271 ·
-
Unwrap phase function Ouverte
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
arrayfire/arrayfire-python#270 ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 35/100
arrayfire/arrayfire-python#269 ·
-
Difficulté 4/5 3-5 jours Accessibilité débutants 38/100
arrayfire/arrayfire-python#268 · 1 commentaire ·
-
Difficulté 3/5 1-2 jours Accessibilité débutants 48/100
arrayfire/arrayfire-python#267 · 1 commentaire · 1 réaction ·
Toutes les issues de arrayfire/arrayfire-python
Issues similaires
-
Add: hunch Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 74/100
AbdelStark/awesome-typesafe#104 ·
-
enhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
DiamondLightSource/dodal#2211 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
openml/openml-python#1749 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
sipyourdrink-ltd/bernstein#6191 ·