Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Cassette julia tokai

64 views

Published on

julia東海

Published in: Engineering
  • Be the first to comment

  • Be the first to like this

Cassette julia tokai

  1. 1. 2019/5/11 title localhost:52895/?print-pdf-now#/ 1/22 Cassette.jl
  2. 2. 2019/5/11 title localhost:52895/?print-pdf-now#/ 2/22 CASSETTE.JLCASSETTE.JL CONTEXUAL DISPATCHCONTEXUAL DISPATCH
  3. 3. 2019/5/11 title localhost:52895/?print-pdf-now#/ 3/22 CASSETTE SLIDECASSETTE SLIDE CASSETTE GITHUBCASSETTE GITHUB CASSETTE.JL: OVERDUB YOUR JULIA CODECASSETTE.JL: OVERDUB YOUR JULIA CODE ENGINEERING JULIA FOR SPEEDENGINEERING JULIA FOR SPEED https://slides.com/peter-cheng/cassettejl#/0/2 https://github.com/jrevels/Cassette.jl https://www.youtube.com/watch?v=lyX-isPDS2M https://www.youtube.com/watch?v=XWIZ_dCO6X8
  4. 4. 2019/5/11 title localhost:52895/?print-pdf-now#/ 4/22 CASSETTCASSETT ??
  5. 5. 2019/5/11 title localhost:52895/?print-pdf-now#/ 5/22 CASSETTECASSETTE
  6. 6. 2019/5/11 title localhost:52895/?print-pdf-now#/ 6/22 (e.g. control flow, literals, bindings ) BF ! Promotion
  7. 7. 2019/5/11 title localhost:52895/?print-pdf-now#/ 7/22 Julia Julia JIT
  8. 8. 2019/5/11 title localhost:52895/?print-pdf-now#/ 8/22 ... v1.x Julia
  9. 9. 2019/5/11 title localhost:52895/?print-pdf-now#/ 9/22 julia compile loop
  10. 10. 2019/5/11 title localhost:52895/?print-pdf-now#/ 10/22 ## Julia Runtime #function call hypotmul(x::Vector{T},args...) where T = (x .* hypot(args hypotmul([3.4],2,2.7) # type signature sig = Tuple{typeof(hypotmul), Vector{Float64},Int, Float6   # Methods dispatch   _, sparams, meth = Base._methods_by_ftype(sig, 1, typemax
  11. 11. 2019/5/11 title localhost:52895/?print-pdf-now#/ 11/22 #Type Inference -> @generated Cassett 置 換   Core.Compiler.uncompressed_ast(meth)   # Inferd methods   code_typed(hypotmul, (Vector{Float64},Int,Float64),optimi
  12. 12. 2019/5/11 title localhost:52895/?print-pdf-now#/ 12/22 # optimization code_typed(hypotmul, (Vector{Float64}, Int,Float64),optimize=true)   # llvm @code_llvm hypotmul([3,4,2,2.7])   # native @code_native hypotmul([3,4,2,2.7])
  13. 13. 2019/5/11 title localhost:52895/?print-pdf-now#/ 13/22 OVERDUBINGOVERDUBING
  14. 14. 2019/5/11 title localhost:52895/?print-pdf-now#/ 14/22   using Cassette   Cassette.@context Ctx   Cassette.overdub(Ctx(), /, 1, 2)   @code_lowered 1/2   @code_lowered Cassette.overdub(Ctx(), /, 1, 2)
  15. 15. 2019/5/11 title localhost:52895/?print-pdf-now#/ 15/22 logging   using Cassette using Cassette: @context, @overdub   @context PrintCtx   Cassette.prehook(::PrintCtx, f, args...) = println(f   @overdub(PrintCtx(), sin(1))
  16. 16. 2019/5/11 title localhost:52895/?print-pdf-now#/ 16/22 overdub recurse memoize   fib(x) = x < 3 ? 1 : fib(x-2) + fib(x-1)   using Cassette: Cassette, @context, overdub, recurse   Cassette.@context MemoizeCtx
  17. 17. 2019/5/11 title localhost:52895/?print-pdf-now#/ 17/22 memoize   function Cassette.overdub(ctx::MemoizeCtx, ::typeof(fib) get(ctx.metadata, x) do result = recurse(ctx, fib, x)#fib(18) + fib(19) ctx.metadata[x] = result return result end end   Cassette.overdub(MemoizeCtx(metadata=Dict{Int,Int}()), fi
  18. 18. 2019/5/11 title localhost:52895/?print-pdf-now#/ 18/22 Code Info
  19. 19. 2019/5/11 title localhost:52895/?print-pdf-now#/ 19/22 info = @code_lowered sin(7) ref = Cassette.refrection((typeof(sin),Float64))
  20. 20. 2019/5/11 title localhost:52895/?print-pdf-now#/ 20/22 REFLECTIONREFLECTION function traced_new(::Type{<:TraceCtx}, reflection::Casse ir = reflection.code_info Cassette.replace_match!(x -> Base.Meta.isexpr(x, :cal return Expr(:call, __new__, x.args...) end return ir end
  21. 21. 2019/5/11 title localhost:52895/?print-pdf-now#/ 21/22 YOTA(AUTOMATICH DIFF)YOTA(AUTOMATICH DIFF) !!
  22. 22. 2019/5/11 title localhost:52895/?print-pdf-now#/ 22/22

×