mlx/mlx/graph_utils.h
Cheng 28fcd2b519
Add missing && when forwarding args (#894)
Without the && args would be copied and perfect forwarding won't work.

Also add template utils to make sure the function only forwards array
and not vector<array>.
2024-03-25 14:55:54 -07:00

30 lines
811 B
C++

// Copyright © 2023 Apple Inc.
#pragma once
#include "mlx/array.h"
namespace mlx::core {
struct NodeNamer {
std::unordered_map<std::uintptr_t, std::string> names;
const std::string& get_name(const array& x);
};
void print_graph(std::ostream& os, const std::vector<array>& outputs);
template <typename... Arrays, typename = enable_for_arrays_t<Arrays...>>
void print_graph(std::ostream& os, Arrays&&... outputs) {
print_graph(os, std::vector<array>{std::forward<Arrays>(outputs)...});
}
void export_to_dot(std::ostream& os, const std::vector<array>& outputs);
template <typename... Arrays, typename = enable_for_arrays_t<Arrays...>>
void export_to_dot(std::ostream& os, Arrays&&... outputs) {
export_to_dot(os, std::vector<array>{std::forward<Arrays>(outputs)...});
}
} // namespace mlx::core