【发布时间】:2020-06-20 11:47:13
【问题描述】:
当我在 cupy 数组上运行 cupy 函数时,第一次调用函数所用的时间比第二次运行要长得多,即使我第二次在不同的数组上运行它也是如此。
这是为什么?
import cupy as cp
cp.__version__
# 7.5.0
A = cp.random.random((1024, 1024))
B = cp.random.random((1024, 1024))
from time import time
def test(func, *args):
t = time()
func(*args)
print("{}".format(round(time() - t, 4)))
test(cp.fft.fft2, A)
test(cp.fft.fft2, B)
# 0.129
# 0.001
test(cp.matmul, A, A.T)
test(cp.matmul, B, B.T)
# 0.171
# 0.0
test(cp.linalg.inv, A)
test(cp.linalg.inv, B)
# 0.259
# 0.002
【问题讨论】:
标签: cupy