Code Monkey home page Code Monkey logo

jitrench.jl's Introduction

abap34

Tokyo Institute of Technology, Department of Computer Science, B3

For more information about me, please visit abap34.com

jitrench.jl's People

Contributors

abap34 avatar github-actions[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

jitrench.jl's Issues

literal_pow doesn't work when broadcast occur

Currently, the function which contain in _func_to_jt_struct in src/arr/broadcast.jl
are supported broadcast.

_func_to_jt_struct = Dict(
    (+) => Add, 
    (-) => Sub, 
    (*) => Mul,
    (/) => Div,
    (^) => Pow,
    (sin) => Sin,
    (cos) => Cos,
    (tan) => Tan,
    (log) => Log,
)

so, Variable(arr) .^ 2 is thought to work, but it will be an error.

julia> x = [1, 2, 3]
3-element Vector{Int64}:
 1
 2
 3

julia> x .^ 2
3-element Vector{Int64}:
 1
 4
 9

julia> using  JITrench
[ Info: Precompiling JITrench [573e55e6-eb53-4bcf-a884-6670806246ed]

julia> Variable([1, 2, 3]) .^ 2
ERROR: MethodError: no method matching length(::Variable)
Closest candidates are:
  length(::Union{Base.KeySet, Base.ValueIterator}) at abstractdict.jl:58
  length(::Union{LinearAlgebra.Adjoint{T, S}, LinearAlgebra.Transpose{T, S}} where {T, S}) at /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/adjtrans.jl:195
  length(::Union{DataStructures.OrderedRobinDict, DataStructures.RobinDict}) at /Users/yuchi_ymgc/.julia/packages/DataStructures/ixwFs/src/ordered_robin_dict.jl:86
  ...
Stacktrace:
 [1] _similar_for(c::UnitRange{Int64}, #unused#::Type{Any}, itr::Variable, #unused#::Base.HasLength)
   @ Base ./array.jl:575
 [2] _collect(cont::UnitRange{Int64}, itr::Variable, #unused#::Base.HasEltype, isz::Base.HasLength)
   @ Base ./array.jl:608
 [3] collect(itr::Variable)
   @ Base ./array.jl:602
 [4] broadcastable(x::Variable)
   @ Base.Broadcast ./broadcast.jl:682
 [5] broadcasted(f::Function, arg1::Function, arg2::Variable, args::Val{2})
   @ Base.Broadcast ./broadcast.jl:1313
 [6] top-level scope
   @ REPL[5]:1

The cause of the error seems that the specifications of Julia, the replace of pow when exp is literal.

julia> f() = Variable([1, 2, 3]) .^ 2
f (generic function with 1 method)

julia> @code_lowered f()
CodeInfo(
1%1 = Base.vect(1, 2, 3)
│   %2 = Main.Variable(%1)
│   %3 = Core.apply_type(Base.Val, 2)
│   %4 = (%3)()
│   %5 = Base.broadcasted(Base.literal_pow, Main.:^, %2, %4)
│   %6 = Base.materialize(%5)
└──      return %6
)

It should be fixed as soon as possible.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.