timeit
https://blogs.mathworks.com/loren/2021/01/14/paged-matrix-functions/
pagetimes and gpu
% batchSize = [500 500 500];
batchSize = [1000000];
matSize = [2 2];
a = complex(rand([matSize batchSize]), rand([matSize batchSize]));
gpuA = gpuArray(a);
f = @() mtimesx(a,a);
gpuF = @() pagefun(@mtimes,gpuA, gpuA);
timeit(f) % I get around 0.8175 seconds
gputimeit(gpuF) % I get around 0.1033 seconds
batchSize = [1000 1000];
% batchSize = [10000]
matSize = [2 2];
a = complex(rand([matSize batchSize]), rand([matSize batchSize]));
gpuA = gpuArray(a);
f = @() pagemtimes(a,a);
gpuF = @() pagemtimes(gpuA, gpuA);
timeit(f) % I get around 0.05 seconds
gputimeit(gpuF) % I get around 0.3 seconds

浙公网安备 33010602011771号