mirror of
https://github.com/ml-explore/mlx.git
synced 2025-12-16 01:49:05 +08:00
Remove static initializers (#2059)
* Remove static initializers in device.cpp, load.cpp, pocketfft.h * Remove static initializer InTracing::trace_stack * Remove static initializer of CompilerCache cache * Revert changes in pocketfft.h * Remove duplicate private section of thread_pool()
This commit is contained in:
@@ -22,19 +22,19 @@ std::vector<array> vmap_replace(
|
||||
struct InTracing {
|
||||
explicit InTracing(bool dynamic = false, bool grad = false) {
|
||||
grad_counter += grad;
|
||||
trace_stack.push_back({dynamic, grad});
|
||||
trace_stack().push_back({dynamic, grad});
|
||||
}
|
||||
~InTracing() {
|
||||
grad_counter -= trace_stack.back().second;
|
||||
trace_stack.pop_back();
|
||||
grad_counter -= trace_stack().back().second;
|
||||
trace_stack().pop_back();
|
||||
}
|
||||
|
||||
static bool in_tracing() {
|
||||
return !trace_stack.empty();
|
||||
return !trace_stack().empty();
|
||||
}
|
||||
static bool in_dynamic_tracing() {
|
||||
// compile is always and only the outer-most transform
|
||||
return in_tracing() && trace_stack.front().first;
|
||||
return in_tracing() && trace_stack().front().first;
|
||||
}
|
||||
|
||||
static bool in_grad_tracing() {
|
||||
@@ -43,7 +43,7 @@ struct InTracing {
|
||||
|
||||
private:
|
||||
static int grad_counter;
|
||||
static std::vector<std::pair<char, char>> trace_stack;
|
||||
static std::vector<std::pair<char, char>>& trace_stack();
|
||||
};
|
||||
|
||||
struct RetainGraph {
|
||||
|
||||
Reference in New Issue
Block a user