Skip to content
[alpha] Expose Julia functions to PyTorch
C++ CMake Python Julia Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
pybind11 @ c9d32a8
src
.gitmodules
CMakeLists.txt
Project.toml
README.md
build.sh
test.jl
test.py

README.md

torch_julia

This project makes it easy to write operations (or really anything) in Julia and use those within PyTorch.

Build

./build.sh

Usage

In a Julia file, you'll need to use TorchReg.torch_reg(f) to expose a function to PyTorch.

function f(a, b)
  c = a .* b
  return c
end

import Pkg; Pkg.activate(".") # or install TorchReg
using TorchReg
torch_reg(f)

In a Python file, you can then use torch_julia.load("julia_code.jl") to expose the functions registered to the torch.ops.julia._ namespace.

import torch
import torch_julia
torch_julia.load("julia_code.jl")

a = torch.randn(10)
b = torch.randn(10)
print(a,b)
c = torch.ops.julia.f(a, b)
print(c)

Gotchas

Test

LD_PRELOAD=/data/users/bwasti/julia/usr/lib/libjulia.so PYTHONPATH=build python test.py
You can’t perform that action at this time.