Skip to content

Instantly share code, notes, and snippets.

@unnonouno
Created July 11, 2016 10:50
Show Gist options
  • Save unnonouno/a53031262b80a9d506c2c3c8bef8d7ed to your computer and use it in GitHub Desktop.
Save unnonouno/a53031262b80a9d506c2c3c8bef8d7ed to your computer and use it in GitHub Desktop.
import chainer
from chainer import cuda
import cupy
import numpy
import time
ls = numpy.random.randint(1, 100, size=1000)
ls = numpy.sort(ls)[::-1]
unit = 100
xs = [cupy.empty((l, unit), 'f') for l in ls]
cuda.to_cpu(xs[0])
begin = time.time()
for i in range(10):
chainer.functions.transpose_sequence(xs)
cuda.to_cpu(xs[0])
end = time.time()
print(end - begin)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment