Comments (9)
Ok, I have not looked at the internals of Mjolnir but the older issues point to no support for Unions, so on the face of it it seems to be a bigger job that defining more primitives?
from mjolnir.jl.
@zenna If you annotate the arg type in the function def, does the same issue occur? Would try myself but away from computer.
from mjolnir.jl.
@femtomc Yes. Perhaps this is the same issue as #7 ? Rewriting it to use a while loop does not produce the same error.
from mjolnir.jl.
That's likely because the lowered IR is much simpler for the while
version:
function m(n)
i = 0
while i <= n
nothing
i += 1
end
end
1: (%1, %2)
br 2 (0)
2: (%3)
%4 = %3 <= %2
br 4 unless %4
br 3
3:
%5 = Main.nothing
%6 = %3 + 1
br 2 (%6)
4:
return nothing
compared to
1: (%1, %2)
%3 = 1:%2
%4 = Base.iterate(%3)
%5 = %4 === nothing
%6 = Base.not_int(%5)
br 3 unless %6
br 2 (%4)
2: (%7)
%8 = Core.getfield(%7, 1)
%9 = Core.getfield(%7, 2)
%10 = Main.nothing
%11 = Base.iterate(%3, %9)
%12 = %11 === nothing
%13 = Base.not_int(%12)
br 3 unless %13
br 2 (%11)
3:
return nothing
from mjolnir.jl.
Right, and in particular the type of %4
will be a Union
from mjolnir.jl.
I'm trying to fill in the primitives in Basic
right now to see if I can get it working.
from mjolnir.jl.
Yep - think you're spot on.
from mjolnir.jl.
Although this particular issue seems to be one which is easily fixed without primitive definitions or handling unions.
The IR which causes an issue is:
1: (%1 :: const(first), %2 :: const(2:3))
%3 = $(QuoteNode(Int64)) :: Union{}
%4 = Base.getproperty(%2, :start) :: Union{}
%5 = Base.convert(%3, %4) :: Union{}
return %5
and it's just because Mjolnir
can't handle the $
expression.
from mjolnir.jl.
@zenna Here ya go:
1: (%1 :: const(m), %2 :: Int64)
%3 = (Colon())(1, %2) :: UnitRange{Int64}
%4 = (getfield)(%3, :start) :: Int64
%5 = (getfield)(%3, :stop) :: Int64
%6 = (>)(%4, %5) :: Bool
br 2 unless %6
br 3
2:
br 3
3:
return nothing
I just added https://github.com/femtomc/Mjolnir.jl/blob/ad46e7cc08286153ee4b099a076ac492dd1eb45b/src/infer.jl#L199 to allow QuoteNode
instances to fall through.
But don't ask me if I know if this is the right fix. At least it solves some issue.
from mjolnir.jl.
Related Issues (20)
- simple for loop tries to trace through a dispatch with Union HOT 5
- `@inbounds` HOT 3
- Ambiguous meaning of @trace f(Int) HOT 5
- Sytanx sugar for automatically finding the return type in @abstract HOT 4
- Tracing through setfield! throws error
- Macro Hygiene issue? HOT 1
- Recursion and type inference HOT 3
- Organize test suite
- inline not defined HOT 1
- Cut a new tag with updated IRTools compat HOT 5
- Stabilize Mjolnir use inside of dynamos HOT 5
- simple function triggers an unexpected dimension mismatch error HOT 2
- Infer misses some branches
- Missing Key
- Minimum example of transpiling
- deepcopy of Modules not supported HOT 1
- Running tracked code as anon functions HOT 1
- Multiple dispatch fails in @trace
- self-test fails "Tracing Error: deepcopy of Modules not supported" HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mjolnir.jl.