ndarray: implement rdiv#292
Conversation
e.g. ```julia 1 ./ mx.NDArray(Float32[1 2; 3 4]) ```
Codecov Report
@@ Coverage Diff @@
## master #292 +/- ##
=========================================
Coverage ? 69.52%
=========================================
Files ? 25
Lines ? 1913
Branches ? 0
=========================================
Hits ? 1330
Misses ? 583
Partials ? 0
Continue to review full report at Codecov.
|
|
|
||
| Elementwise Divide a scalar by an `NDArray`. | ||
| """ | ||
| /(arg0 :: Real, arg :: NDArray) = div(arg0, arg) |
There was a problem hiding this comment.
I am not a fan of this since it it no longer Julia semantics
There was a problem hiding this comment.
hmm ... I misunderstood that julia 0.5 need it for broadcasting.
(maybe I should not write code in early morning :p
There was a problem hiding this comment.
Oh... we still need it because of Julia 0.6's broadcasting fusion
julia> expand(:(1 ./ mx.zeros(4)))
:($(Expr(:thunk, CodeInfo(:(begin
$(Expr(:thunk, CodeInfo(:(begin
global ##5#6
const ##5#6
$(Expr(:composite_type, Symbol("##5#6"), :((Core.svec)()), :((Core.svec)()), :(Core.Function), :((Core.svec)()), false, 0))
return
end))))
$(Expr(:method, false, :((Core.svec)((Core.svec)(##5#6, Core.Any), (Core.svec)())), CodeInfo(:(begin
return 1 / #temp#
end)), false))
#5 = $(Expr(:new, Symbol("##5#6")))
SSAValue(0) = #5
SSAValue(1) = ((Core.getfield)(mx, :zeros))(4)
return (Base.broadcast)(SSAValue(0), SSAValue(1))
end)))))
e.g.