/
usr
/
local
/
lib64
/
python3.6
/
site-packages
/
torch
/
include
/
c10
/
core
/
/usr/local/lib64/python3.6/site-packages/torch/include/c10/core
mkdir
upload
Name
Size
Mode
Actions
impl/
-
0755
rm
Allocator.h
8725
0644
edit
dl
rm
AutogradState.h
994
0644
edit
dl
rm
Backend.h
8487
0644
edit
dl
rm
CompileTimeFunctionPointer.h
1677
0644
edit
dl
rm
CopyBytes.h
1229
0644
edit
dl
rm
CPUAllocator.h
2267
0644
edit
dl
rm
DefaultDtype.h
394
0644
edit
dl
rm
DefaultTensorOptions.h
1032
0644
edit
dl
rm
Device.h
5396
0644
edit
dl
rm
DeviceGuard.h
7555
0644
edit
dl
rm
DeviceType.h
2994
0644
edit
dl
rm
DispatchKey.h
18069
0644
edit
dl
rm
DispatchKeySet.h
12951
0644
edit
dl
rm
Event.h
4169
0644
edit
dl
rm
GeneratorImpl.h
3713
0644
edit
dl
rm
GradMode.h
1261
0644
edit
dl
rm
InferenceMode.h
3471
0644
edit
dl
rm
Layout.h
1225
0644
edit
dl
rm
MemoryFormat.h
8571
0644
edit
dl
rm
OptionalRef.h
521
0644
edit
dl
rm
QEngine.h
861
0644
edit
dl
rm
QScheme.h
1562
0644
edit
dl
rm
Scalar.h
6019
0644
edit
dl
rm
ScalarType.h
17073
0644
edit
dl
rm
ScalarTypeToTypeMeta.h
1365
0644
edit
dl
rm
Storage.h
4369
0644
edit
dl
rm
StorageImpl.h
5610
0644
edit
dl
rm
Stream.h
7373
0644
edit
dl
rm
StreamGuard.h
6315
0644
edit
dl
rm
TensorImpl.h
96152
0644
edit
dl
rm
TensorOptions.h
27593
0644
edit
dl
rm
thread_pool.h
2992
0644
edit
dl
rm
UndefinedTensorImpl.h
911
0644
edit
dl
rm
WrapDimMinimal.h
805
0644
edit
dl
rm
Edit:
/usr/local/lib64/python3.6/site-packages/torch/include/c10/core/Backend.h
(8487B)
#pragma once #include <c10/core/DeviceType.h> #include <c10/core/DispatchKey.h> #include <c10/core/DispatchKeySet.h> #include <c10/util/Exception.h> #include <stdexcept> namespace c10 { /** * This legacy enum class defines the set of backends supported by old school, * code generated Type-based ATen. A "backend" in this sense roughly * corresponds to the cartesian product of (device type, layout), but restricted * only to combinations which we actually have kernels for. Backend does NOT * include dtype. * * The reason we are sunsetting this enum class is because it doesn't allow for * open registration; e.g., if you want to add SparseXLA, you'd have to * edit this enum; you wouldn't be able to do it out of tree. DispatchKey is * the replacement for Backend which supports open registration. * * NB: The concept of 'Backend' here disagrees with the notion of backend * exposed to users in torch.backends. Backend here is something like "CPU" * or "SparseCUDA"; backend in torch.backends is something like "MKL" or * "CUDNN". */ enum class Backend { CPU, CUDA, HIP, VE, FPGA, XPU, SparseCPU, SparseCUDA, SparseCsrCPU, SparseCsrCUDA, SparseHIP, SparseVE, SparseXPU, ORT, XLA, Vulkan, Metal, QuantizedCPU, QuantizedCUDA, QuantizedXPU, Undefined, MkldnnCPU, MLC, HPU, Lazy, NumOptions }; static inline Backend dispatchKeyToBackend(DispatchKey t) { if (t == DispatchKey::CPU || t == DispatchKey::AutogradCPU) { return Backend::CPU; } else if (t == DispatchKey::CUDA || t == DispatchKey::AutogradCUDA) { return Backend::CUDA; } else if (t == DispatchKey::HIP) { return Backend::HIP; } else if (t == DispatchKey::VE) { return Backend::VE; } else if (t == DispatchKey::FPGA) { return Backend::FPGA; } else if (t == DispatchKey::ORT) { return Backend::ORT; } else if (t == DispatchKey::XLA || t == DispatchKey::AutogradXLA) { return Backend::XLA; } else if (t == DispatchKey::Lazy || t == DispatchKey::AutogradLazy) { return Backend::Lazy; } else if (t == DispatchKey::MLC || t == DispatchKey::AutogradMLC) { return Backend::MLC; } else if (t == DispatchKey::Vulkan) { return Backend::Vulkan; } else if (t == DispatchKey::Metal) { return Backend::Metal; } else if (t == DispatchKey::SparseCPU) { return Backend::SparseCPU; } else if (t == DispatchKey::SparseCUDA) { return Backend::SparseCUDA; } else if (t == DispatchKey::SparseHIP) { return Backend::SparseHIP; } else if (t == DispatchKey::SparseVE) { return Backend::SparseVE; } else if (t == DispatchKey::SparseCsrCPU) { return Backend::SparseCsrCPU; } else if (t == DispatchKey::SparseCsrCUDA) { return Backend::SparseCsrCUDA; } else if (t == DispatchKey::MkldnnCPU) { return Backend::MkldnnCPU; } else if (t == DispatchKey::QuantizedCPU) { return Backend::QuantizedCPU; } else if (t == DispatchKey::QuantizedCUDA) { return Backend::QuantizedCUDA; } else if (t == DispatchKey::XPU || t == DispatchKey::AutogradXPU) { return Backend::XPU; } else if (t == DispatchKey::SparseXPU) { return Backend::SparseXPU; } else if (t == DispatchKey::QuantizedXPU) { return Backend::QuantizedXPU; } else if (t == DispatchKey::HPU || t == DispatchKey::AutogradHPU) { return Backend::HPU; } else if (t == DispatchKey::Undefined) { return Backend::Undefined; } else { TORCH_CHECK(false, "Unrecognized tensor type ID: ", t); } } static inline DispatchKey backendToDispatchKey(Backend b) { switch (b) { case Backend::CPU: return DispatchKey::CPU; case Backend::CUDA: return DispatchKey::CUDA; case Backend::HIP: return DispatchKey::HIP; case Backend::VE: return DispatchKey::VE; case Backend::FPGA: return DispatchKey::FPGA; case Backend::ORT: return DispatchKey::ORT; case Backend::XLA: return DispatchKey::XLA; case Backend::Lazy: return DispatchKey::Lazy; case Backend::XPU: return DispatchKey::XPU; case Backend::SparseXPU: return DispatchKey::SparseXPU; case Backend::SparseCPU: return DispatchKey::SparseCPU; case Backend::SparseCUDA: return DispatchKey::SparseCUDA; case Backend::SparseHIP: return DispatchKey::SparseHIP; case Backend::SparseVE: return DispatchKey::SparseVE; case Backend::SparseCsrCPU: return DispatchKey::SparseCsrCPU; case Backend::SparseCsrCUDA: return DispatchKey::SparseCsrCUDA; case Backend::MkldnnCPU: return DispatchKey::MkldnnCPU; case Backend::Vulkan: return DispatchKey::Vulkan; case Backend::Metal: return DispatchKey::Metal; case Backend::QuantizedCPU: return DispatchKey::QuantizedCPU; case Backend::QuantizedCUDA: return DispatchKey::QuantizedCUDA; case Backend::Undefined: return DispatchKey::Undefined; case Backend::MLC: return DispatchKey::MLC; case Backend::HPU: return DispatchKey::HPU; default: throw std::runtime_error("Unknown backend"); } } static inline DeviceType backendToDeviceType(Backend b) { switch (b) { case Backend::CPU: return DeviceType::CPU; case Backend::CUDA: return DeviceType::CUDA; case Backend::HIP: return DeviceType::HIP; case Backend::VE: return DeviceType::VE; case Backend::FPGA: return DeviceType::FPGA; case Backend::ORT: return DeviceType::ORT; case Backend::XLA: return DeviceType::XLA; case Backend::Lazy: return DeviceType::Lazy; case Backend::SparseCPU: return DeviceType::CPU; case Backend::SparseCUDA: return DeviceType::CUDA; case Backend::SparseHIP: return DeviceType::HIP; case Backend::SparseVE: return DeviceType::VE; case Backend::SparseCsrCPU: return DeviceType::CPU; case Backend::SparseCsrCUDA: return DeviceType::CUDA; case Backend::XPU: case Backend::SparseXPU: case Backend::QuantizedXPU: return DeviceType::XPU; case Backend::MkldnnCPU: case Backend::QuantizedCPU: return DeviceType::CPU; case Backend::QuantizedCUDA: return DeviceType::CUDA; case Backend::Vulkan: return DeviceType::Vulkan; case Backend::Metal: return DeviceType::Metal; case Backend::MLC: return DeviceType::MLC; case Backend::HPU: return DeviceType::HPU; case Backend::Undefined: TORCH_CHECK(false, "Undefined backend is not a valid device type"); default: TORCH_CHECK(false, "Unknown backend"); } } // TODO: This probably shouldn't actually be static inline static inline const char* toString(Backend b) { switch (b) { case Backend::CPU: return "CPU"; case Backend::CUDA: return "CUDA"; case Backend::HIP: return "HIP"; case Backend::VE: return "VE"; case Backend::FPGA: return "FPGA"; case Backend::XPU: return "XPU"; case Backend::ORT: return "ORT"; case Backend::XLA: return "XLA"; case Backend::Lazy: return "Lazy"; case Backend::MLC: return "MLC"; case Backend::SparseCPU: return "SparseCPU"; case Backend::SparseCUDA: return "SparseCUDA"; case Backend::SparseHIP: return "SparseHIP"; case Backend::SparseVE: return "SparseVE"; case Backend::SparseXPU: return "SparseXPU"; case Backend::SparseCsrCPU: return "SparseCsrCPU"; case Backend::SparseCsrCUDA: return "SparseCsrCUDA"; case Backend::MkldnnCPU: return "MkldnnCPU"; case Backend::Vulkan: return "Vulkan"; case Backend::Metal: return "Metal"; case Backend::QuantizedCPU: return "QuantizedCPU"; case Backend::QuantizedCUDA: return "QuantizedCUDA"; case Backend::QuantizedXPU: return "QuantizedXPU"; case Backend::HPU: return "HPU"; default: return "UNKNOWN_BACKEND"; } } static inline bool isSparse(Backend b) { switch (b) { case Backend::SparseXPU: case Backend::SparseCPU: case Backend::SparseCUDA: case Backend::SparseHIP: case Backend::SparseVE: return true; default: return false; } } static inline bool isSparseCsr(Backend b) { switch (b) { case Backend::SparseCsrCPU: case Backend::SparseCsrCUDA: return true; default: return false; } } } // namespace c10
Save
cmd:
run