Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
julia: fix mx.forward kwargs checking (#16138)
Browse files Browse the repository at this point in the history
  • Loading branch information
iblislin committed Sep 12, 2019
1 parent aa3677d commit 6559b80
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
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 6559b80

Please sign in to comment.