consolidate ATen/test/dispatch_key_set_test.cpp with rest of DispatchKeySet tests (#151697)

Doesn't seem to be a reason to have two test files for this.

Differential Revision: [D73274020](https://our.internmc.facebook.com/intern/diff/D73274020/)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/151697
Approved by: https://github.com/Skylion007
ghstack dependencies: #151626, #151627, #151628, #151629, #151630
This commit is contained in:
Scott Wolchok 2025-04-20 09:23:28 -07:00 committed by PyTorch MergeBot
parent 9c2ac2b876
commit 8eb21dffa9
3 changed files with 10 additions and 20 deletions

View File

@ -17,7 +17,6 @@ list(APPEND ATen_CPU_TEST_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/cpu_generator_test.cpp ${CMAKE_CURRENT_SOURCE_DIR}/cpu_generator_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cpu_profiling_allocator_test.cpp ${CMAKE_CURRENT_SOURCE_DIR}/cpu_profiling_allocator_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/cpu_rng_test.cpp ${CMAKE_CURRENT_SOURCE_DIR}/cpu_rng_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dispatch_key_set_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/dlconvertor_test.cpp ${CMAKE_CURRENT_SOURCE_DIR}/dlconvertor_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/extension_backend_test.cpp ${CMAKE_CURRENT_SOURCE_DIR}/extension_backend_test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/half_test.cpp ${CMAKE_CURRENT_SOURCE_DIR}/half_test.cpp

View File

@ -1,19 +0,0 @@
#include <gtest/gtest.h>
#include <ATen/ATen.h>
#include <c10/core/DispatchKeySet.h>
#include <vector>
using at::DispatchKey;
using at::DispatchKeySet;
TEST(DispatchKeySetTest, TestGetRuntimeDispatchKeySet) {
// Check if getRuntimeDispatchKeySet and runtimeDispatchKeySetHas agree.
for (auto dk1: DispatchKeySet(DispatchKeySet::FULL)) {
auto dks = getRuntimeDispatchKeySet(dk1);
for (auto dk2: DispatchKeySet(DispatchKeySet::FULL)) {
ASSERT_EQ(dks.has(dk2), runtimeDispatchKeySetHas(dk1, dk2));
}
}
}

View File

@ -443,3 +443,13 @@ TEST(DispatchKeySet, TestFunctionalityDispatchKeyToString) {
seen_strings.insert(res); seen_strings.insert(res);
} }
} }
TEST(DispatchKeySet, TestGetRuntimeDispatchKeySet) {
// Check if getRuntimeDispatchKeySet and runtimeDispatchKeySetHas agree.
for (auto dk1 : DispatchKeySet(DispatchKeySet::FULL)) {
auto dks = getRuntimeDispatchKeySet(dk1);
for (auto dk2 : DispatchKeySet(DispatchKeySet::FULL)) {
ASSERT_EQ(dks.has(dk2), runtimeDispatchKeySetHas(dk1, dk2));
}
}
}