@@ -46,8 +46,38 @@ inline infini::ops::DataType toInfiniOpsDtype(DataType dtype) {
4646}
4747
4848inline infini::ops::Device toInfiniOpsDevice (const Device &device) {
49- INFINICORE_ASSERT (device.getType () == Device::Type::NVIDIA );
50- return infini::ops::Device{infini::ops::Device::Type::kNvidia , static_cast <int >(device.getIndex ())};
49+ switch (device.getType ()) {
50+ case Device::Type::NVIDIA :
51+ return infini::ops::Device{infini::ops::Device::Type::kNvidia , static_cast <int >(device.getIndex ())};
52+ case Device::Type::METAX :
53+ return infini::ops::Device{infini::ops::Device::Type::kMetax , static_cast <int >(device.getIndex ())};
54+ case Device::Type::MOORE :
55+ return infini::ops::Device{infini::ops::Device::Type::kMoore , static_cast <int >(device.getIndex ())};
56+ case Device::Type::ILUVATAR :
57+ return infini::ops::Device{infini::ops::Device::Type::kIluvatar , static_cast <int >(device.getIndex ())};
58+ default :
59+ throw std::runtime_error (" InfiniOps backend does not support this device type." );
60+ }
61+ }
62+
63+ inline bool isSupportedDevice (Device::Type device_type) {
64+ switch (device_type) {
65+ case Device::Type::NVIDIA :
66+ case Device::Type::METAX :
67+ case Device::Type::MOORE :
68+ case Device::Type::ILUVATAR :
69+ return true ;
70+ default :
71+ return false ;
72+ }
73+ }
74+
75+ template <typename Dispatcher, typename Function>
76+ void registerSupportedDevices (Dispatcher &dispatcher, Function function) {
77+ dispatcher.registerDevice (Device::Type::NVIDIA , function);
78+ dispatcher.registerDevice (Device::Type::METAX , function);
79+ dispatcher.registerDevice (Device::Type::MOORE , function);
80+ dispatcher.registerDevice (Device::Type::ILUVATAR , function);
5181}
5282
5383struct TensorMeta {
0 commit comments