MLX
 
Loading...
Searching...
No Matches
compile.h
Go to the documentation of this file.
1// Copyright © 2023-2024 Apple Inc.
2
3#pragma once
4
5#include "mlx/array.h"
6
7namespace mlx::core {
8
10
12std::function<std::vector<array>(const std::vector<array>&)> compile(
13 std::function<std::vector<array>(const std::vector<array>&)> fun,
14 bool shapeless = false);
15
16std::function<std::vector<array>(const std::vector<array>&)> compile(
17 std::vector<array> (*fun)(const std::vector<array>&),
18 bool shapeless = false);
19
20// Convert capture-less lambdas to function pointers.
21template <
22 typename F,
23 typename = std::enable_if_t<
24 std::is_convertible_v<F, decltype(+std::declval<F>())>>>
25std::function<std::vector<array>(const std::vector<array>&)> compile(
26 F&& f,
27 bool shapeless = false) {
28 return compile(+f, shapeless);
29}
30
36
41
44} // namespace mlx::core
Definition allocator.h:7
void enable_compile()
Globally enable compilation.
void set_compile_mode(CompileMode mode)
Set the compiler mode to the given value.
std::function< std::vector< array >(const std::vector< array > &)> compile(std::function< std::vector< array >(const std::vector< array > &)> fun, bool shapeless=false)
Compile takes a function and returns a compiled function.
void disable_compile()
Globally disable compilation.
CompileMode
Definition compile.h:9
@ disabled
Definition compile.h:9
@ no_simplify
Definition compile.h:9
@ enabled
Definition compile.h:9
@ no_fuse
Definition compile.h:9