2

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

2
  • Could I ask: does this cause you any problems in your code, or is it simply an inconsistency you've observed? Commented Feb 5, 2015 at 8:57
  • 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. Commented Feb 5, 2015 at 16:53

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Will this slow down my code if I put it in my loop?
Operations on scalars are generally faster on the CPU, so I recommend avoiding putting scalar data onto the GPU. So actually this behaviour is probably beneficial if inconsistent.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.