2023-12-01 03:12:53 +08:00
|
|
|
// Copyright © 2023 Apple Inc.
|
|
|
|
|
2023-11-30 02:30:41 +08:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace mlx::core {
|
|
|
|
|
|
|
|
struct Device {
|
|
|
|
enum class DeviceType {
|
|
|
|
cpu,
|
|
|
|
gpu,
|
|
|
|
};
|
|
|
|
|
|
|
|
static constexpr DeviceType cpu = DeviceType::cpu;
|
|
|
|
static constexpr DeviceType gpu = DeviceType::gpu;
|
|
|
|
|
2024-06-13 13:06:49 +08:00
|
|
|
Device(DeviceType type, int index = 0) : type(type), index(index) {}
|
2023-11-30 02:30:41 +08:00
|
|
|
|
|
|
|
DeviceType type;
|
|
|
|
int index;
|
|
|
|
};
|
|
|
|
|
|
|
|
const Device& default_device();
|
|
|
|
|
|
|
|
void set_default_device(const Device& d);
|
|
|
|
|
|
|
|
bool operator==(const Device& lhs, const Device& rhs);
|
|
|
|
bool operator!=(const Device& lhs, const Device& rhs);
|
|
|
|
|
2025-05-01 00:08:17 +08:00
|
|
|
bool is_available(const Device& d);
|
|
|
|
|
2023-11-30 02:30:41 +08:00
|
|
|
} // namespace mlx::core
|