Skip to content

Commit

Permalink
backport Julia patches to v1.5.x (apache#16142)
Browse files Browse the repository at this point in the history
* julia: bump window prebult binary version to v1.5.0 (apache#15608)

- remove file REQUIRE, it's stale for Pkg3.jl

* update julia install doc (apache#15609)

* julia: fix `mx.forward` kwargs checking (apache#16138)

close dmlc/MXNet.jl#431

* Julia: add API docs back (apache#16348)

`ndarray` and `symbolic-node` have been refactored by splitting into a
few files in commits ed83071 and 36a3cb8, but the corresponding
document setting for MXNet.jl is not updated yet.

List all split source files into the `at_autodoc` setting.

Also refer to the `at_autodoc` setting in `julia/docs/src/api/optimizer.md`
  • Loading branch information
iblislin authored Dec 17, 2019
1 parent c981848 commit 3f449aa
Show file tree
Hide file tree
Showing 7 changed files with 115 additions and 17 deletions.
64 changes: 62 additions & 2 deletions docs/install/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,22 @@ Indicate your preferred configuration. Then, follow the customized commands to i
</div>
</div>
</div>

<!-- Linux Julia Options -->

<div class="linux macos windows">
<div class="julia">
<div class="cpu gpu">
<div class="btn-group opt-group" role="group">
<button type="button" class="btn btn-default environs opt active">Pkg</button>
<button type="button" class="btn btn-default environs opt">Build from Source</button>
</div>
</div>
</div>
</div>

<hr>

<!-- END - Main Menu -->

<!-- START - Linux Python CPU Installation Instructions -->
Expand Down Expand Up @@ -582,8 +597,23 @@ You can use the Maven packages defined in the following dependency to include MX
<div class="julia">
<div class="cpu gpu">
</br>
<div class="pkg">

```
]add MXNet#v1.5.0
```

Install the latest release:

```
]add MXNet
```

</div>
<div class="build-from-source">
Refer to the <a href="ubuntu_setup.html#install-the-mxnet-package-for-julia">Julia section of the MXNet Ubuntu installation guide</a>.

</div>
</div> <!-- End of cpu gpu -->
</div> <!-- End of julia -->

Expand All @@ -593,7 +623,7 @@ Refer to the <a href="ubuntu_setup.html#install-the-mxnet-package-for-julia">Jul
Refer to the <a href="ubuntu_setup.html#install-the-mxnet-package-for-perl">Perl section of the MXNet Ubuntu installation guide</a>.

</div> <!-- End of cpu gpu -->
</div> <!-- End of julia -->
</div> <!-- End of perl -->



Expand Down Expand Up @@ -884,8 +914,23 @@ Not available at this time. <br>
<div class="julia">
<div class="cpu gpu">
</br>
<div class="pkg">

```
]add MXNet#v1.5.0
```

Install the latest release:

```
]add MXNet
```

</div>
<div class="build-from-source">
Refer to the <a href="osx_setup.html#install-the-mxnet-package-for-julia">Julia section of the MXNet macOS installation guide</a>.

</div>
</div> <!-- End of cpu gpu -->
</div> <!-- End of julia -->

Expand Down Expand Up @@ -1226,8 +1271,23 @@ MXNet-Java for Windows is not yet available.
<div class="julia">
<div class="cpu gpu">
</br>
<div class="pkg">

```
]add MXNet#v1.5.0
```

Install the latest release:

```
]add MXNet
```

</div>
<div class="build-from-source">
Refer to the <a href="windows_setup.html#install-the-mxnet-package-for-julia">Julia section of the MXNet Windows installation guide</a>.

</div>
</div> <!-- End of cpu gpu -->
</div> <!-- End of julia -->

Expand All @@ -1237,7 +1297,7 @@ Refer to the <a href="windows_setup.html#install-the-mxnet-package-for-julia">Ju
Refer to the <a href="windows_setup.html#install-the-mxnet-package-for-perl">Perl section of the MXNet Windows installation guide</a>.

</div> <!-- End of cpu gpu -->
</div> <!-- End of julia -->
</div> <!-- End of perl -->

<div class="cpp">
<div class="cpu gpu">
Expand Down
6 changes: 0 additions & 6 deletions julia/REQUIRE

This file was deleted.

16 changes: 10 additions & 6 deletions julia/deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ using LinearAlgebra
################################################################################
libmxnet_detected = false
libmxnet_curr_ver = get(ENV, "MXNET_COMMIT", "master")
curr_win = "20180211" # v1.1.0
curr_win = "20190608" # v1.5.0

if haskey(ENV, "MXNET_HOME")
MXNET_HOME = ENV["MXNET_HOME"]
Expand Down Expand Up @@ -119,21 +119,25 @@ if !libmxnet_detected
base_url = "https://github.com/yajiedesign/mxnet/releases/download/weekly_binary_build_v2/prebuildbase_win10_x64_vc14_v2.7z"

if libmxnet_curr_ver == "master"
_cmd = "{
[System.Net.ServicePointManager]::SecurityProtocol='tls12';
Invoke-WebRequest -Uri 'https://api.github.com/repos/yajiedesign/mxnet/releases/latest'
-OutFile 'mxnet.json'}"
# download_cmd uses powershell 2, but we need powershell 3 to do this
run(`powershell -NoProfile -Command Invoke-WebRequest -Uri "https://api.github.com/repos/yajiedesign/mxnet/releases/latest" -OutFile "mxnet.json"`)
run(`powershell -NoProfile -Command $_cmd`)
curr_win = JSON.parsefile("mxnet.json")["tag_name"]
@info("Can't use MXNet master on Windows, using latest binaries from $curr_win.")
end
# TODO: Get url from JSON.
name = "mxnet_x64_vc14_$(HAS_CUDA ? "gpu" : "cpu").7z"
# TODO: detect cuda version and select corresponding url.
name = "mxnet_x64_$(HAS_CUDA ? "vc141_gpu_cu101" : "vc14_cpu").7z"
package_url = "https://github.com/yajiedesign/mxnet/releases/download/$(curr_win)/$(curr_win)_$(name)"

exe7z = joinpath(JULIA_HOME, "7z.exe")
exe7z = joinpath(Sys.BINDIR, "7z.exe")

run(download_cmd(package_url, "mxnet.7z"))
# this command will create the dir "usr\\lib"
run(`$exe7z x mxnet.7z build lib -y -ousr`)
run(`cmd /c copy "usr\\build\\*.dll" "usr\\lib"`)
run(`$exe7z e mxnet.7z *\\build\\* *\\lib\\* -y -ousr\\lib`)

run(download_cmd(base_url, "mxnet_base.7z"))
run(`$exe7z x mxnet_base.7z -y -ousr`)
Expand Down
18 changes: 17 additions & 1 deletion julia/docs/src/api/ndarray.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,21 @@ In the following example `y` can be a `Real` value or another `NDArray`

```@autodocs
Modules = [MXNet.mx]
Pages = ["ndarray.jl"]
Pages = [
"ndarray.jl",
"ndarray/activation.jl",
"ndarray/arithmetic.jl",
"ndarray/array.jl",
"ndarray/autoimport.jl",
"ndarray/comparison.jl",
"ndarray/context.jl",
"ndarray/io.jl",
"ndarray/linalg.jl",
"ndarray/reduction.jl",
"ndarray/remap.jl",
"ndarray/show.jl",
"ndarray/statistic.jl",
"ndarray/trig.jl",
"ndarray/type.jl",
]
```
11 changes: 10 additions & 1 deletion julia/docs/src/api/symbolic-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,14 @@

```@autodocs
Modules = [MXNet.mx]
Pages = ["symbolic-node.jl"]
Pages = [
"symbolic-node.jl",
"symbolic-node/arithmetic.jl",
"symbolic-node/array.jl",
"symbolic-node/autodiff.jl",
"symbolic-node/io.jl",
"symbolic-node/op.jl",
"symbolic-node/show.jl",
"symbolic-node/type.jl",
]
```
2 changes: 1 addition & 1 deletion julia/src/executor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ end

function forward(self::Executor; is_train::Bool = false, kwargs...)
for (k,v) in kwargs
@assert(k self.arg_dict, "Unknown argument $k")
@assert(k keys(self.arg_dict), "Unknown argument $k")
@assert(isa(v, NDArray), "Keyword argument $k must be an NDArray")
copy!(self.arg_dict[k], v)
end
Expand Down
15 changes: 15 additions & 0 deletions julia/test/unittest/bind.jl
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,26 @@ function test_arithmetic()
end
end

function test_forward()
# forward with data keyword argument
x = @var x
y = x .+ 42

A = 1:5
B = A .+ 42

e = bind(y, args = Dict(:x => NDArray(24:28)))
z = forward(e, x = NDArray(A))[1]

@test copy(z) == collect(B)
end

################################################################################
# Run tests
################################################################################
@testset "Bind Test" begin
test_arithmetic()
test_forward()
end

end
Expand Down

0 comments on commit 3f449aa

Please sign in to comment.