Skip to content

Instantly share code, notes, and snippets.

@asi1024
Created December 19, 2019 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asi1024/e8e2b77533fbe2451205f3de70b2fdba to your computer and use it in GitHub Desktop.
Save asi1024/e8e2b77533fbe2451205f3de70b2fdba to your computer and use it in GitHub Desktop.
import itertools
import numpy
import cupy
import cupyx
shapes = [(4096, 4096), (64, 64, 64, 64)]
for shape in shapes:
ndim = len(shape)
size = numpy.prod(shape)
range_ndim = list(range(ndim))
for perm in itertools.permutations(range_ndim, ndim):
for n_axis in range(1, ndim + 1):
for axes in itertools.combinations(range_ndim, n_axis):
x = cupy.arange(size, dtype='f').reshape(shape)
x = x.transpose(perm)
perf = cupyx.time.repeat(cupy.sum, (x, axes), n=100)
print(perf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment