How to get the value of the ndarray in scala apis

Hello everyone.
I am new to mxnet.
I am trying to find cosine similarity between 2 ndarray vectors using scala API. Following is the code

println(result1.shape) # Shape(2047, 1)
println(result2.shape) # Shape(2047, 1)
val dt = NDArray.dot(NDArray.transpose(result1), result2) # dt is of shape (1, 1)
println(“dot computed”)
val r1n = NDArray.norm(result1)
val r2n = NDArray.norm(result2)
println(“norm calculated”)
val denom = NDArray.dot(r1n, r2n) # denom is of shape (1)
println(“denom calculated”)

val cosine_similarity = NDArray.broadcast_div(denom, dt)

Now, how do I get the value of cosine_similarity here?
If I do cosine_similarity.toArray, it takes around 1 min.
IS there any other way to get the value?

Thanks a lot.