Skip to content

Commit

Permalink
upgrade MLStyle (#81)
Browse files Browse the repository at this point in the history
* upgrade MLStyle

* update project.toml
  • Loading branch information
GiggleLiu committed May 24, 2022
1 parent f11d0a5 commit a80e991
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
6 changes: 3 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name = "NiLang"
uuid = "ab4ef3a6-0b42-11ea-31f6-e34652774712"
authors = ["JinGuo Liu", "thautwarm"]
version = "0.9.2"
version = "0.9.3"

[deps]
FixedPointNumbers = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
LogarithmicNumbers = "aa2f6b4e-9042-5d33-9679-40d3a6b85899"
MatchCore = "5dd3f0b1-72a9-48ad-ae6e-79f673da005f"
MLStyle = "d8e11817-5142-5d16-987a-aa16d5891078"
NiLangCore = "575d3204-02a4-11ea-3f62-238caa8bf11e"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
Expand All @@ -16,10 +16,10 @@ TupleTools = "9d95972d-f1c8-5527-a6e0-b4b365fa01f6"
[compat]
FixedPointNumbers = "0.6, 0.7, 0.8"
LogarithmicNumbers = "0.4, 1.0"
MatchCore = "0.1"
NiLangCore = "0.10.1"
Reexport = "0.2, 1.0"
TupleTools = "1.2"
MLStyle = "0.4"
julia = "1.3"

[extras]
Expand Down
2 changes: 1 addition & 1 deletion src/autodiff/autodiff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module AD

using ..NiLang
using NiLangCore
using MatchCore, TupleTools
using MLStyle, TupleTools

import ..NiLang: ROT, IROT, SWAP,
chfield, value, NoGrad, INC, DEC, HADAMARD,
Expand Down
6 changes: 3 additions & 3 deletions src/autodiff/vars.jl
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ Base.show(io::IO, ::MIME"plain/text", gv::GVar) = Base.show(io, gv)
Base.isfinite(x::GVar) = isfinite(x.x)
# interfaces

_replace_opmx_callable(ex) = @smatch ex begin
_replace_opmx_callable(ex) = @match ex begin
:(:+=($f)) => :(PlusEq($f))
:(:-=($f)) => :(MinusEq($f))
:(:*=($f)) => :(MulEq($f))
Expand All @@ -206,12 +206,12 @@ end
Mark `f(args...)` as having no gradients.
"""
macro nograd(ex)
@smatch ex begin
@match ex begin
:($f($(args...))) => begin
f2 = _replace_opmx_callable(f)
newargs = []
for arg in args
push!(newargs, @smatch arg begin
push!(newargs, @match arg begin
:($x::GVar) => :($x.x)
:($x::VecGVar) => :($x.x)
:($x::GVar{$tp}) => :($x.x)
Expand Down
10 changes: 5 additions & 5 deletions src/macros.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using MatchCore, NiLang
using MLStyle, NiLang
export alloc, @auto_alloc, @auto_expand

"""
Expand All @@ -13,7 +13,7 @@ macro auto_alloc(ex)
end

function auto_alloc(ex)
@smatch ex begin
@match ex begin
:($f($out, $(args...))) => begin
Expr(:block, :($out $alloc($f, $(args...))), ex)
end
Expand Down Expand Up @@ -48,10 +48,10 @@ function auto_expand(ex)
end

function auto_expand!(ex, exprs, sym=nothing, addnew=true)
@smatch ex begin
@match ex begin
:($f($(args...))) => begin
for (i, arg) in enumerate(args)
@smatch arg begin
@match arg begin
:($_{$(_...)}($(_...))) => begin
auto_expand!(arg, exprs, nothing, false)
end
Expand Down Expand Up @@ -79,4 +79,4 @@ end

macro auto_expand(ex)
esc(auto_expand(ex))
end
end

0 comments on commit a80e991

Please sign in to comment.