Is there a bug in GPU version of arrayfun in 2017a update?
Show older comments
A call to the function below, e.g. f0(1,1), throws an error "Inputs must be the same size or either one can be a scalar".
It was not the case in 2016b and 2015b. The two parameters (a,b) are necessary to reproduce the error. I've read the release notes, but still no idea why this happens.
function y0=f0(a, b)
y0 = arrayfun(@f1, gpuArray(1));
function y1 = f1(x1)
y1 = f2(a, b);
end
function y2 = f2(a2, b2)
y2 = 1;
end
end
Answers (1)
Joss Knight
on 10 Mar 2017
Although the behaviour here is incorrect, the confusion arises because you have not indexed the up-level variables a and b. You can workaround the problem with a minor change:
function y0=r17agpubug(a, b)
y0 = arrayfun(@f1, gpuArray(1));
function y1 = f1(x1)
y1 = f2(a(1), b(1)); % Index a and b here
end
function y2 = f2(a2, b2)
y2 = 1;
end
end
Categories
Find more on GPU Computing in MATLAB in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!