Skip to content

Instantly share code, notes, and snippets.

@asi1024
Created December 18, 2019 11:20
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save asi1024/f902267d483de8e94c8d4a4f83fbb869 to your computer and use it in GitHub Desktop.
import numpy
import cupy
import cupyx
shapes = [(10, 10), (4096, 4096)]
# cupy.add
for shape in shapes:
for is_c_contiguous in [False, True]:
size = numpy.prod(shape)
x = cupy.arange(size).reshape(shape)
y = cupy.arange(size).reshape(shape)
if not is_c_contiguous:
x = x.T
perf = cupyx.time.repeat(cupy.add, (x, y), n=3000)
print(perf)
# cupy.sum
for shape in shapes:
for is_c_contiguous in [False, True]:
size = numpy.prod(shape)
x = cupy.arange(size).reshape(shape)
if not is_c_contiguous:
x = x.T
perf = cupyx.time.repeat(cupy.sum, (x, 0), n=3000)
print(perf)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment