|
|
#pragma once
|
|
|
|
|
|
#include <c10/core/Allocator.h>
|
|
|
#include <c10/util/Exception.h>
|
|
|
#include <c10/util/Registry.h>
|
|
|
|
|
|
#include <ATen/detail/AcceleratorHooksInterface.h>
|
|
|
|
|
|
|
|
|
namespace at {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct TORCH_API HIPHooksInterface : AcceleratorHooksInterface {
|
|
|
|
|
|
|
|
|
~HIPHooksInterface() override = default;
|
|
|
|
|
|
void init() const override {
|
|
|
TORCH_CHECK(false, "Cannot initialize HIP without ATen_hip library.");
|
|
|
}
|
|
|
|
|
|
const Generator& getDefaultGenerator(
|
|
|
[[maybe_unused]] DeviceIndex device_index = -1) const override {
|
|
|
TORCH_CHECK(false, "Cannot initialize HIP without ATen_hip library.");
|
|
|
}
|
|
|
|
|
|
virtual bool hasHIP() const {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
virtual c10::DeviceIndex current_device() const {
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
bool isPinnedPtr(const void* ) const override {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
Allocator* getPinnedMemoryAllocator() const override {
|
|
|
TORCH_CHECK(false, "Pinned memory requires HIP.");
|
|
|
}
|
|
|
|
|
|
virtual int getNumGPUs() const {
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
bool hasPrimaryContext(DeviceIndex ) const override {
|
|
|
TORCH_CHECK(false, "Cannot check primary context without ATen_hip library.");
|
|
|
}
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
struct TORCH_API HIPHooksArgs {};
|
|
|
|
|
|
TORCH_DECLARE_REGISTRY(HIPHooksRegistry, HIPHooksInterface, HIPHooksArgs);
|
|
|
#define REGISTER_HIP_HOOKS(clsname) \
|
|
|
C10_REGISTER_CLASS(HIPHooksRegistry, clsname, clsname)
|
|
|
|
|
|
namespace detail {
|
|
|
TORCH_API const HIPHooksInterface& getHIPHooks();
|
|
|
|
|
|
}
|
|
|
}
|
|
|
|