When I do sample on GPU, for example
>> a = rand(3,5, 'gpuArray');
>> a = a > rand(size(a), 'gpuArray');
>> b = rand(5,3, 'gpuArray');
>> c = b * a; %where mistake happens,just said misuse *,
MTIMES do not fully support integer class,at least one input is scalar.
So how can I solve this question?
Just use
>> a = double(a);
>> b = rand(5,3, 'gpuArray');
>> c = b * a;
I know I can do this, but is there any nicer solutions, such as I can multiply it directly?
There are no other solutions that are "nice". As you have already discovered, MATLAB only supports matrix multiplication using floating-point types ( double
, single
, etc.). This is well-understood behaviour in MATLAB. You must ensure both types are of a supported type.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.