From c279d9b652f77b5c12937768986db8ffad7fd2f4 Mon Sep 17 00:00:00 2001 From: Ben Lawrence Date: Wed, 24 Jan 2024 10:42:23 +0000 Subject: [PATCH 1/3] [INSTX-3280] Add missing header for macOS Without this TORCH_VERSION_MAJOR isn't defined so it defaults to 0, meaning that we always took the CPU path. --- dorado/modbase/ModBaseCaller.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/dorado/modbase/ModBaseCaller.cpp b/dorado/modbase/ModBaseCaller.cpp index 5faf8114..4fa1cfb1 100644 --- a/dorado/modbase/ModBaseCaller.cpp +++ b/dorado/modbase/ModBaseCaller.cpp @@ -12,6 +12,7 @@ #endif #include #include +#include #include From a687e1937b7c1d826ec66a7985675f80f095d06e Mon Sep 17 00:00:00 2001 From: Ben Lawrence Date: Wed, 24 Jan 2024 10:43:21 +0000 Subject: [PATCH 2/3] [INSTX-3280] Add warning to check for use of undefined macros This should catch issues like this again (at least on non-Windows). --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c3b7e515..4a5548b5 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,7 +44,7 @@ function(enable_warnings_as_errors TARGET_NAME) _CRT_SECURE_NO_WARNINGS ) else() - target_compile_options(${TARGET_NAME} PRIVATE -Wall -Werror -Wextra) + target_compile_options(${TARGET_NAME} PRIVATE -Wall -Werror -Wextra -Wundef) endif() endfunction() From d75776ec9cea2bbe8a2396e22632adfa8a731e62 Mon Sep 17 00:00:00 2001 From: Ben Lawrence Date: Wed, 24 Jan 2024 11:15:46 +0000 Subject: [PATCH 3/3] [INSTX-3280] Guard metal usage behind __APPLE__ Also drop the torch version check since we only support torch2 there. --- dorado/modbase/ModBaseCaller.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/dorado/modbase/ModBaseCaller.cpp b/dorado/modbase/ModBaseCaller.cpp index 4fa1cfb1..a98dd1c2 100644 --- a/dorado/modbase/ModBaseCaller.cpp +++ b/dorado/modbase/ModBaseCaller.cpp @@ -12,7 +12,6 @@ #endif #include #include -#include #include @@ -73,17 +72,10 @@ ModBaseCaller::ModBaseCaller(const std::vector& model_pat if (device == "cpu") { // no slow_conv2d_cpu for type Half, need to use float32 m_options = at::TensorOptions().device(torch::kCPU).dtype(torch::kFloat32); +#ifdef __APPLE__ } else if (device == "metal") { -#if TORCH_VERSION_MAJOR < 2 - // no metal implementation yet, force to cpu - auto torchMetalBackend = torch::kCPU; - auto torchMetalDtype = torch::kFloat32; - spdlog::debug("- no metal backend available for modified basecalling, defaulting to CPU."); -#else - auto torchMetalBackend = torch::kMPS; - auto torchMetalDtype = torch::kFloat16; + m_options = at::TensorOptions().device(torch::kMPS).dtype(torch::kFloat16); #endif - m_options = at::TensorOptions().device(torchMetalBackend).dtype(torchMetalDtype); } else { m_options = at::TensorOptions().device(device).dtype(torch::kFloat16); }