Jarartur
Jarartur

Reputation: 159

Array/Tensor calculations efficiency in Julia

I wondered what is the most efficient way of array calculations in Julia. I want to write some deep learning models from scratch so maybe there is some package for tensor calculations, maybe on the gpu? My current code is pretty much as basic as it gets:

function linear(x, w, b)
    return(x*w .+ transpose(b))
end

Upvotes: 4

Views: 95

Answers (1)

Oscar Smith
Oscar Smith

Reputation: 6378

Good news: this code is already good for maximal performance and gpu. You just need a the CuArrays (for Nvidia) to define a GPU array type and then you can run code like linear(CuArray(1:1000),CuArray(1:2*1:1000'),CuArray(1:1000)) and all the calculations will be happening on GPU. Note that you will probably need more complicated examples for the GPU speed to be worth the data transfer time.

Upvotes: 1

Related Questions