A Julia interface for PyTorch's C++ backend.
THArrays.Tensor
: PyTorch Tensor as an Array-like data type in JuliaTHArrays.THAD
: AD using PyTorch C++ backendTHArrays.TrackerAD
: AD using Tracker.jl and PyTorch C++ backend mixed, on your choiceTHArrays.THJIT
: using TorchScript in Julia
-
Install the package:
] add THArrays
-
Read the docs here, or
-
Experiment in the Julia REPL directly:
julia> using THArrays julia> t = Tensor( -rand(3, 3) ) PyTorch.Tensor{Float64, 2}: -0.1428 -0.7099 -0.1446 -0.3447 -0.0686 -0.8287 -0.2692 -0.0501 -0.2092 [ CPUDoubleType{3,3} ] julia> sin(t)^2 + cos(t)^2 PyTorch.Tensor{Float64, 2}: 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 1.0000 [ CPUDoubleType{3,3} ] julia> THAD.gradient(x->sum(sin(x)+x^2), rand(3,3)) (PyTorch.Tensor{Float64, 2}: 2.3776 1.5465 2.0206 1.2542 1.2081 2.1156 2.1034 1.1568 2.2599 [ CPUDoubleType{3,3} ] ,) julia>
You can find more examples under the
test
directory.