Skip to content

Commit

Permalink
Refactor compile and test buffer donation (#126)
Browse files Browse the repository at this point in the history
* Format code

* Delete `CompiledModule` and rename function to `compile_mlir!`

* Refactor out MLIR `Context` preparation before `compile_mlir!` call

* Refactor `compile` into smaller `codegen_*` and `compile_*` methods

* Test preserved arguments in buffer donation tests

* Fix rebase on top of #123

* Fix test

* Add some comments

* Add compiler hints to `traced_getfield`

* Refactor `create_result`

* Wrap "Compiler.jl" into a `Compiler` module

* Refactor `compile` calls for `@compile` macrocalls

* Fix imports

* Fix `@compile` tests on broadcast

* Refactor `@compile` calls for broadcasting syntax

* Stop printing MLIR in `show` method for `TracedRArray`

Segfaults if MLIR has not been correctly generated

* Fix call to compiled function in Flux test

* Import `compile` symbol to top-level

* Fix function compilation in Lux test

* Revert refactor to `@compile` on Lux test

* Another fix for the Lux test

* Revert refactor to `@compile` on benchmarks
  • Loading branch information
mofeing authored Sep 27, 2024
1 parent aefba5a commit ea88cb0
Show file tree
Hide file tree
Showing 13 changed files with 397 additions and 291 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function sinsum_add(x, y)
return sum(sin.(x) .+ y)
end

f=Reactant.compile(sinsum_add, (input1,input2))
f= @compile sinsum_add(input1,input2)

# one can now run the program
f(input1, input2)
Expand Down
6 changes: 3 additions & 3 deletions benchmark/benchmarks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ SUITE["comptime"]["basics"]["Basic cos"] = @benchmarkable Reactant.compile(cos,
SUITE["comptime"]["lux neural networks"] = BenchmarkGroup()

for depth in [11, 13, 16, 19]
SUITE["comptime"]["lux neural networks"]["vgg$depth"] = @benchmarkable begin
Reactant.compile(vgg, (x, ps_concrete, st_concrete))
end setup = begin
SUITE["comptime"]["lux neural networks"]["vgg$depth"] = @benchmarkable Reactant.compile(
vgg, (x, ps_concrete, st_concrete)
) setup = begin
vgg = Vision.VGG($depth; pretrained=false, batchnorm=false)
ps, st = Lux.setup(Random.default_rng(), vgg)
ps_concrete = Reactant.to_rarray(ps)
Expand Down
Loading

0 comments on commit ea88cb0

Please sign in to comment.