GithubHelp home page GithubHelp logo

Comments (4)

maleadt avatar maleadt commented on July 17, 2024 1

With the inference spoofing heuristics from JuliaLang/julia#24852 / #25 this gets quite a bit further (the final Overdub call wrapping the typeassert is gone), but still fails to infer pointerref. I reduced it a little more:

code_warntype(unsafe_load, Tuple{Ptr{Float32}})


using Cassette
Cassette.@context Ctx

code_warntype(Cassette.overdub(Ctx, unsafe_load), Tuple{Ptr{Float32}})

Original IR:

Variables:
  p::Ptr{Float32}

Body:
  begin
      # meta: location pointer.jl unsafe_load 105
      SSAValue(2) = (Base.pointerref)(p::Ptr{Float32}, 1, 1)::Float32
      # meta: pop location
      return SSAValue(2)
  end::Float32

Overdubbed:

Variables:
  o<optimized out>
  x1::Ptr{Float32}

Body:
  begin
      # stripped the meta nodes and useless goto's
      SSAValue(202) = (typeassert)(1, Int64)::Int64
      SSAValue(332) = (pointerref)(x1::Ptr{Float32}, SSAValue(202), 1)::Any
      return SSAValue(332)
  end::Any

from cassette.jl.

vtjnash avatar vtjnash commented on July 17, 2024

Yes, I think it remains to be seen how we can make it possible for inference to avoid triggering the limit trigger rules.

from cassette.jl.

maleadt avatar maleadt commented on July 17, 2024

Which inference limit/rule is this running into? Can it be resolved with custom InferenceParams?

from cassette.jl.

jrevels avatar jrevels commented on July 17, 2024

closed by #41

julia> using Cassette

julia> Cassette.@context Ctx

julia> ctx = Ctx()
Ctx{Cassette.Unused,0x0000000000006ba5,Cassette.Unused,Nothing}(Cassette.Unused(), Val{0x0000000000006ba5}(), Cassette.Unused(), nothing)

julia> foo(ptr::Ptr{T}, i) where {T} = Base.unsafe_load(ptr, i)::T
foo (generic function with 1 method)

julia> x = rand(Float32,1);

julia> ptr = pointer(x);

julia> ctx = Ctx();^C

julia> @code_warntype Cassette.overdub_execute(ctx, foo, ptr, 1)
Variables:
  ctx<optimized out>
  args::Tuple{typeof(foo),Ptr{Float32},Int64}
  output<optimized out>

Body:
  begin
      Core.SSAValue(17) = (Core.getfield)(args::Tuple{typeof(foo),Ptr{Float32},Int64}, 2)::Ptr{Float32}
      Core.SSAValue(18) = (Core.getfield)(args::Tuple{typeof(foo),Ptr{Float32},Int64}, 3)::Int64
      Core.SSAValue(35) = (Base.pointerref)(Core.SSAValue(17), Core.SSAValue(18), 1)::Float32
      return Core.SSAValue(35)
  end::Float32

from cassette.jl.

Related Issues (20)

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.