2023-12-01 03:12:53 +08:00
|
|
|
// Copyright © 2023 Apple Inc.
|
|
|
|
|
2023-11-30 02:52:08 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <pybind11/pybind11.h>
|
2023-12-27 18:06:55 +08:00
|
|
|
#include <optional>
|
|
|
|
#include <string>
|
2023-11-30 02:52:08 +08:00
|
|
|
#include <unordered_map>
|
|
|
|
#include <variant>
|
2024-01-20 06:06:05 +08:00
|
|
|
#include "mlx/io.h"
|
2023-11-30 02:52:08 +08:00
|
|
|
|
|
|
|
namespace py = pybind11;
|
|
|
|
using namespace mlx::core;
|
|
|
|
|
2024-01-20 06:06:05 +08:00
|
|
|
using LoadOutputTypes = std::variant<
|
|
|
|
array,
|
|
|
|
std::unordered_map<std::string, array>,
|
|
|
|
std::pair<
|
|
|
|
std::unordered_map<std::string, array>,
|
|
|
|
std::unordered_map<std::string, MetaData>>>;
|
2023-11-30 02:52:08 +08:00
|
|
|
|
2023-12-27 18:06:55 +08:00
|
|
|
std::unordered_map<std::string, array> mlx_load_safetensor_helper(
|
|
|
|
py::object file,
|
|
|
|
StreamOrDevice s);
|
2024-01-08 07:16:51 +08:00
|
|
|
void mlx_save_safetensor_helper(py::object file, py::dict d);
|
2023-12-27 18:06:55 +08:00
|
|
|
|
2024-01-20 06:06:05 +08:00
|
|
|
std::pair<
|
|
|
|
std::unordered_map<std::string, array>,
|
|
|
|
std::unordered_map<std::string, MetaData>>
|
|
|
|
mlx_load_gguf_helper(py::object file, StreamOrDevice s);
|
|
|
|
void mlx_save_gguf_helper(
|
2024-01-11 05:22:48 +08:00
|
|
|
py::object file,
|
2024-01-20 06:06:05 +08:00
|
|
|
py::dict d,
|
|
|
|
std::optional<py::dict> m);
|
2024-01-11 05:22:48 +08:00
|
|
|
|
2024-01-20 06:06:05 +08:00
|
|
|
LoadOutputTypes mlx_load_helper(
|
2023-12-27 18:06:55 +08:00
|
|
|
py::object file,
|
|
|
|
std::optional<std::string> format,
|
2024-01-20 06:06:05 +08:00
|
|
|
bool return_metadata,
|
2023-12-27 18:06:55 +08:00
|
|
|
StreamOrDevice s);
|
2024-01-08 07:16:51 +08:00
|
|
|
void mlx_save_helper(py::object file, array a);
|
2023-11-30 02:52:08 +08:00
|
|
|
void mlx_savez_helper(
|
|
|
|
py::object file,
|
|
|
|
py::args args,
|
|
|
|
const py::kwargs& kwargs,
|
2023-12-22 06:08:24 +08:00
|
|
|
bool compressed = false);
|