2
votes

My matlab version is 2014a. Norm function is built in gpuArray function in matlab. I think it should return gpuArray class when input is gpuArray. But in my matlab, it returns double. Could anyone tell me what happened?

Example,

a=gpuArray.randn(3,4);
b=norm(a)

the type of b is "double" instead of "gpuArray".

Thank you

1
Could I ask: does this cause you any problems in your code, or is it simply an inconsistency you've observed? - Edric
It doesn't cause problem. I am just not sure if this inconsistency will slow down my code if I put it in the loop. It seems like to transfer back and forth between CPU and GPU every time. - aaa

1 Answers

1
votes

Unfortunately as you observe this is an inconsistency in the implementation of gpuArray. Generally speaking, methods that return data related to the values of the input array such as min, max, sum etc. return values as gpuArray, but norm does not.