diff --git a/Source/Cmlx/include-framework/mlx-c-export.h b/Source/Cmlx/include-framework/mlx-c-export.h index 96ab788a..4b4a6e62 100644 --- a/Source/Cmlx/include-framework/mlx-c-export.h +++ b/Source/Cmlx/include-framework/mlx-c-export.h @@ -66,6 +66,7 @@ int mlx_imported_function_apply_kwargs( const mlx_imported_function xfunc, const mlx_vector_array args, const mlx_map_string_to_array kwargs); +int mlx_export_to_dot_file(const char* path, mlx_array output); /**@}*/ #ifdef __cplusplus diff --git a/Source/Cmlx/include/mlx/c/export.h b/Source/Cmlx/include/mlx/c/export.h index 52cb2835..3a91ac44 100644 --- a/Source/Cmlx/include/mlx/c/export.h +++ b/Source/Cmlx/include/mlx/c/export.h @@ -66,6 +66,7 @@ int mlx_imported_function_apply_kwargs( const mlx_imported_function xfunc, const mlx_vector_array args, const mlx_map_string_to_array kwargs); +int mlx_export_to_dot_file(const char* path, mlx_array output); /**@}*/ #ifdef __cplusplus diff --git a/Source/MLX/GraphExport.swift b/Source/MLX/GraphExport.swift new file mode 100644 index 00000000..e89adca7 --- /dev/null +++ b/Source/MLX/GraphExport.swift @@ -0,0 +1,8 @@ +import Cmlx + +/// Export the computation graph of an array to a DOT file for visualization. +public func exportGraphToDot(path: String, output: MLXArray) { + path.withCString { cPath in + mlx_export_to_dot_file(cPath, output.ctx) + } +}