FluxML / IRTools.jl

Mike's Little Intermediate Representation
MIT License
111 stars 36 forks source link

Help Julia do type narrowing #47

Closed MikeInnes closed 4 years ago

MikeInnes commented 4 years ago
using LinearAlgebra, IRTools, BenchmarkTools
using IRTools: IR, @dynamo

@dynamo function pass(f, x)
  ir = IR(f, x)
  return ir
end

A = rand(100, 100)
julia> @btime tr($A)
  77.351 ns (0 allocations: 0 bytes)
49.604880105076276

julia> @btime pass(tr, $A)
  78.095 ns (0 allocations: 0 bytes)
49.604880105076276

cc @roger-luo

Roger-luo commented 4 years ago

Thanks for the quick fix! I could try to wrap my spmd package now