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

julia: fix mx.forward kwargs checking #16138

Merged
merged 1 commit into from
Sep 12, 2019
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
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