There is a bug in the index output of max and min for gpuArrays. I am using 2018b and the bug also appears in 2019b. The index of the max (the 2nd output) is wrong for various lengths of arrays. For example:
x = randn(8680, 2, 'gpuArray');
[m, k] = max(x, [], 1);
disp(k)
[mCpu, kCpu] = max(gather(x), [], 1);
disp(kCpu)
isequal(k, kCpu)
x = randn(8681, 2, 'gpuArray');
[m, k] = max(x, [], 1);
disp(k)
[mCpu, kCpu] = max(gather(x), [], 1);
disp(kCpu)
isequal(k, kCpu)
OK let's do a test to see which lengths of x faile
n = 1 : 10e3;
bad = [];
for i = 1 : length(n)
x = randn(n(i), 2, 'single', 'gpuArray');
[m1, k1] = max(x, [], 1);
[m2, k2] = max(gather(x), [], 1);
if ~isequal(k1, k2)
bad(end+1) = n(i);
end
end
figure
plot(bad)
Now let's try again with different 2nd dim lengths of x
n = 1 : 10e3;
bad = [];
for i = 1 : length(n)
x = randn(n(i), 4, 'single', 'gpuArray');
[m1, k1] = max(x, [], 1);
[m2, k2] = max(gather(x), [], 1);
if ~isequal(k1, k2)
bad(end+1) = n(i);
end
end
figure
plot(bad)
0 Comments
Sign in to comment.