Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed compat to enable tests on CI #60

Merged
merged 3 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 23 additions & 22 deletions .buildkite/pipeline.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,28 @@ steps:
- JuliaCI/julia-test#v1: ~
agents:
queue: "juliagpu"
cuda: "*"
timeout_in_minutes: 60
cuda: "true"
cap: sm_75
command: |
TMP_PROJECT=`mktemp -d`

cd $$TMP_PROJECT

- label: "GPU integration with julia v1"
plugins:
- JuliaCI/julia#v1:
version: "1"
- JuliaCI/julia-test#v1: ~
agents:
queue: "juliagpu"
cuda: "*"
env:
JULIA_CUDA_USE_BINARYBUILDER: "true"
timeout_in_minutes: 60
touch Project.toml
cat <<EOT > LocalPreferences.toml
[CUDA_Runtime_jll]
version = "10.2"
EOT

export CUDA_RUNTIME_ROOT=`julia --project --eval '
using Pkg
Pkg.add(name="CUDA_Runtime_jll", version="0.2")
using CUDA_Runtime_jll
println(CUDA_Runtime_jll.artifact_dir)
'`

# - label: "GPU nightly"
# plugins:
# - JuliaCI/julia#v1:
# version: "nightly"
# - JuliaCI/julia-test#v1: ~
# agents:
# queue: "juliagpu"
# cuda: "*"
# timeout_in_minutes: 60
ls -1 $$CUDA_RUNTIME_ROOT/lib/libcudart*
export LD_LIBRARY_PATH=$$CUDA_RUNTIME_ROOT/lib

cd $$BUILDKITE_BUILD_CHECKOUT_PATH
timeout_in_minutes: 60
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/Manifest.toml
/.vscode
134 changes: 0 additions & 134 deletions Manifest.toml

This file was deleted.

12 changes: 6 additions & 6 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "Torch"
uuid = "6a2ea274-3061-11ea-0d63-ff850051a295"
authors = ["dhairyagandhi96 "]
authors = ["Dhairya Gandhi <dhairyagandhi96@gmail.com>"]
version = "0.1.2"

[deps]
Expand All @@ -15,19 +15,19 @@ ZygoteRules = "700de1a5-db45-46bc-99cf-38207098b444"

[compat]
FillArrays = "0.8, 0.11, 0.13"
NNlib = "0.6, 0.7"
Flux = "0.11"
NNlib = "0.6, 0.7.0 - 0.7.24"
Requires = "1"
Torch_jll = "~1.4"
Zygote = "0.5"
ZygoteRules = "0"
julia = "1.4"

[extras]
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
IterTools = "c8e1da08-722c-5040-9ed9-7db0dc04731e"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Metalhead = "dbeba491-748d-5e0e-a39e-b530a07fa0cc"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[targets]
test = ["Test", "Flux", "Metalhead", "Documenter", "IterTools", "LinearAlgebra"]
test = ["Flux", "Metalhead", "Test", "Zygote"]
21 changes: 21 additions & 0 deletions test/flux_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using Flux
using Metalhead
using Test
using Torch
using Torch: Tensor, tensor

@testset "Flux" begin
resnet = ResNet()
tresnet = Flux.fmap(Torch.to_tensor, resnet.layers)

ip = rand(Float32, 224, 224, 3, 1) # An RGB Image
tip = tensor(ip, dev = 0) # 0 => GPU:0 in Torch

top = tresnet(tip)
op = resnet.layers(ip)

gs = gradient(() -> sum(tresnet(tip)), Flux.params(tresnet))
@test top isa Tensor
@test size(top) == size(op)
@test gs isa Flux.Zygote.Grads
end
32 changes: 5 additions & 27 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,29 +1,7 @@
using Test, Flux, Metalhead
using Torch
using Torch: Tensor, tensor
using Test

@testset "Movement" begin
r = rand(Float32, 3,3)
tr = tensor(r, dev = 0)
@test tr isa Tensor
@test tr .* tr isa Tensor

cr = collect(tr)
@test cr isa Array
end

@testset "Flux" begin
resnet = ResNet()
tresnet = Flux.fmap(Torch.to_tensor, resnet.layers)

ip = rand(Float32, 224, 224, 3, 1) # An RGB Image
tip = tensor(ip, dev = 0) # 0 => GPU:0 in Torch

top = tresnet(tip)
op = resnet.layers(ip)

gs = gradient(() -> sum(tresnet(tip)), Flux.params(tresnet))
@test top isa Tensor
@test size(top) == size(op)
@test gs isa Flux.Zygote.Grads
@testset verbose=true "Torch" begin
include("flux_tests.jl")
include("tensor_movement_tests.jl")
include("tensor_nnlib_tests.jl")
end
12 changes: 12 additions & 0 deletions test/tensor_movement_tests.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using Test
using Torch: Tensor, tensor

@testset "Movement" begin
r = rand(Float32, 3,3)
tr = tensor(r, dev = 0)
@test tr isa Tensor
@test tr .* tr isa Tensor

cr = collect(tr)
@test cr isa Array
end
12 changes: 6 additions & 6 deletions test/test_nnlib.jl → test/tensor_nnlib_tests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ using Torch: tensor
test_output = NNlib.depthwiseconv(x, w, pad = (0,0), stride = (1,1 ), dilation = (1, 1))

test_output = Array(test_output)
@test maximum(abs.(test_output - expected_output)) < 10 * eps(Float32)
@test maximum(abs.(test_output - expected_output)) < 1e3 * eps(Float32) # Numerical accuracy adjusted wrt. CI
end
end
end
Expand Down Expand Up @@ -58,7 +58,7 @@ end
test_output = NNlib.conv(x, w, cdims)

test_output = Array(test_output)
@test maximum(abs.(test_output - expected_output)) < 10 * eps(Float32)
@test maximum(abs.(test_output - expected_output)) < 1e6 * eps(Float32) # Numerical accuracy adjusted wrt. CI
end
end
end
Expand Down Expand Up @@ -95,7 +95,7 @@ end
test_output = NNlib.conv(x, w, cdims)

test_output = Array(test_output)
@test maximum(abs.(test_output - expected_output)) < 10 * eps(Float32)
@test maximum(abs.(test_output - expected_output)) < 1e4 * eps(Float32) # Numerical accuracy adjusted wrt. CI
end
end
end
Expand Down Expand Up @@ -138,7 +138,7 @@ end
test_output = NNlib.conv(x, w, cdims)

test_output = Array(test_output)
@test maximum(abs.(test_output - expected_output)) < 10 * eps(Float32)
@test maximum(abs.(test_output - expected_output)) < 1e2 * eps(Float32) # Numerical accuracy adjusted wrt. CI
end
end
end
Expand Down Expand Up @@ -174,7 +174,7 @@ end
test_output = fn(x, pdims)

test_output = Array(test_output)
@test maximum(abs.(test_output - expected_output)) < 10 * eps(Float32)
@test maximum(abs.(test_output - expected_output)) < 1e1 * eps(Float32)
end
end
end
Expand All @@ -198,6 +198,6 @@ end
end

test_output = Array(test_output)
@test maximum(abs.(test_output - expected_output)) < 10 * eps(Float32)
@test maximum(abs.(test_output - expected_output)) < 1e1 * eps(Float32)
end
end