File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -422,6 +422,13 @@ void addOrtValueMethods(pybind11::module& m) {
422422 .def (" numpy" , [](const OrtValue* ml_value) -> py::object {
423423 ORT_ENFORCE (ml_value->IsTensor (), " Only OrtValues that are Tensors are convertible to Numpy objects" );
424424 const auto & device = ml_value->Get <Tensor>().Location ().device ;
425+ #ifdef _MSC_VER
426+ // The switch statement may only contain the 'default' label. In such a case, the MSVC compiler
427+ // will warn about it, and since the warnings are treated as errors, the compilation will break.
428+ // Below pragmas turn off warning generation for this switch only.
429+ #pragma warning(push)
430+ #pragma warning(disable : 4065)
431+ #endif
425432 switch (device.Vendor ()) {
426433#ifdef USE_CUDA
427434 case OrtDevice::VendorIds::NVIDIA:
@@ -440,9 +447,13 @@ void addOrtValueMethods(pybind11::module& m) {
440447 case OrtDevice::VendorIds::AMD:
441448 return GetPyObjFromTensor (*ml_value, nullptr , GetMIGraphXToHostMemCpyFunction (device));
442449#endif
443- default :
450+ default :
444451 return GetPyObjFromTensor (*ml_value, nullptr , nullptr );
445- } })
452+ }
453+ #ifdef _MSC_VER
454+ #pragma warning(pop)
455+ #endif
456+ })
446457#if defined(ENABLE_DLPACK)
447458 .def (" to_dlpack" , [](OrtValue* ort_value) -> py::object { return py::reinterpret_steal<py::object>(ToDlpack (*ort_value)); },
448459 " Returns a DLPack representing the tensor. This method does not copy the pointer shape, "
You can’t perform that action at this time.
0 commit comments