Is there a bug in GPU version of arrayfun in 2017a update?

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

답변 (1개)

Joss Knight
Joss Knight 2017년 3월 10일
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

카테고리

도움말 센터File Exchange에서 GPU Computing에 대해 자세히 알아보기

제품

질문:

2017년 3월 10일

답변:

2017년 3월 10일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by