-
Notifications
You must be signed in to change notification settings - Fork 3
/
flambeau.nimble
98 lines (82 loc) · 3.12 KB
/
flambeau.nimble
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# Flambeau
# Copyright (c) 2020 Mamy André-Ratsimbazafy
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at http://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at http://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.
packageName = "flambeau"
version = "0.0.3"
author = "Mamy André-Ratsimbazafy"
description = "A state-of-the-art tensor and deep learning backend on CPU, Nvidia Cuda, AMD HIP, OpenCL, Vulkan, OpenGL"
license = "MIT or Apache License 2.0"
installDirs = @["vendor"]
### Dependencies
requires "nim >= 1.9.3"
requires "zip"
requires "cppstl >= 0.3.0"
requires "fusion"
backend = "cpp"
import os
when defined(nimdistros):
import distros
foreignDep "libjpeg"
foreignDep "libpng"
foreignDep "ffmpeg"
foreignDep "gtest" # TODO remove this dependency (due to io/decoder/sync_decoder_test.cpp)
### Build
task build_torchvision, "Build the dependency torchvision":
when defined(windows):
const libName = "torchvision.dll"
elif defined(macosx):
const libName = "libtorchvision.dylib"
else:
const libName = "libtorchvision.so"
const libBuilder = "flambeau/install/torchvision_build.nim"
switch("out", "vendor/" & libName)
switch("define", "danger")
switch("app", "lib")
switch("noMain")
switch("gc", "none")
setCommand "cpp", libBuilder
task test_raw, "Execute RawTensor tests ":
let skipGcArc= @["./test_nn.nim"]
withDir "tests" / "raw":
for fstr in listFiles("."):
if fstr.endsWith(".nim") and fstr.startsWith("." / "test_"):
echo "Running ", fstr
if fstr notin skipGcArc:
selfExec("cpp -r -d:release " & fstr)
selfExec("cpp -r --gc:arc -d:release " & fstr)
else:
echo "Skipping --gc:arc for ", fstr
selfExec("cpp -r -d:release " & fstr)
task test_tensor, "Execute Tensor[T] tests ":
withDir "tests" / "tensor":
for fstr in listFiles("."):
if fstr.endsWith(".nim") and fstr.startsWith("." / "test_"):
echo "Running ", fstr
selfExec("cpp -r -d:release " & fstr)
selfExec("cpp -r --gc:arc -d:release " & fstr)
task test, "Execute all tests ":
testRawTask()
testTensorTask()
task runExamples, "Run all examples":
withDir "examples" / "proof_of_concepts":
for fstr in listFiles("."):
if fstr.endsWith(".nim") and fstr.startsWith("." / "poc"):
echo "Running ", fstr
selfExec("cpp -r -d:release " & fstr)
selfExec("cpp -r --gc:arc -d:release " & fstr)
task install_libtorch, "Download and install libtorch":
const libInstaller = "flambeau" / "install" / "torch_installer.nim"
# Using -b:cpp r avoir creating a local binary
selfExec("-b:cpp r --skipParentCfg:on " & libInstaller)
task setup, "Setup repo":
if not dirExists "vendor" / "vision" / "torchvision" / "csrc":
exec("git submodule update --init --recursive")
if not dirExists "vendor" / "libtorch":
install_libtorchTask()
after install:
setupTask()
after develop:
setupTask()