mirror of
https://github.com/zebrajr/pytorch.git
synced 2025-12-06 12:20:52 +01:00
Disable avoid-non-const-global-variables lint check (#62008)
Summary: As GoogleTest `TEST` macro is non-compliant with it as well as `DEFINE_DISPATCH` All changes but the ones to `.clang-tidy` are generated using following script: ``` for i in `find . -type f -iname "*.c*" -or -iname "*.h"|xargs grep cppcoreguidelines-avoid-non-const-global-variables|cut -f1 -d:|sort|uniq`; do sed -i "/\/\/ NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)/d" $i; done ``` Pull Request resolved: https://github.com/pytorch/pytorch/pull/62008 Reviewed By: driazati, r-barnes Differential Revision: D29838584 Pulled By: malfet fbshipit-source-id: 1b2f8602c945bd4ce50a9bfdd204755556e31d13
This commit is contained in:
parent
260198d42c
commit
a9b0a921d5
|
|
@ -9,6 +9,7 @@ bugprone-*,
|
|||
-bugprone-reserved-identifier,
|
||||
cppcoreguidelines-*,
|
||||
-cppcoreguidelines-avoid-magic-numbers,
|
||||
-cppcoreguidelines-avoid-non-const-global-variables,
|
||||
-cppcoreguidelines-interfaces-global-init,
|
||||
-cppcoreguidelines-macro-usage,
|
||||
-cppcoreguidelines-owning-memory,
|
||||
|
|
|
|||
|
|
@ -235,7 +235,6 @@ Allocator* getCPUAllocator() {
|
|||
// means the allow_tf32 flags are overrided and tf32 is force disabled
|
||||
// override_allow_tf32_flag = false
|
||||
// means the original allow_tf32 flags are followed
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
thread_local bool override_allow_tf32_flag = false;
|
||||
|
||||
NoTF32Guard::NoTF32Guard() {
|
||||
|
|
|
|||
|
|
@ -53,7 +53,6 @@ struct MapInfo {
|
|||
std::atomic<int> refcount;
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
const std::string unknown_filename = "filename not specified";
|
||||
#ifdef _WIN32
|
||||
const std::string unknown_eventname = "eventname not specified";
|
||||
|
|
|
|||
|
|
@ -23,11 +23,9 @@ namespace at {
|
|||
namespace {
|
||||
// used with _set_in_parallel_region to mark master thread
|
||||
// as in parallel region while executing parallel primitives
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
thread_local bool in_parallel_region_ = false;
|
||||
|
||||
// thread number (task_id) set by parallel primitive
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
thread_local int thread_num_ = 0;
|
||||
|
||||
void _set_in_parallel_region(bool in_region) {
|
||||
|
|
@ -60,7 +58,6 @@ const int CONSUMED = -2;
|
|||
// - NOT_SET - pool not initialized, user value is not set
|
||||
// - positive value - pool not initialized, user value set
|
||||
// - CONSUMED - pool is initialized
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
std::atomic<int> num_intraop_threads{NOT_SET};
|
||||
|
||||
int _num_pool_threads(int nthreads) {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ const int CONSUMED = -2;
|
|||
// (CONSUMED - thread pool is initialized)
|
||||
// or
|
||||
// NOT_SET -> CONSUMED
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
std::atomic<int> num_interop_threads{NOT_SET};
|
||||
|
||||
// thread pool global instance is hidden,
|
||||
|
|
@ -46,7 +45,6 @@ std::shared_ptr<TaskThreadPoolBase> create_c10_threadpool(
|
|||
|
||||
} // namespace
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
C10_REGISTER_CREATOR(ThreadPoolRegistry, C10, create_c10_threadpool);
|
||||
|
||||
void set_num_interop_threads(int nthreads) {
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ namespace at {
|
|||
namespace sequence_number {
|
||||
|
||||
namespace {
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
thread_local uint64_t sequence_nr_ = 0;
|
||||
} // namespace
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
namespace at {
|
||||
namespace impl {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
thread_local int64_t VmapMode_current_vmap_level = 0;
|
||||
|
||||
int64_t VmapMode::current_vmap_level() {
|
||||
|
|
|
|||
|
|
@ -47,14 +47,12 @@ namespace {
|
|||
// directly against incoming TensorImpl*s.
|
||||
using weakref_type = c10::weak_intrusive_ptr<TensorImpl, UndefinedTensorImpl>;
|
||||
using val_type = std::tuple<weakref_type, Tensor>;
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
thread_local std::unordered_map<TensorImpl*, val_type> cached_casts;
|
||||
|
||||
// nesting tracks the nesting depth of the Python-side context manager.
|
||||
// When the autocast context manager exits to a nesting level that's outside
|
||||
// any instance of autocast (which should occur at the end of each forward pass)
|
||||
// it calls clear_cache() to ensure cached Tensors don't leak outside the autocasting region.
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
thread_local int nesting = 0;
|
||||
|
||||
// autocast_cpu_dtype is the lower_precision_fp used by AutocastCPU.
|
||||
|
|
|
|||
|
|
@ -79,10 +79,7 @@ static void GenerateSizes2d(benchmark::internal::Benchmark* b) {
|
|||
}
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
BENCHMARK(quantize_per_channel_2d)->Apply(GenerateSizes2d);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
BENCHMARK(quantize_per_channel_4d_contiguous)->Apply(GenerateSizes4d);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
BENCHMARK(quantize_per_channel_4d_channels_last)->Apply(GenerateSizes4d);
|
||||
BENCHMARK_MAIN();
|
||||
|
|
|
|||
|
|
@ -82,6 +82,5 @@ static void GenerateSizes(benchmark::internal::Benchmark* b) {
|
|||
}
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
BENCHMARK(stateful_conv1d)->Apply(GenerateSizes);
|
||||
BENCHMARK_MAIN();
|
||||
|
|
|
|||
|
|
@ -26,6 +26,5 @@ static void GenerateSizes(benchmark::internal::Benchmark* b) {
|
|||
}
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
BENCHMARK(tensor_add)->Apply(GenerateSizes);
|
||||
BENCHMARK_MAIN();
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
namespace at {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
static Symbol kWildcard = Symbol::dimname("*");
|
||||
|
||||
std::ostream& operator<<(std::ostream& out, const Dimname& dimname) {
|
||||
|
|
|
|||
|
|
@ -3,73 +3,62 @@
|
|||
|
||||
using namespace c10;
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenEmptyList_whenCallingEmpty_thenReturnsTrue) {
|
||||
List<string> list;
|
||||
EXPECT_TRUE(list.empty());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenNonemptyList_whenCallingEmpty_thenReturnsFalse) {
|
||||
List<string> list({"3"});
|
||||
EXPECT_FALSE(list.empty());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenEmptyList_whenCallingSize_thenReturnsZero) {
|
||||
List<string> list;
|
||||
EXPECT_EQ(0, list.size());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenNonemptyList_whenCallingSize_thenReturnsNumberOfElements) {
|
||||
List<string> list({"3", "4"});
|
||||
EXPECT_EQ(2, list.size());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenNonemptyList_whenCallingClear_thenIsEmpty) {
|
||||
List<string> list({"3", "4"});
|
||||
list.clear();
|
||||
EXPECT_TRUE(list.empty());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenCallingGetWithExistingPosition_thenReturnsElement) {
|
||||
List<string> list({"3", "4"});
|
||||
EXPECT_EQ("3", list.get(0));
|
||||
EXPECT_EQ("4", list.get(1));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenCallingGetWithNonExistingPosition_thenThrowsException) {
|
||||
List<string> list({"3", "4"});
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-goto,hicpp-avoid-goto)
|
||||
EXPECT_THROW(list.get(2), std::out_of_range);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenCallingExtractWithExistingPosition_thenReturnsElement) {
|
||||
List<string> list({"3", "4"});
|
||||
EXPECT_EQ("3", list.extract(0));
|
||||
EXPECT_EQ("4", list.extract(1));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenCallingExtractWithExistingPosition_thenListElementBecomesInvalid) {
|
||||
List<string> list({"3", "4"});
|
||||
list.extract(0);
|
||||
EXPECT_EQ("", list.get(0));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenCallingExtractWithNonExistingPosition_thenThrowsException) {
|
||||
List<string> list({"3", "4"});
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-goto,hicpp-avoid-goto)
|
||||
EXPECT_THROW(list.extract(2), std::out_of_range);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenCallingCopyingSetWithExistingPosition_thenChangesElement) {
|
||||
List<string> list({"3", "4"});
|
||||
string value = "5";
|
||||
|
|
@ -78,7 +67,6 @@ TEST(ListTest_IValueBasedList, whenCallingCopyingSetWithExistingPosition_thenCha
|
|||
EXPECT_EQ("5", list.get(1));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenCallingMovingSetWithExistingPosition_thenChangesElement) {
|
||||
List<string> list({"3", "4"});
|
||||
string value = "5";
|
||||
|
|
@ -87,7 +75,6 @@ TEST(ListTest_IValueBasedList, whenCallingMovingSetWithExistingPosition_thenChan
|
|||
EXPECT_EQ("5", list.get(1));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenCallingCopyingSetWithNonExistingPosition_thenThrowsException) {
|
||||
List<string> list({"3", "4"});
|
||||
string value = "5";
|
||||
|
|
@ -95,7 +82,6 @@ TEST(ListTest_IValueBasedList, whenCallingCopyingSetWithNonExistingPosition_then
|
|||
EXPECT_THROW(list.set(2, value), std::out_of_range);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenCallingMovingSetWithNonExistingPosition_thenThrowsException) {
|
||||
List<string> list({"3", "4"});
|
||||
string value = "5";
|
||||
|
|
@ -103,14 +89,12 @@ TEST(ListTest_IValueBasedList, whenCallingMovingSetWithNonExistingPosition_thenT
|
|||
EXPECT_THROW(list.set(2, std::move(value)), std::out_of_range);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenCallingAccessOperatorWithExistingPosition_thenReturnsElement) {
|
||||
List<string> list({"3", "4"});
|
||||
EXPECT_EQ("3", static_cast<string>(list[0]));
|
||||
EXPECT_EQ("4", static_cast<string>(list[1]));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenAssigningToAccessOperatorWithExistingPosition_thenSetsElement) {
|
||||
List<string> list({"3", "4", "5"});
|
||||
list[1] = "6";
|
||||
|
|
@ -119,7 +103,6 @@ TEST(ListTest_IValueBasedList, whenAssigningToAccessOperatorWithExistingPosition
|
|||
EXPECT_EQ("5", list.get(2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenAssigningToAccessOperatorFromAccessOperator_thenSetsElement) {
|
||||
List<string> list({"3", "4", "5"});
|
||||
list[1] = list[2];
|
||||
|
|
@ -128,7 +111,6 @@ TEST(ListTest_IValueBasedList, whenAssigningToAccessOperatorFromAccessOperator_t
|
|||
EXPECT_EQ("5", list.get(2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenSwappingFromAccessOperator_thenSwapsElements) {
|
||||
List<string> list({"3", "4", "5"});
|
||||
swap(list[1], list[2]);
|
||||
|
|
@ -137,14 +119,12 @@ TEST(ListTest_IValueBasedList, whenSwappingFromAccessOperator_thenSwapsElements)
|
|||
EXPECT_EQ("4", list.get(2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenCallingAccessOperatorWithNonExistingPosition_thenThrowsException) {
|
||||
List<string> list({"3", "4"});
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-goto,hicpp-avoid-goto)
|
||||
EXPECT_THROW(list[2], std::out_of_range);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenCallingInsertOnIteratorWithLValue_thenInsertsElement) {
|
||||
List<string> list({"3", "4", "6"});
|
||||
string v = "5";
|
||||
|
|
@ -153,7 +133,6 @@ TEST(ListTest_IValueBasedList, whenCallingInsertOnIteratorWithLValue_thenInserts
|
|||
EXPECT_EQ("5", list.get(2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenCallingInsertOnIteratorWithRValue_thenInsertsElement) {
|
||||
List<string> list({"3", "4", "6"});
|
||||
string v = "5";
|
||||
|
|
@ -162,7 +141,6 @@ TEST(ListTest_IValueBasedList, whenCallingInsertOnIteratorWithRValue_thenInserts
|
|||
EXPECT_EQ("5", list.get(2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenCallingInsertWithLValue_thenReturnsIteratorToNewElement) {
|
||||
List<string> list({"3", "4", "6"});
|
||||
string v = "5";
|
||||
|
|
@ -170,7 +148,6 @@ TEST(ListTest_IValueBasedList, whenCallingInsertWithLValue_thenReturnsIteratorTo
|
|||
EXPECT_EQ(list.begin() + 2, result);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenCallingInsertWithRValue_thenReturnsIteratorToNewElement) {
|
||||
List<string> list({"3", "4", "6"});
|
||||
string v = "5";
|
||||
|
|
@ -178,7 +155,6 @@ TEST(ListTest_IValueBasedList, whenCallingInsertWithRValue_thenReturnsIteratorTo
|
|||
EXPECT_EQ(list.begin() + 2, result);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenCallingEmplaceWithLValue_thenInsertsElement) {
|
||||
List<string> list({"3", "4", "6"});
|
||||
string v = "5";
|
||||
|
|
@ -187,7 +163,6 @@ TEST(ListTest_IValueBasedList, whenCallingEmplaceWithLValue_thenInsertsElement)
|
|||
EXPECT_EQ("5", list.get(2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenCallingEmplaceWithRValue_thenInsertsElement) {
|
||||
List<string> list({"3", "4", "6"});
|
||||
string v = "5";
|
||||
|
|
@ -196,7 +171,6 @@ TEST(ListTest_IValueBasedList, whenCallingEmplaceWithRValue_thenInsertsElement)
|
|||
EXPECT_EQ("5", list.get(2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenCallingEmplaceWithConstructorArg_thenInsertsElement) {
|
||||
List<string> list({"3", "4", "6"});
|
||||
list.emplace(list.begin() + 2, "5"); // const char* is a constructor arg to std::string
|
||||
|
|
@ -204,7 +178,6 @@ TEST(ListTest_IValueBasedList, whenCallingEmplaceWithConstructorArg_thenInsertsE
|
|||
EXPECT_EQ("5", list.get(2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenCallingPushBackWithLValue_ThenInsertsElement) {
|
||||
List<string> list;
|
||||
string v = "5";
|
||||
|
|
@ -213,7 +186,6 @@ TEST(ListTest_IValueBasedList, whenCallingPushBackWithLValue_ThenInsertsElement)
|
|||
EXPECT_EQ("5", list.get(0));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenCallingPushBackWithRValue_ThenInsertsElement) {
|
||||
List<string> list;
|
||||
string v = "5";
|
||||
|
|
@ -222,7 +194,6 @@ TEST(ListTest_IValueBasedList, whenCallingPushBackWithRValue_ThenInsertsElement)
|
|||
EXPECT_EQ("5", list.get(0));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenCallingEmplaceBackWithLValue_ThenInsertsElement) {
|
||||
List<string> list;
|
||||
string v = "5";
|
||||
|
|
@ -231,7 +202,6 @@ TEST(ListTest_IValueBasedList, whenCallingEmplaceBackWithLValue_ThenInsertsEleme
|
|||
EXPECT_EQ("5", list.get(0));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenCallingEmplaceBackWithRValue_ThenInsertsElement) {
|
||||
List<string> list;
|
||||
string v = "5";
|
||||
|
|
@ -240,7 +210,6 @@ TEST(ListTest_IValueBasedList, whenCallingEmplaceBackWithRValue_ThenInsertsEleme
|
|||
EXPECT_EQ("5", list.get(0));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenCallingEmplaceBackWithConstructorArg_ThenInsertsElement) {
|
||||
List<string> list;
|
||||
list.emplace_back("5"); // const char* is a constructor arg to std::string
|
||||
|
|
@ -248,7 +217,6 @@ TEST(ListTest_IValueBasedList, whenCallingEmplaceBackWithConstructorArg_ThenInse
|
|||
EXPECT_EQ("5", list.get(0));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenEmptyList_whenIterating_thenBeginIsEnd) {
|
||||
List<string> list;
|
||||
const List<string> clist;
|
||||
|
|
@ -258,7 +226,6 @@ TEST(ListTest_IValueBasedList, givenEmptyList_whenIterating_thenBeginIsEnd) {
|
|||
EXPECT_EQ(clist.begin(), clist.end());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenIterating_thenFindsElements) {
|
||||
List<string> list({"3", "5"});
|
||||
bool found_first = false;
|
||||
|
|
@ -278,7 +245,6 @@ TEST(ListTest_IValueBasedList, whenIterating_thenFindsElements) {
|
|||
EXPECT_TRUE(found_second);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenIteratingWithForeach_thenFindsElements) {
|
||||
List<string> list({"3", "5"});
|
||||
bool found_first = false;
|
||||
|
|
@ -299,34 +265,29 @@ TEST(ListTest_IValueBasedList, whenIteratingWithForeach_thenFindsElements) {
|
|||
EXPECT_TRUE(found_second);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenOneElementList_whenErasing_thenListIsEmpty) {
|
||||
List<string> list({"3"});
|
||||
list.erase(list.begin());
|
||||
EXPECT_TRUE(list.empty());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenList_whenErasing_thenReturnsIterator) {
|
||||
List<string> list({"1", "2", "3"});
|
||||
List<string>::iterator iter = list.erase(list.begin() + 1);
|
||||
EXPECT_EQ(list.begin() + 1, iter);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenList_whenErasingFullRange_thenIsEmpty) {
|
||||
List<string> list({"1", "2", "3"});
|
||||
list.erase(list.begin(), list.end());
|
||||
EXPECT_TRUE(list.empty());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenCallingReserve_thenDoesntCrash) {
|
||||
List<string> list;
|
||||
list.reserve(100);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenCopyConstructingList_thenAreEqual) {
|
||||
List<string> list1({"3", "4"});
|
||||
|
||||
|
|
@ -338,7 +299,6 @@ TEST(ListTest_IValueBasedList, whenCopyConstructingList_thenAreEqual) {
|
|||
EXPECT_EQ("4", list2.get(1));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenCopyAssigningList_thenAreEqual) {
|
||||
List<string> list1({"3", "4"});
|
||||
|
||||
|
|
@ -350,7 +310,6 @@ TEST(ListTest_IValueBasedList, whenCopyAssigningList_thenAreEqual) {
|
|||
EXPECT_EQ("4", list2.get(1));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenCopyingList_thenAreEqual) {
|
||||
List<string> list1({"3", "4"});
|
||||
|
||||
|
|
@ -361,7 +320,6 @@ TEST(ListTest_IValueBasedList, whenCopyingList_thenAreEqual) {
|
|||
EXPECT_EQ("4", list2.get(1));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenMoveConstructingList_thenNewIsCorrect) {
|
||||
List<string> list1({"3", "4"});
|
||||
|
||||
|
|
@ -372,7 +330,6 @@ TEST(ListTest_IValueBasedList, whenMoveConstructingList_thenNewIsCorrect) {
|
|||
EXPECT_EQ("4", list2.get(1));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenMoveAssigningList_thenNewIsCorrect) {
|
||||
List<string> list1({"3", "4"});
|
||||
|
||||
|
|
@ -384,7 +341,6 @@ TEST(ListTest_IValueBasedList, whenMoveAssigningList_thenNewIsCorrect) {
|
|||
EXPECT_EQ("4", list2.get(1));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenMoveConstructingList_thenOldIsEmpty) {
|
||||
List<string> list1({"3", "4"});
|
||||
|
||||
|
|
@ -393,7 +349,6 @@ TEST(ListTest_IValueBasedList, whenMoveConstructingList_thenOldIsEmpty) {
|
|||
EXPECT_TRUE(list1.empty());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, whenMoveAssigningList_thenOldIsEmpty) {
|
||||
List<string> list1({"3", "4"});
|
||||
|
||||
|
|
@ -403,7 +358,6 @@ TEST(ListTest_IValueBasedList, whenMoveAssigningList_thenOldIsEmpty) {
|
|||
EXPECT_TRUE(list1.empty());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenIterator_whenPostfixIncrementing_thenMovesToNextAndReturnsOldPosition) {
|
||||
List<string> list({"3", "4"});
|
||||
|
||||
|
|
@ -413,7 +367,6 @@ TEST(ListTest_IValueBasedList, givenIterator_whenPostfixIncrementing_thenMovesTo
|
|||
EXPECT_EQ("3", static_cast<string>(*iter2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenIterator_whenPrefixIncrementing_thenMovesToNextAndReturnsNewPosition) {
|
||||
List<string> list({"3", "4"});
|
||||
|
||||
|
|
@ -423,7 +376,6 @@ TEST(ListTest_IValueBasedList, givenIterator_whenPrefixIncrementing_thenMovesToN
|
|||
EXPECT_NE("3", static_cast<string>(*iter2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenIterator_whenPostfixDecrementing_thenMovesToNextAndReturnsOldPosition) {
|
||||
List<string> list({"3", "4"});
|
||||
|
||||
|
|
@ -433,7 +385,6 @@ TEST(ListTest_IValueBasedList, givenIterator_whenPostfixDecrementing_thenMovesTo
|
|||
EXPECT_EQ("4", static_cast<string>(*iter2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenIterator_whenPrefixDecrementing_thenMovesToNextAndReturnsNewPosition) {
|
||||
List<string> list({"3", "4"});
|
||||
|
||||
|
|
@ -443,7 +394,6 @@ TEST(ListTest_IValueBasedList, givenIterator_whenPrefixDecrementing_thenMovesToN
|
|||
EXPECT_NE("4", static_cast<string>(*iter2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenIterator_whenIncreasing_thenMovesToNextAndReturnsNewPosition) {
|
||||
List<string> list({"3", "4", "5"});
|
||||
|
||||
|
|
@ -453,7 +403,6 @@ TEST(ListTest_IValueBasedList, givenIterator_whenIncreasing_thenMovesToNextAndRe
|
|||
EXPECT_EQ("5", static_cast<string>(*iter2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenIterator_whenDecreasing_thenMovesToNextAndReturnsNewPosition) {
|
||||
List<string> list({"3", "4", "5"});
|
||||
|
||||
|
|
@ -463,7 +412,6 @@ TEST(ListTest_IValueBasedList, givenIterator_whenDecreasing_thenMovesToNextAndRe
|
|||
EXPECT_EQ("4", static_cast<string>(*iter2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenIterator_whenAdding_thenReturnsNewIterator) {
|
||||
List<string> list({"3", "4", "5"});
|
||||
|
||||
|
|
@ -473,7 +421,6 @@ TEST(ListTest_IValueBasedList, givenIterator_whenAdding_thenReturnsNewIterator)
|
|||
EXPECT_EQ("5", static_cast<string>(*iter2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenIterator_whenSubtracting_thenReturnsNewIterator) {
|
||||
List<string> list({"3", "4", "5"});
|
||||
|
||||
|
|
@ -483,13 +430,11 @@ TEST(ListTest_IValueBasedList, givenIterator_whenSubtracting_thenReturnsNewItera
|
|||
EXPECT_EQ("3", static_cast<string>(*iter2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenIterator_whenCalculatingDifference_thenReturnsCorrectNumber) {
|
||||
List<string> list({"3", "4"});
|
||||
EXPECT_EQ(2, list.end() - list.begin());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenEqualIterators_thenAreEqual) {
|
||||
List<string> list({"3", "4"});
|
||||
|
||||
|
|
@ -499,7 +444,6 @@ TEST(ListTest_IValueBasedList, givenEqualIterators_thenAreEqual) {
|
|||
EXPECT_FALSE(iter1 != iter2);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenDifferentIterators_thenAreNotEqual) {
|
||||
List<string> list({"3", "4"});
|
||||
|
||||
|
|
@ -511,7 +455,6 @@ TEST(ListTest_IValueBasedList, givenDifferentIterators_thenAreNotEqual) {
|
|||
EXPECT_TRUE(iter1 != iter2);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenIterator_whenDereferencing_thenPointsToCorrectElement) {
|
||||
List<string> list({"3"});
|
||||
|
||||
|
|
@ -519,7 +462,6 @@ TEST(ListTest_IValueBasedList, givenIterator_whenDereferencing_thenPointsToCorre
|
|||
EXPECT_EQ("3", static_cast<string>(*iter));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenIterator_whenAssigningNewValue_thenChangesValue) {
|
||||
List<string> list({"3"});
|
||||
|
||||
|
|
@ -528,7 +470,6 @@ TEST(ListTest_IValueBasedList, givenIterator_whenAssigningNewValue_thenChangesVa
|
|||
EXPECT_EQ("4", list.get(0));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenIterator_whenAssigningNewValueFromIterator_thenChangesValue) {
|
||||
List<string> list({"3", "4"});
|
||||
|
||||
|
|
@ -538,7 +479,6 @@ TEST(ListTest_IValueBasedList, givenIterator_whenAssigningNewValueFromIterator_t
|
|||
EXPECT_EQ("4", list.get(1));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenIterator_whenSwappingValuesFromIterator_thenChangesValue) {
|
||||
List<string> list({"3", "4"});
|
||||
|
||||
|
|
@ -548,14 +488,12 @@ TEST(ListTest_IValueBasedList, givenIterator_whenSwappingValuesFromIterator_then
|
|||
EXPECT_EQ("3", list.get(1));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenOneElementList_whenCallingPopBack_thenIsEmpty) {
|
||||
List<string> list({"3"});
|
||||
list.pop_back();
|
||||
EXPECT_TRUE(list.empty());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenEmptyList_whenCallingResize_thenResizesAndSetsEmptyValue) {
|
||||
List<string> list;
|
||||
list.resize(2);
|
||||
|
|
@ -564,7 +502,6 @@ TEST(ListTest_IValueBasedList, givenEmptyList_whenCallingResize_thenResizesAndSe
|
|||
EXPECT_EQ("", list.get(1));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenEmptyList_whenCallingResizeWithValue_thenResizesAndSetsValue) {
|
||||
List<string> list;
|
||||
list.resize(2, "value");
|
||||
|
|
@ -573,7 +510,6 @@ TEST(ListTest_IValueBasedList, givenEmptyList_whenCallingResizeWithValue_thenRes
|
|||
EXPECT_EQ("value", list.get(1));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, isReferenceType) {
|
||||
List<string> list1;
|
||||
// NOLINTNEXTLINE(performance-unnecessary-copy-initialization)
|
||||
|
|
@ -587,7 +523,6 @@ TEST(ListTest_IValueBasedList, isReferenceType) {
|
|||
EXPECT_EQ(1, list3.size());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, copyHasSeparateStorage) {
|
||||
List<string> list1;
|
||||
List<string> list2(list1.copy());
|
||||
|
|
@ -600,7 +535,6 @@ TEST(ListTest_IValueBasedList, copyHasSeparateStorage) {
|
|||
EXPECT_EQ(0, list3.size());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenEqualLists_thenIsEqual) {
|
||||
List<string> list1({"first", "second"});
|
||||
List<string> list2({"first", "second"});
|
||||
|
|
@ -608,7 +542,6 @@ TEST(ListTest_IValueBasedList, givenEqualLists_thenIsEqual) {
|
|||
EXPECT_EQ(list1, list2);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_IValueBasedList, givenDifferentLists_thenIsNotEqual) {
|
||||
List<string> list1({"first", "second"});
|
||||
List<string> list2({"first", "not_second"});
|
||||
|
|
@ -616,66 +549,56 @@ TEST(ListTest_IValueBasedList, givenDifferentLists_thenIsNotEqual) {
|
|||
EXPECT_NE(list1, list2);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenEmptyList_whenCallingEmpty_thenReturnsTrue) {
|
||||
List<int64_t> list;
|
||||
EXPECT_TRUE(list.empty());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenNonemptyList_whenCallingEmpty_thenReturnsFalse) {
|
||||
List<int64_t> list({3});
|
||||
EXPECT_FALSE(list.empty());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenEmptyList_whenCallingSize_thenReturnsZero) {
|
||||
List<int64_t> list;
|
||||
EXPECT_EQ(0, list.size());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenNonemptyList_whenCallingSize_thenReturnsNumberOfElements) {
|
||||
List<int64_t> list({3, 4});
|
||||
EXPECT_EQ(2, list.size());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenNonemptyList_whenCallingClear_thenIsEmpty) {
|
||||
List<int64_t> list({3, 4});
|
||||
list.clear();
|
||||
EXPECT_TRUE(list.empty());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenCallingGetWithExistingPosition_thenReturnsElement) {
|
||||
List<int64_t> list({3, 4});
|
||||
EXPECT_EQ(3, list.get(0));
|
||||
EXPECT_EQ(4, list.get(1));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenCallingGetWithNonExistingPosition_thenThrowsException) {
|
||||
List<int64_t> list({3, 4});
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-goto,hicpp-avoid-goto)
|
||||
EXPECT_THROW(list.get(2), std::out_of_range);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenCallingExtractWithExistingPosition_thenReturnsElement) {
|
||||
List<int64_t> list({3, 4});
|
||||
EXPECT_EQ(3, list.extract(0));
|
||||
EXPECT_EQ(4, list.extract(1));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenCallingExtractWithNonExistingPosition_thenThrowsException) {
|
||||
List<int64_t> list({3, 4});
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-goto,hicpp-avoid-goto)
|
||||
EXPECT_THROW(list.extract(2), std::out_of_range);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenCallingCopyingSetWithExistingPosition_thenChangesElement) {
|
||||
List<int64_t> list({3, 4});
|
||||
int64_t value = 5;
|
||||
|
|
@ -684,7 +607,6 @@ TEST(ListTest_NonIValueBasedList, whenCallingCopyingSetWithExistingPosition_then
|
|||
EXPECT_EQ(5, list.get(1));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenCallingMovingSetWithExistingPosition_thenChangesElement) {
|
||||
List<int64_t> list({3, 4});
|
||||
int64_t value = 5;
|
||||
|
|
@ -694,7 +616,6 @@ TEST(ListTest_NonIValueBasedList, whenCallingMovingSetWithExistingPosition_thenC
|
|||
EXPECT_EQ(5, list.get(1));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenCallingCopyingSetWithNonExistingPosition_thenThrowsException) {
|
||||
List<int64_t> list({3, 4});
|
||||
int64_t value = 5;
|
||||
|
|
@ -702,7 +623,6 @@ TEST(ListTest_NonIValueBasedList, whenCallingCopyingSetWithNonExistingPosition_t
|
|||
EXPECT_THROW(list.set(2, value), std::out_of_range);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenCallingMovingSetWithNonExistingPosition_thenThrowsException) {
|
||||
List<int64_t> list({3, 4});
|
||||
int64_t value = 5;
|
||||
|
|
@ -710,14 +630,12 @@ TEST(ListTest_NonIValueBasedList, whenCallingMovingSetWithNonExistingPosition_th
|
|||
EXPECT_THROW(list.set(2, std::move(value)), std::out_of_range);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenCallingAccessOperatorWithExistingPosition_thenReturnsElement) {
|
||||
List<int64_t> list({3, 4});
|
||||
EXPECT_EQ(3, static_cast<int64_t>(list[0]));
|
||||
EXPECT_EQ(4, static_cast<int64_t>(list[1]));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenAssigningToAccessOperatorWithExistingPosition_thenSetsElement) {
|
||||
List<int64_t> list({3, 4, 5});
|
||||
list[1] = 6;
|
||||
|
|
@ -726,7 +644,6 @@ TEST(ListTest_NonIValueBasedList, whenAssigningToAccessOperatorWithExistingPosit
|
|||
EXPECT_EQ(5, list.get(2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenAssigningToAccessOperatorFromAccessOperator_thenSetsElement) {
|
||||
List<int64_t> list({3, 4, 5});
|
||||
list[1] = list[2];
|
||||
|
|
@ -735,7 +652,6 @@ TEST(ListTest_NonIValueBasedList, whenAssigningToAccessOperatorFromAccessOperato
|
|||
EXPECT_EQ(5, list.get(2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenSwappingFromAccessOperator_thenSwapsElements) {
|
||||
List<int64_t> list({3, 4, 5});
|
||||
swap(list[1], list[2]);
|
||||
|
|
@ -744,14 +660,12 @@ TEST(ListTest_NonIValueBasedList, whenSwappingFromAccessOperator_thenSwapsElemen
|
|||
EXPECT_EQ(4, list.get(2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenCallingAccessOperatorWithNonExistingPosition_thenThrowsException) {
|
||||
List<int64_t> list({3, 4});
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-goto,hicpp-avoid-goto)
|
||||
EXPECT_THROW(list[2], std::out_of_range);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenCallingInsertOnIteratorWithLValue_thenInsertsElement) {
|
||||
List<int64_t> list({3, 4, 6});
|
||||
int64_t v = 5;
|
||||
|
|
@ -760,7 +674,6 @@ TEST(ListTest_NonIValueBasedList, whenCallingInsertOnIteratorWithLValue_thenInse
|
|||
EXPECT_EQ(5, list.get(2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenCallingInsertOnIteratorWithRValue_thenInsertsElement) {
|
||||
List<int64_t> list({3, 4, 6});
|
||||
int64_t v = 5;
|
||||
|
|
@ -770,7 +683,6 @@ TEST(ListTest_NonIValueBasedList, whenCallingInsertOnIteratorWithRValue_thenInse
|
|||
EXPECT_EQ(5, list.get(2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenCallingInsertWithLValue_thenReturnsIteratorToNewElement) {
|
||||
List<int64_t> list({3, 4, 6});
|
||||
int64_t v = 5;
|
||||
|
|
@ -778,7 +690,6 @@ TEST(ListTest_NonIValueBasedList, whenCallingInsertWithLValue_thenReturnsIterato
|
|||
EXPECT_EQ(list.begin() + 2, result);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenCallingInsertWithRValue_thenReturnsIteratorToNewElement) {
|
||||
List<int64_t> list({3, 4, 6});
|
||||
int64_t v = 5;
|
||||
|
|
@ -787,7 +698,6 @@ TEST(ListTest_NonIValueBasedList, whenCallingInsertWithRValue_thenReturnsIterato
|
|||
EXPECT_EQ(list.begin() + 2, result);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenCallingEmplaceWithLValue_thenInsertsElement) {
|
||||
List<int64_t> list({3, 4, 6});
|
||||
int64_t v = 5;
|
||||
|
|
@ -796,7 +706,6 @@ TEST(ListTest_NonIValueBasedList, whenCallingEmplaceWithLValue_thenInsertsElemen
|
|||
EXPECT_EQ(5, list.get(2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenCallingEmplaceWithRValue_thenInsertsElement) {
|
||||
List<int64_t> list({3, 4, 6});
|
||||
int64_t v = 5;
|
||||
|
|
@ -806,7 +715,6 @@ TEST(ListTest_NonIValueBasedList, whenCallingEmplaceWithRValue_thenInsertsElemen
|
|||
EXPECT_EQ(5, list.get(2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenCallingEmplaceWithConstructorArg_thenInsertsElement) {
|
||||
List<int64_t> list({3, 4, 6});
|
||||
list.emplace(list.begin() + 2, 5); // const char* is a constructor arg to std::int64_t
|
||||
|
|
@ -814,7 +722,6 @@ TEST(ListTest_NonIValueBasedList, whenCallingEmplaceWithConstructorArg_thenInser
|
|||
EXPECT_EQ(5, list.get(2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenCallingPushBackWithLValue_ThenInsertsElement) {
|
||||
List<int64_t> list;
|
||||
int64_t v = 5;
|
||||
|
|
@ -823,7 +730,6 @@ TEST(ListTest_NonIValueBasedList, whenCallingPushBackWithLValue_ThenInsertsEleme
|
|||
EXPECT_EQ(5, list.get(0));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenCallingPushBackWithRValue_ThenInsertsElement) {
|
||||
List<int64_t> list;
|
||||
int64_t v = 5;
|
||||
|
|
@ -833,7 +739,6 @@ TEST(ListTest_NonIValueBasedList, whenCallingPushBackWithRValue_ThenInsertsEleme
|
|||
EXPECT_EQ(5, list.get(0));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenCallingEmplaceBackWithLValue_ThenInsertsElement) {
|
||||
List<int64_t> list;
|
||||
int64_t v = 5;
|
||||
|
|
@ -842,7 +747,6 @@ TEST(ListTest_NonIValueBasedList, whenCallingEmplaceBackWithLValue_ThenInsertsEl
|
|||
EXPECT_EQ(5, list.get(0));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenCallingEmplaceBackWithRValue_ThenInsertsElement) {
|
||||
List<int64_t> list;
|
||||
int64_t v = 5;
|
||||
|
|
@ -852,7 +756,6 @@ TEST(ListTest_NonIValueBasedList, whenCallingEmplaceBackWithRValue_ThenInsertsEl
|
|||
EXPECT_EQ(5, list.get(0));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenCallingEmplaceBackWithConstructorArg_ThenInsertsElement) {
|
||||
List<int64_t> list;
|
||||
list.emplace_back(5); // const char* is a constructor arg to std::int64_t
|
||||
|
|
@ -860,7 +763,6 @@ TEST(ListTest_NonIValueBasedList, whenCallingEmplaceBackWithConstructorArg_ThenI
|
|||
EXPECT_EQ(5, list.get(0));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenEmptyList_whenIterating_thenBeginIsEnd) {
|
||||
List<int64_t> list;
|
||||
const List<int64_t> clist;
|
||||
|
|
@ -870,7 +772,6 @@ TEST(ListTest_NonIValueBasedList, givenEmptyList_whenIterating_thenBeginIsEnd) {
|
|||
EXPECT_EQ(clist.begin(), clist.end());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenIterating_thenFindsElements) {
|
||||
List<int64_t> list({3, 5});
|
||||
bool found_first = false;
|
||||
|
|
@ -890,7 +791,6 @@ TEST(ListTest_NonIValueBasedList, whenIterating_thenFindsElements) {
|
|||
EXPECT_TRUE(found_second);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenIteratingWithForeach_thenFindsElements) {
|
||||
List<int64_t> list({3, 5});
|
||||
bool found_first = false;
|
||||
|
|
@ -911,34 +811,29 @@ TEST(ListTest_NonIValueBasedList, whenIteratingWithForeach_thenFindsElements) {
|
|||
EXPECT_TRUE(found_second);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenOneElementList_whenErasing_thenListIsEmpty) {
|
||||
List<int64_t> list({3});
|
||||
list.erase(list.begin());
|
||||
EXPECT_TRUE(list.empty());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenList_whenErasing_thenReturnsIterator) {
|
||||
List<int64_t> list({1, 2, 3});
|
||||
List<int64_t>::iterator iter = list.erase(list.begin() + 1);
|
||||
EXPECT_EQ(list.begin() + 1, iter);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenList_whenErasingFullRange_thenIsEmpty) {
|
||||
List<int64_t> list({1, 2, 3});
|
||||
list.erase(list.begin(), list.end());
|
||||
EXPECT_TRUE(list.empty());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenCallingReserve_thenDoesntCrash) {
|
||||
List<int64_t> list;
|
||||
list.reserve(100);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenCopyConstructingList_thenAreEqual) {
|
||||
List<int64_t> list1({3, 4});
|
||||
|
||||
|
|
@ -950,7 +845,6 @@ TEST(ListTest_NonIValueBasedList, whenCopyConstructingList_thenAreEqual) {
|
|||
EXPECT_EQ(4, list2.get(1));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenCopyAssigningList_thenAreEqual) {
|
||||
List<int64_t> list1({3, 4});
|
||||
|
||||
|
|
@ -962,7 +856,6 @@ TEST(ListTest_NonIValueBasedList, whenCopyAssigningList_thenAreEqual) {
|
|||
EXPECT_EQ(4, list2.get(1));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenCopyingList_thenAreEqual) {
|
||||
List<int64_t> list1({3, 4});
|
||||
|
||||
|
|
@ -973,7 +866,6 @@ TEST(ListTest_NonIValueBasedList, whenCopyingList_thenAreEqual) {
|
|||
EXPECT_EQ(4, list2.get(1));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenMoveConstructingList_thenNewIsCorrect) {
|
||||
List<int64_t> list1({3, 4});
|
||||
|
||||
|
|
@ -984,7 +876,6 @@ TEST(ListTest_NonIValueBasedList, whenMoveConstructingList_thenNewIsCorrect) {
|
|||
EXPECT_EQ(4, list2.get(1));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenMoveAssigningList_thenNewIsCorrect) {
|
||||
List<int64_t> list1({3, 4});
|
||||
|
||||
|
|
@ -996,7 +887,6 @@ TEST(ListTest_NonIValueBasedList, whenMoveAssigningList_thenNewIsCorrect) {
|
|||
EXPECT_EQ(4, list2.get(1));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenMoveConstructingList_thenOldIsEmpty) {
|
||||
List<int64_t> list1({3, 4});
|
||||
|
||||
|
|
@ -1005,7 +895,6 @@ TEST(ListTest_NonIValueBasedList, whenMoveConstructingList_thenOldIsEmpty) {
|
|||
EXPECT_TRUE(list1.empty());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, whenMoveAssigningList_thenOldIsEmpty) {
|
||||
List<int64_t> list1({3, 4});
|
||||
|
||||
|
|
@ -1015,7 +904,6 @@ TEST(ListTest_NonIValueBasedList, whenMoveAssigningList_thenOldIsEmpty) {
|
|||
EXPECT_TRUE(list1.empty());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenIterator_whenPostfixIncrementing_thenMovesToNextAndReturnsOldPosition) {
|
||||
List<int64_t> list({3, 4});
|
||||
|
||||
|
|
@ -1025,7 +913,6 @@ TEST(ListTest_NonIValueBasedList, givenIterator_whenPostfixIncrementing_thenMove
|
|||
EXPECT_EQ(3, static_cast<int64_t>(*iter2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenIterator_whenPrefixIncrementing_thenMovesToNextAndReturnsNewPosition) {
|
||||
List<int64_t> list({3, 4});
|
||||
|
||||
|
|
@ -1035,7 +922,6 @@ TEST(ListTest_NonIValueBasedList, givenIterator_whenPrefixIncrementing_thenMoves
|
|||
EXPECT_NE(3, static_cast<int64_t>(*iter2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenIterator_whenPostfixDecrementing_thenMovesToNextAndReturnsOldPosition) {
|
||||
List<int64_t> list({3, 4});
|
||||
|
||||
|
|
@ -1045,7 +931,6 @@ TEST(ListTest_NonIValueBasedList, givenIterator_whenPostfixDecrementing_thenMove
|
|||
EXPECT_EQ(4, static_cast<int64_t>(*iter2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenIterator_whenPrefixDecrementing_thenMovesToNextAndReturnsNewPosition) {
|
||||
List<int64_t> list({3, 4});
|
||||
|
||||
|
|
@ -1055,7 +940,6 @@ TEST(ListTest_NonIValueBasedList, givenIterator_whenPrefixDecrementing_thenMoves
|
|||
EXPECT_NE(4, static_cast<int64_t>(*iter2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenIterator_whenIncreasing_thenMovesToNextAndReturnsNewPosition) {
|
||||
List<int64_t> list({3, 4, 5});
|
||||
|
||||
|
|
@ -1065,7 +949,6 @@ TEST(ListTest_NonIValueBasedList, givenIterator_whenIncreasing_thenMovesToNextAn
|
|||
EXPECT_EQ(5, static_cast<int64_t>(*iter2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenIterator_whenDecreasing_thenMovesToNextAndReturnsNewPosition) {
|
||||
List<int64_t> list({3, 4, 5});
|
||||
|
||||
|
|
@ -1075,7 +958,6 @@ TEST(ListTest_NonIValueBasedList, givenIterator_whenDecreasing_thenMovesToNextAn
|
|||
EXPECT_EQ(4, static_cast<int64_t>(*iter2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenIterator_whenAdding_thenReturnsNewIterator) {
|
||||
List<int64_t> list({3, 4, 5});
|
||||
|
||||
|
|
@ -1085,7 +967,6 @@ TEST(ListTest_NonIValueBasedList, givenIterator_whenAdding_thenReturnsNewIterato
|
|||
EXPECT_EQ(5, static_cast<int64_t>(*iter2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenIterator_whenSubtracting_thenReturnsNewIterator) {
|
||||
List<int64_t> list({3, 4, 5});
|
||||
|
||||
|
|
@ -1095,13 +976,11 @@ TEST(ListTest_NonIValueBasedList, givenIterator_whenSubtracting_thenReturnsNewIt
|
|||
EXPECT_EQ(3, static_cast<int64_t>(*iter2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenIterator_whenCalculatingDifference_thenReturnsCorrectNumber) {
|
||||
List<int64_t> list({3, 4});
|
||||
EXPECT_EQ(2, list.end() - list.begin());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenEqualIterators_thenAreEqual) {
|
||||
List<int64_t> list({3, 4});
|
||||
|
||||
|
|
@ -1111,7 +990,6 @@ TEST(ListTest_NonIValueBasedList, givenEqualIterators_thenAreEqual) {
|
|||
EXPECT_FALSE(iter1 != iter2);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenDifferentIterators_thenAreNotEqual) {
|
||||
List<int64_t> list({3, 4});
|
||||
|
||||
|
|
@ -1123,7 +1001,6 @@ TEST(ListTest_NonIValueBasedList, givenDifferentIterators_thenAreNotEqual) {
|
|||
EXPECT_TRUE(iter1 != iter2);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenIterator_whenDereferencing_thenPointsToCorrectElement) {
|
||||
List<int64_t> list({3});
|
||||
|
||||
|
|
@ -1131,7 +1008,6 @@ TEST(ListTest_NonIValueBasedList, givenIterator_whenDereferencing_thenPointsToCo
|
|||
EXPECT_EQ(3, static_cast<int64_t>(*iter));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenIterator_whenAssigningNewValue_thenChangesValue) {
|
||||
List<int64_t> list({3});
|
||||
|
||||
|
|
@ -1140,7 +1016,6 @@ TEST(ListTest_NonIValueBasedList, givenIterator_whenAssigningNewValue_thenChange
|
|||
EXPECT_EQ(4, list.get(0));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenIterator_whenAssigningNewValueFromIterator_thenChangesValue) {
|
||||
List<int64_t> list({3, 4});
|
||||
|
||||
|
|
@ -1150,7 +1025,6 @@ TEST(ListTest_NonIValueBasedList, givenIterator_whenAssigningNewValueFromIterato
|
|||
EXPECT_EQ(4, list.get(1));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenIterator_whenSwappingValuesFromIterator_thenChangesValue) {
|
||||
List<int64_t> list({3, 4});
|
||||
|
||||
|
|
@ -1160,14 +1034,12 @@ TEST(ListTest_NonIValueBasedList, givenIterator_whenSwappingValuesFromIterator_t
|
|||
EXPECT_EQ(3, list.get(1));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenOneElementList_whenCallingPopBack_thenIsEmpty) {
|
||||
List<int64_t> list({3});
|
||||
list.pop_back();
|
||||
EXPECT_TRUE(list.empty());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenEmptyList_whenCallingResize_thenResizesAndSetsEmptyValue) {
|
||||
List<int64_t> list;
|
||||
list.resize(2);
|
||||
|
|
@ -1176,7 +1048,6 @@ TEST(ListTest_NonIValueBasedList, givenEmptyList_whenCallingResize_thenResizesAn
|
|||
EXPECT_EQ(0, list.get(1));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenEmptyList_whenCallingResizeWithValue_thenResizesAndSetsValue) {
|
||||
List<int64_t> list;
|
||||
list.resize(2, 5);
|
||||
|
|
@ -1185,7 +1056,6 @@ TEST(ListTest_NonIValueBasedList, givenEmptyList_whenCallingResizeWithValue_then
|
|||
EXPECT_EQ(5, list.get(1));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, isReferenceType) {
|
||||
List<int64_t> list1;
|
||||
// NOLINTNEXTLINE(performance-unnecessary-copy-initialization)
|
||||
|
|
@ -1199,7 +1069,6 @@ TEST(ListTest_NonIValueBasedList, isReferenceType) {
|
|||
EXPECT_EQ(1, list3.size());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, copyHasSeparateStorage) {
|
||||
List<int64_t> list1;
|
||||
List<int64_t> list2(list1.copy());
|
||||
|
|
@ -1212,7 +1081,6 @@ TEST(ListTest_NonIValueBasedList, copyHasSeparateStorage) {
|
|||
EXPECT_EQ(0, list3.size());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenEqualLists_thenIsEqual) {
|
||||
List<int64_t> list1({1, 3});
|
||||
List<int64_t> list2({1, 3});
|
||||
|
|
@ -1220,7 +1088,6 @@ TEST(ListTest_NonIValueBasedList, givenEqualLists_thenIsEqual) {
|
|||
EXPECT_EQ(list1, list2);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, givenDifferentLists_thenIsNotEqual) {
|
||||
List<int64_t> list1({1, 3});
|
||||
List<int64_t> list2({1, 2});
|
||||
|
|
@ -1228,7 +1095,6 @@ TEST(ListTest_NonIValueBasedList, givenDifferentLists_thenIsNotEqual) {
|
|||
EXPECT_NE(list1, list2);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, isChecksIdentity) {
|
||||
List<int64_t> list1({1, 3});
|
||||
// NOLINTNEXTLINE(performance-unnecessary-copy-initialization)
|
||||
|
|
@ -1237,7 +1103,6 @@ TEST(ListTest_NonIValueBasedList, isChecksIdentity) {
|
|||
EXPECT_TRUE(list1.is(list2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest_NonIValueBasedList, sameValueDifferentStorage_thenIsReturnsFalse) {
|
||||
List<int64_t> list1({1, 3});
|
||||
const auto list2 = list1.copy();
|
||||
|
|
@ -1245,7 +1110,6 @@ TEST(ListTest_NonIValueBasedList, sameValueDifferentStorage_thenIsReturnsFalse)
|
|||
EXPECT_FALSE(list1.is(list2));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest, canAccessStringByReference) {
|
||||
List<std::string> list({"one", "two"});
|
||||
const auto& listRef = list;
|
||||
|
|
@ -1257,7 +1121,6 @@ TEST(ListTest, canAccessStringByReference) {
|
|||
EXPECT_EQ("two", strRef);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest, canAccessOptionalStringByReference) {
|
||||
List<c10::optional<std::string>> list({"one", "two", c10::nullopt});
|
||||
const auto& listRef = list;
|
||||
|
|
@ -1274,7 +1137,6 @@ TEST(ListTest, canAccessOptionalStringByReference) {
|
|||
EXPECT_FALSE(strRef2.has_value());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(ListTest, canAccessTensorByReference) {
|
||||
List<at::Tensor> list;
|
||||
const auto& listRef = list;
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
namespace at {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
thread_local bool NamesMode_enabled = true;
|
||||
|
||||
bool NamesMode::is_enabled() {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include <caffe2/core/tensor.h>
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(TensorImplTest, Caffe2Constructor) {
|
||||
caffe2::Tensor tensor(caffe2::CPU);
|
||||
ASSERT_EQ(tensor.strides()[0], 1);
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
namespace at { namespace impl {
|
||||
|
||||
namespace {
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
VariableHooksInterface* hooks = nullptr;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
namespace at {
|
||||
namespace vitals {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
APIVitals VitalsAPI;
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, TorchVital const& tv) {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ namespace kernels {
|
|||
// The expectXXX() functions further below use these invariants
|
||||
// to check that calling a specific kernels works correctly.
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
optional<tuple<int64_t, int64_t>> called_with_args;
|
||||
|
||||
|
||||
|
|
@ -32,7 +31,6 @@ optional<tuple<int64_t, int64_t>> called_with_args;
|
|||
// take in a DispatchKeySet.
|
||||
// The value itself is meaningless for all of the tests that use kernels without a DispatchKeySet argument.
|
||||
// See Note [Plumbing Keys Through The Dispatcher] for details.
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
c10::DispatchKeySet CPU_TEST_SET = c10::DispatchKeySet(c10::DispatchKey::CPU);
|
||||
|
||||
void boxed_func_with_return(const OperatorHandle& /*opHandle*/, Stack* stack) {
|
||||
|
|
@ -101,13 +99,11 @@ void unboxed_function_without_return(int64_t a, int64_t b) {
|
|||
called_with_args = tuple<int64_t, int64_t>(a, b);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
auto unboxed_lambda_with_return = [] (int64_t a, int64_t b) -> int64_t {
|
||||
called_with_args = tuple<int64_t, int64_t>(a, b);
|
||||
return 5;
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
auto unboxed_lambda_without_return = [] (int64_t a, int64_t b) -> void{
|
||||
called_with_args = tuple<int64_t, int64_t>(a, b);
|
||||
};
|
||||
|
|
@ -388,19 +384,16 @@ void expectOutOfPlaceMultiUnboxedCallingWorks(const KernelFunction& func) {
|
|||
|
||||
// functional, boxed calling
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenBoxedFunction_withReturn_whenCallingBoxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromBoxedFunction<&kernels::boxed_func_with_return>();
|
||||
kernels::expectBoxedCallingWithReturnWorks(func);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenBoxedFunction_withoutReturn_whenCallingBoxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromBoxedFunction<&kernels::boxed_func_without_return>();
|
||||
kernels::expectBoxedCallingWithoutReturnWorks(func);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenBoxedFunction_withMultiReturn_whenCallingBoxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromBoxedFunction<&kernels::boxed_func_with_multi_return>();
|
||||
kernels::expectBoxedCallingWithMultiReturnWorks(func);
|
||||
|
|
@ -408,19 +401,16 @@ TEST(KernelFunctionTest, givenBoxedFunction_withMultiReturn_whenCallingBoxed_the
|
|||
|
||||
// in/out, boxed calling
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenBoxedFunction_withInPlaceSignature_whenCallingBoxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromBoxedFunction<&kernels::boxed_func_for_inplace_op>();
|
||||
kernels::expectInPlaceBoxedCallingWorks(func);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenBoxedFunction_withOutOfPlaceSignature_whenCallingBoxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromBoxedFunction<&kernels::boxed_func_for_outofplace_op>();
|
||||
kernels::expectOutOfPlaceBoxedCallingWorks(func);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenBoxedFunction_withOutOfPlaceMultiSignature_whenCallingBoxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromBoxedFunction<&kernels::boxed_func_for_outofplace_multi_op>();
|
||||
kernels::expectOutOfPlaceMultiBoxedCallingWorks(func);
|
||||
|
|
@ -428,19 +418,16 @@ TEST(KernelFunctionTest, givenBoxedFunction_withOutOfPlaceMultiSignature_whenCal
|
|||
|
||||
// functional, unboxed calling
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenBoxedFunction_withReturn_whenCallingUnboxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromBoxedFunction<&kernels::boxed_func_with_return>();
|
||||
kernels::expectUnboxedCallingWithReturnWorks(func);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenBoxedFunction_withoutReturn_whenCallingUnboxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromBoxedFunction<&kernels::boxed_func_without_return>();
|
||||
kernels::expectUnboxedCallingWithoutReturnWorks(func);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenBoxedFunction_withMultiReturn_whenCallingUnboxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromBoxedFunction<&kernels::boxed_func_with_multi_return>();
|
||||
kernels::expectUnboxedCallingWithMultiReturnWorks(func);
|
||||
|
|
@ -448,19 +435,16 @@ TEST(KernelFunctionTest, givenBoxedFunction_withMultiReturn_whenCallingUnboxed_t
|
|||
|
||||
// in/out, unboxed calling
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenBoxedFunction_withInPlaceSignature_whenCallingUnboxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromBoxedFunction<&kernels::boxed_func_for_inplace_op>();
|
||||
kernels::expectInPlaceUnboxedCallingWorks(func);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenBoxedFunction_withOutOfPlaceSignature_whenCallingUnboxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromBoxedFunction<&kernels::boxed_func_for_outofplace_op>();
|
||||
kernels::expectOutOfPlaceUnboxedCallingWorks(func);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenBoxedFunction_withOutOfPlaceMultiSignature_whenCallingUnboxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromBoxedFunction<&kernels::boxed_func_for_outofplace_multi_op>();
|
||||
kernels::expectOutOfPlaceMultiUnboxedCallingWorks(func);
|
||||
|
|
@ -468,97 +452,81 @@ TEST(KernelFunctionTest, givenBoxedFunction_withOutOfPlaceMultiSignature_whenCal
|
|||
|
||||
// functors etc.
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenUnboxedFunctor_withReturn_whenCallingBoxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromUnboxedFunctor<false, kernels::unboxed_functor_with_return>(std::unique_ptr<OperatorKernel>(std::make_unique<kernels::unboxed_functor_with_return>()));
|
||||
kernels::expectBoxedCallingWithReturnWorks(func);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenUnboxedFunctor_withoutReturn_whenCallingBoxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromUnboxedFunctor<false, kernels::unboxed_functor_without_return>(std::unique_ptr<OperatorKernel>(std::make_unique<kernels::unboxed_functor_without_return>()));
|
||||
kernels::expectBoxedCallingWithoutReturnWorks(func);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenUnboxedFunctor_withReturn_whenCallingUnboxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromUnboxedFunctor<false, kernels::unboxed_functor_with_return>(std::unique_ptr<OperatorKernel>(std::make_unique<kernels::unboxed_functor_with_return>()));
|
||||
kernels::expectUnboxedCallingWithReturnWorks(func);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenUnboxedFunctor_withoutReturn_whenCallingUnboxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromUnboxedFunctor<false, kernels::unboxed_functor_without_return>(std::unique_ptr<OperatorKernel>(std::make_unique<kernels::unboxed_functor_without_return>()));
|
||||
kernels::expectUnboxedCallingWithoutReturnWorks(func);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenUnboxedFunction_withReturn_whenCallingBoxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromUnboxedFunction(TORCH_FN(kernels::unboxed_function_with_return));
|
||||
kernels::expectBoxedCallingWithReturnWorks(func);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenUnboxedFunction_withoutReturn_whenCallingBoxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromUnboxedFunction(TORCH_FN(kernels::unboxed_function_without_return));
|
||||
kernels::expectBoxedCallingWithoutReturnWorks(func);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenUnboxedFunction_withReturn_whenCallingUnboxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromUnboxedFunction(TORCH_FN(kernels::unboxed_function_with_return));
|
||||
kernels::expectUnboxedCallingWithReturnWorks(func);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenUnboxedFunction_withoutReturn_whenCallingUnboxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromUnboxedFunction(TORCH_FN(kernels::unboxed_function_without_return));
|
||||
kernels::expectUnboxedCallingWithoutReturnWorks(func);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenUnboxedRuntimeFunction_withReturn_whenCallingBoxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromUnboxedRuntimeFunction(&kernels::unboxed_function_with_return);
|
||||
kernels::expectBoxedCallingWithReturnWorks(func);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenUnboxedRuntimeFunction_withoutReturn_whenCallingBoxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromUnboxedRuntimeFunction(&kernels::unboxed_function_without_return);
|
||||
kernels::expectBoxedCallingWithoutReturnWorks(func);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenUnboxedRuntimeFunction_withReturn_whenCallingUnboxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromUnboxedRuntimeFunction(&kernels::unboxed_function_with_return);
|
||||
kernels::expectUnboxedCallingWithReturnWorks(func);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenUnboxedRuntimeFunction_withoutReturn_whenCallingUnboxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromUnboxedRuntimeFunction(&kernels::unboxed_function_without_return);
|
||||
kernels::expectUnboxedCallingWithoutReturnWorks(func);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenUnboxedLambda_withReturn_whenCallingBoxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromUnboxedLambda(kernels::unboxed_lambda_with_return);
|
||||
kernels::expectBoxedCallingWithReturnWorks(func);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenUnboxedLambda_withoutReturn_whenCallingBoxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromUnboxedLambda(kernels::unboxed_lambda_without_return);
|
||||
kernels::expectBoxedCallingWithoutReturnWorks(func);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenUnboxedLambda_withReturn_whenCallingUnboxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromUnboxedLambda(kernels::unboxed_lambda_with_return);
|
||||
kernels::expectUnboxedCallingWithReturnWorks(func);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(KernelFunctionTest, givenUnboxedLambda_withoutReturn_whenCallingUnboxed_thenWorks) {
|
||||
KernelFunction func = KernelFunction::makeFromUnboxedLambda(kernels::unboxed_lambda_without_return);
|
||||
kernels::expectUnboxedCallingWithoutReturnWorks(func);
|
||||
|
|
|
|||
|
|
@ -66,19 +66,16 @@ void expectCallsDecrement(DispatchKey dispatch_key) {
|
|||
EXPECT_EQ(4, result[0].toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernel_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op("_test::my_op(Tensor dummy, int input) -> int", &incrementKernel);
|
||||
expectCallsIncrement(DispatchKey::CPU);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernel_whenRegisteredInConstructor_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators("_test::my_op(Tensor dummy, int input) -> int", &incrementKernel);
|
||||
expectCallsIncrement(DispatchKey::CPU);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenMultipleOperatorsAndKernels_whenRegisteredInOneRegistrar_thenCallsRightKernel) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::my_op(Tensor dummy, int input) -> int", &incrementKernel)
|
||||
|
|
@ -86,14 +83,12 @@ TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenMultipleOperatorsA
|
|||
expectCallsIncrement(DispatchKey::CPU);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenMultipleOperatorsAndKernels_whenRegisteredInMultipleRegistrars_thenCallsRightKernel) {
|
||||
auto registrar1 = RegisterOperators().op("_test::my_op(Tensor dummy, int input) -> int", &incrementKernel);
|
||||
auto registrar2 = RegisterOperators().op("_test::error(Tensor dummy, int input) -> int", &errorKernel);
|
||||
expectCallsIncrement(DispatchKey::CPU);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernel_whenRegistrationRunsOutOfScope_thenCannotBeCalledAnymore) {
|
||||
{
|
||||
auto registrar = RegisterOperators().op("_test::my_op(Tensor dummy, int input) -> int", &incrementKernel);
|
||||
|
|
@ -105,14 +100,12 @@ TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernel_whenRegistr
|
|||
expectDoesntFindOperator("_test::my_op");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
bool was_called = false;
|
||||
|
||||
void kernelWithoutOutput(const Tensor&) {
|
||||
was_called = true;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op("_test::no_return(Tensor dummy) -> ()", &kernelWithoutOutput);
|
||||
|
||||
|
|
@ -129,7 +122,6 @@ std::tuple<> kernelWithZeroOutputs(const Tensor&) {
|
|||
return std::make_tuple();
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithZeroOutputs_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op("_test::zero_outputs(Tensor dummy) -> ()", &kernelWithZeroOutputs);
|
||||
|
||||
|
|
@ -145,7 +137,6 @@ int64_t kernelWithIntOutput(Tensor, int64_t a, int64_t b) {
|
|||
return a + b;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithIntOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::int_output(Tensor dummy, int a, int b) -> int", &kernelWithIntOutput);
|
||||
|
|
@ -162,7 +153,6 @@ Tensor kernelWithTensorOutput(const Tensor& input) {
|
|||
return input;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithTensorOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::returning_tensor(Tensor input) -> Tensor", &kernelWithTensorOutput);
|
||||
|
|
@ -183,7 +173,6 @@ std::vector<Tensor> kernelWithTensorListOutput(const Tensor& input1, const Tenso
|
|||
return {input1, input2, input3};
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithTensorListOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::list_output(Tensor input1, Tensor input2, Tensor input3) -> Tensor[]", &kernelWithTensorListOutput);
|
||||
|
|
@ -203,7 +192,6 @@ std::vector<int64_t> kernelWithIntListOutput(const Tensor&, int64_t input1, int6
|
|||
return {input1, input2, input3};
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithIntListOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::list_output(Tensor dummy, int input1, int input2, int input3) -> int[]", &kernelWithIntListOutput);
|
||||
|
|
@ -232,7 +220,6 @@ std::tuple<Tensor, int64_t, std::vector<Tensor>, c10::optional<int64_t>, Dict<st
|
|||
);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithMultipleOutputs_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::multiple_outputs(Tensor dummy) -> (Tensor, int, Tensor[], int?, Dict(str, Tensor))", &kernelWithMultipleOutputs);
|
||||
|
|
@ -261,7 +248,6 @@ Tensor kernelWithTensorInputByReferenceWithOutput(const Tensor& input1) {
|
|||
Tensor kernelWithTensorInputByValueWithOutput(Tensor input1) {
|
||||
return input1;
|
||||
}
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithTensorInputByReference_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_input(Tensor input) -> Tensor", &kernelWithTensorInputByReferenceWithOutput);
|
||||
|
|
@ -278,7 +264,6 @@ TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithTensorIn
|
|||
EXPECT_EQ(DispatchKey::CUDA, extractDispatchKey(result[0].toTensor()));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithTensorInputByValue_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_input(Tensor input) -> Tensor", &kernelWithTensorInputByValueWithOutput);
|
||||
|
|
@ -295,7 +280,6 @@ TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithTensorIn
|
|||
EXPECT_EQ(DispatchKey::CUDA, extractDispatchKey(result[0].toTensor()));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
Tensor captured_input;
|
||||
|
||||
void kernelWithTensorInputByReferenceWithoutOutput(const Tensor& input1) {
|
||||
|
|
@ -306,7 +290,6 @@ void kernelWithTensorInputByValueWithoutOutput(Tensor input1) {
|
|||
captured_input = input1;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithTensorInputByReference_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_input(Tensor input) -> ()", &kernelWithTensorInputByReferenceWithoutOutput);
|
||||
|
|
@ -323,7 +306,6 @@ TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithTensorIn
|
|||
EXPECT_EQ(DispatchKey::CUDA, extractDispatchKey(captured_input));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithTensorInputByValue_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_input(Tensor input) -> ()", &kernelWithTensorInputByValueWithoutOutput);
|
||||
|
|
@ -340,14 +322,12 @@ TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithTensorIn
|
|||
EXPECT_EQ(DispatchKey::CUDA, extractDispatchKey(captured_input));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
int64_t captured_int_input = 0;
|
||||
|
||||
void kernelWithIntInputWithoutOutput(Tensor, int64_t input1) {
|
||||
captured_int_input = input1;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithIntInput_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::int_input(Tensor dummy, int input) -> ()", &kernelWithIntInputWithoutOutput);
|
||||
|
|
@ -365,7 +345,6 @@ int64_t kernelWithIntInputWithOutput(Tensor, int64_t input1) {
|
|||
return input1 + 1;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithIntInput_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::int_input(Tensor dummy, int input) -> int", &kernelWithIntInputWithOutput);
|
||||
|
|
@ -378,14 +357,12 @@ TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithIntInput
|
|||
EXPECT_EQ(4, outputs[0].toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
int64_t captured_input_list_size = 0;
|
||||
|
||||
void kernelWithIntListInputWithoutOutput(Tensor, const std::vector<int64_t>& input1) {
|
||||
captured_input_list_size = input1.size();
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithIntListInput_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::int_list_input(Tensor dummy, int[] input) -> ()", &kernelWithIntListInputWithoutOutput);
|
||||
|
|
@ -403,7 +380,6 @@ int64_t kernelWithIntListInputWithOutput(Tensor, const std::vector<int64_t>& inp
|
|||
return input1.size();
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithIntListInput_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::int_list_input(Tensor dummy, int[] input) -> int", &kernelWithIntListInputWithOutput);
|
||||
|
|
@ -420,7 +396,6 @@ void kernelWithTensorListInputWithoutOutput(const std::vector<Tensor>& input1) {
|
|||
captured_input_list_size = input1.size();
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithTensorListInput_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_list_input(Tensor[] input) -> ()", &kernelWithTensorListInputWithoutOutput);
|
||||
|
|
@ -438,7 +413,6 @@ int64_t kernelWithTensorListInputWithOutput(const std::vector<Tensor>& input1) {
|
|||
return input1.size();
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithTensorListInput_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_list_input(Tensor[] input) -> int", &kernelWithTensorListInputWithOutput);
|
||||
|
|
@ -455,7 +429,6 @@ void kernelWithLegacyTensorVectorInputWithoutOutput(const std::vector<Tensor>& i
|
|||
captured_input_list_size = input1.size();
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithLegacyTensorVectorInput_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_list_input(Tensor[] input) -> ()", &kernelWithLegacyTensorVectorInputWithoutOutput);
|
||||
|
|
@ -473,7 +446,6 @@ int64_t kernelWithLegacyTensorVectorInputWithOutput(const std::vector<Tensor>& i
|
|||
return input1.size();
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithLegacyTensorVectorInput_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_list_input(Tensor[] input) -> int", &kernelWithLegacyTensorVectorInputWithOutput);
|
||||
|
|
@ -490,7 +462,6 @@ void kernelWithLegacyTensorListInputWithoutOutput(std::vector<Tensor> input1) {
|
|||
captured_input_list_size = input1.size();
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithLegacyTensorListInput_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_list_input(Tensor[] input) -> ()", &kernelWithLegacyTensorListInputWithoutOutput);
|
||||
|
|
@ -508,7 +479,6 @@ int64_t kernelWithLegacyTensorListInputWithOutput(std::vector<Tensor> input1) {
|
|||
return input1.size();
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithLegacyTensorListInput_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_list_input(Tensor[] input) -> int", &kernelWithLegacyTensorListInputWithOutput);
|
||||
|
|
@ -525,7 +495,6 @@ std::vector<std::string> kernelWithStringListOutput(std::vector<std::string> inp
|
|||
return input;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithStringListOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::stringlist_output(str[] input) -> str[]", &kernelWithStringListOutput);
|
||||
|
|
@ -543,14 +512,12 @@ TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithStringLi
|
|||
EXPECT_EQ("value2", output.get(1).toString()->string());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
int captured_dict_size = 0;
|
||||
|
||||
void kernelWithDictInputWithoutOutput(Dict<string, Tensor> input1) {
|
||||
captured_dict_size = input1.size();
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithDictInput_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::dict_input(Dict(str, Tensor) input) -> ()", &kernelWithDictInputWithoutOutput);
|
||||
|
|
@ -571,7 +538,6 @@ string kernelWithDictInputWithOutput(Dict<string, string> input1) {
|
|||
return input1.at("key2");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithDictInput_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::dict_input(Dict(str, str) input) -> str", &kernelWithDictInputWithOutput);
|
||||
|
|
@ -591,7 +557,6 @@ Dict<string, string> kernelWithDictOutput(Dict<string, string> input) {
|
|||
return input;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithDictOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::dict_output(Dict(str, str) input) -> Dict(str, str)", &kernelWithDictOutput);
|
||||
|
|
@ -615,7 +580,6 @@ void kernelWithUnorderedMapInputWithoutOutput(std::unordered_map<string, Tensor>
|
|||
captured_dict_size = input1.size();
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithUnorderedMapInput_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::dict_input(Dict(str, Tensor) input) -> ()", &kernelWithUnorderedMapInputWithoutOutput);
|
||||
|
|
@ -636,7 +600,6 @@ string kernelWithUnorderedMapInputWithOutput(std::unordered_map<string, string>
|
|||
return input1.at("key2");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithUnorderedMapInput_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::dict_input(Dict(str, str) input) -> str", &kernelWithUnorderedMapInputWithOutput);
|
||||
|
|
@ -656,7 +619,6 @@ std::unordered_map<string, string> kernelWithUnorderedMapOutput(std::unordered_m
|
|||
return input;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithUnorderedMapOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::dict_output(Dict(str, str) input) -> Dict(str, str)", &kernelWithUnorderedMapOutput);
|
||||
|
|
@ -680,7 +642,6 @@ std::unordered_map<string, std::vector<int64_t>> kernelWithMapOfIntList(std::uno
|
|||
return input;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithMapOfList_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::dict_output(Dict(str, int[]) input) -> Dict(str, int[])", &kernelWithMapOfIntList);
|
||||
|
|
@ -708,7 +669,6 @@ std::unordered_map<string, std::vector<std::unordered_map<int64_t, string>>> ker
|
|||
return input;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithMapOfListOfMap_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::dict_output(Dict(str, Dict(int,str)[]) input) -> Dict(str, Dict(int,str)[])", &kernelWithMapOfListOfMap);
|
||||
|
|
@ -743,7 +703,6 @@ std::vector<std::unordered_map<string, int64_t>> kernelWithListOfMap(std::vector
|
|||
return input;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithListOfMap_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::list_output(Dict(str, int)[] input) -> Dict(str, int)[]", &kernelWithListOfMap);
|
||||
|
|
@ -775,7 +734,6 @@ std::vector<std::unordered_map<string, std::vector<int64_t>>> kernelWithListOfMa
|
|||
return input;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithListOfMapOfIntList_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::list_output(Dict(str, int[])[] input) -> Dict(str, int[])[]", &kernelWithListOfMapOfIntList);
|
||||
|
|
@ -810,14 +768,12 @@ TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithListOfMa
|
|||
EXPECT_EQ(8, output.get(1).toGenericDict().at("7").toIntVector()[1]);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
bool called = false;
|
||||
|
||||
void kernelWithoutInputs() {
|
||||
called = true;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenFallbackKernelWithoutAnyArguments_whenRegistered_thenCanBeCalled) {
|
||||
// note: non-fallback kernels without tensor arguments don't work because there
|
||||
// is no way to get the dispatch key. For operators that only have a fallback
|
||||
|
|
@ -837,7 +793,6 @@ int64_t kernelWithoutTensorInputs(int64_t arg) {
|
|||
return arg + 1;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenFallbackKernelWithoutTensorArguments_whenRegistered_thenCanBeCalled) {
|
||||
// note: non-fallback kernels without tensor arguments don't work because there
|
||||
// is no way to get the dispatch key. For operators that only have a fallback
|
||||
|
|
@ -853,11 +808,8 @@ TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenFallbackKernelWith
|
|||
EXPECT_EQ(4, outputs[0].toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
c10::optional<Tensor> called_arg2 = c10::nullopt;
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
c10::optional<int64_t> called_arg3 = c10::nullopt;
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
c10::optional<std::string> called_arg4 = c10::nullopt;
|
||||
|
||||
void kernelWithOptInputWithoutOutput(Tensor arg1, const c10::optional<Tensor>& arg2, c10::optional<int64_t> arg3, c10::optional<std::string> arg4) {
|
||||
|
|
@ -867,7 +819,6 @@ void kernelWithOptInputWithoutOutput(Tensor arg1, const c10::optional<Tensor>& a
|
|||
called_arg4 = arg4;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithOptionalInputs_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op("_test::opt_input(Tensor arg1, Tensor? arg2, int? arg3, str? arg4) -> ()", &kernelWithOptInputWithoutOutput);
|
||||
auto op = c10::Dispatcher::singleton().findSchema({"_test::opt_input", ""});
|
||||
|
|
@ -903,7 +854,6 @@ c10::optional<Tensor> kernelWithOptInputWithOutput(Tensor arg1, const c10::optio
|
|||
return arg2;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithOptionalInputs_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op("_test::opt_input(Tensor arg1, Tensor? arg2, int? arg3, str? arg4) -> Tensor?", &kernelWithOptInputWithOutput);
|
||||
auto op = c10::Dispatcher::singleton().findSchema({"_test::opt_input", ""});
|
||||
|
|
@ -938,7 +888,6 @@ kernelWithOptInputWithMultipleOutputs(Tensor arg1, const c10::optional<Tensor>&
|
|||
return std::make_tuple(arg2, arg3, arg4);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernelWithOptionalInputs_withMultipleOutputs_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op("_test::opt_input(Tensor arg1, Tensor? arg2, int? arg3, str? arg4) -> (Tensor?, int?, str?)", &kernelWithOptInputWithMultipleOutputs);
|
||||
auto op = c10::Dispatcher::singleton().findSchema({"_test::opt_input", ""});
|
||||
|
|
@ -971,7 +920,6 @@ void expectCallsConcatUnboxed(DispatchKey dispatch_key) {
|
|||
EXPECT_EQ("123", result);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernel_whenRegistered_thenCanBeCalledUnboxed) {
|
||||
auto registrar = RegisterOperators().op("_test::my_op(Tensor dummy, str a, str b, int c) -> str", &concatKernel);
|
||||
expectCallsConcatUnboxed(DispatchKey::CPU);
|
||||
|
|
@ -981,7 +929,6 @@ std::tuple<int64_t, Tensor> kernelForSchemaInference(Tensor arg1, int64_t arg2,
|
|||
return {};
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenKernel_whenRegisteredWithoutSpecifyingSchema_thenInfersSchema) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::no_schema_specified", &kernelForSchemaInference);
|
||||
|
|
@ -1000,7 +947,6 @@ template<class... Args> struct kernel_func<void, Args...> final {
|
|||
static void func(Args...) {}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenMismatchedKernel_withDifferentNumArguments_whenRegistering_thenFails) {
|
||||
// assert this does not fail because it matches
|
||||
RegisterOperators()
|
||||
|
|
@ -1037,7 +983,6 @@ TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenMismatchedKernel_w
|
|||
);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenMismatchedKernel_withDifferentArgumentType_whenRegistering_thenFails) {
|
||||
// assert this does not fail because it matches
|
||||
RegisterOperators()
|
||||
|
|
@ -1057,7 +1002,6 @@ TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenMismatchedKernel_w
|
|||
);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenMismatchedKernel_withDifferentNumReturns_whenRegistering_thenFails) {
|
||||
// assert this does not fail because it matches
|
||||
RegisterOperators()
|
||||
|
|
@ -1117,7 +1061,6 @@ TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenMismatchedKernel_w
|
|||
);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyFunctionBasedKernel, givenMismatchedKernel_withDifferentReturnTypes_whenRegistering_thenFails) {
|
||||
// assert this does not fail because it matches
|
||||
RegisterOperators()
|
||||
|
|
|
|||
|
|
@ -55,13 +55,11 @@ void expectCallsDecrement(DispatchKey dispatch_key) {
|
|||
EXPECT_EQ(4, result[0].toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernel_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op("_test::my_op(Tensor dummy, int input) -> int", RegisterOperators::options().kernel<decltype(incrementKernel), &incrementKernel>(DispatchKey::CPU));
|
||||
expectCallsIncrement(DispatchKey::CPU);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernel_whenRegisteredWithTorchLibraryAndTorchFn_thenCanBeCalled) {
|
||||
auto m = MAKE_TORCH_LIBRARY(_test);
|
||||
m.def("my_op(Tensor dummy, int input) -> int");
|
||||
|
|
@ -69,14 +67,12 @@ TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernel_whenRegisteredWit
|
|||
expectCallsIncrement(DispatchKey::CPU);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenCatchAllKernel_whenRegisteredWithTorchLibraryAndTorchFn_thenCanBeCalled) {
|
||||
auto m = MAKE_TORCH_LIBRARY(_test);
|
||||
m.def("my_op(Tensor dummy, int input) -> int", TORCH_FN(incrementKernel));
|
||||
expectCallsIncrement(DispatchKey::CPU);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenMultipleOperatorsAndKernels_whenRegisteredInOneRegistrar_thenCallsRightKernel) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::my_op(Tensor dummy, int input) -> int", RegisterOperators::options().kernel<decltype(incrementKernel), &incrementKernel>(DispatchKey::CPU)
|
||||
|
|
@ -86,7 +82,6 @@ TEST(OperatorRegistrationTest_FunctionBasedKernel, givenMultipleOperatorsAndKern
|
|||
expectCallsIncrement(DispatchKey::CPU);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenMultipleOperatorsAndKernels_whenRegisteredInMultipleRegistrars_thenCallsRightKernel) {
|
||||
auto registrar1 = RegisterOperators().op("_test::my_op(Tensor dummy, int input) -> int", RegisterOperators::options().kernel<decltype(incrementKernel), &incrementKernel>(DispatchKey::CPU)
|
||||
.kernel<decltype(errorKernel), &errorKernel>(DispatchKey::CUDA));
|
||||
|
|
@ -96,7 +91,6 @@ TEST(OperatorRegistrationTest_FunctionBasedKernel, givenMultipleOperatorsAndKern
|
|||
}
|
||||
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(NewOperatorRegistrationTest_FunctionBasedKernel, givenKernel_whenRegistrationRunsOutOfScope_thenCannotBeCalledAnymore) {
|
||||
{
|
||||
auto m = MAKE_TORCH_LIBRARY(_test);
|
||||
|
|
@ -121,14 +115,12 @@ TEST(NewOperatorRegistrationTest_FunctionBasedKernel, givenKernel_whenRegistrati
|
|||
expectDoesntFindOperator("_test::my_op");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
bool was_called = false;
|
||||
|
||||
void kernelWithoutOutput(const Tensor&) {
|
||||
was_called = true;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op("_test::no_return(Tensor dummy) -> ()", RegisterOperators::options().kernel<decltype(kernelWithoutOutput), &kernelWithoutOutput>(DispatchKey::CPU));
|
||||
|
||||
|
|
@ -145,7 +137,6 @@ std::tuple<> kernelWithZeroOutputs(const Tensor&) {
|
|||
return std::make_tuple();
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithZeroOutputs_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op("_test::zero_outputs(Tensor dummy) -> ()", RegisterOperators::options().kernel<decltype(kernelWithZeroOutputs), &kernelWithZeroOutputs>(DispatchKey::CPU));
|
||||
|
||||
|
|
@ -161,7 +152,6 @@ int64_t kernelWithIntOutput(Tensor, int64_t a, int64_t b) {
|
|||
return a + b;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithIntOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::int_output(Tensor dummy, int a, int b) -> int", RegisterOperators::options().kernel<decltype(kernelWithIntOutput), &kernelWithIntOutput>(DispatchKey::CPU));
|
||||
|
|
@ -178,7 +168,6 @@ Tensor kernelWithTensorOutput(const Tensor& input) {
|
|||
return input;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithTensorOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::returning_tensor(Tensor input) -> Tensor", RegisterOperators::options().kernel<decltype(kernelWithTensorOutput), &kernelWithTensorOutput>(DispatchKey::CPU)
|
||||
|
|
@ -200,7 +189,6 @@ c10::List<Tensor> kernelWithTensorListOutput(const Tensor& input1, const Tensor&
|
|||
return c10::List<Tensor>({input1, input2, input3});
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithTensorListOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::list_output(Tensor input1, Tensor input2, Tensor input3) -> Tensor[]", RegisterOperators::options().kernel<decltype(kernelWithTensorListOutput), &kernelWithTensorListOutput>(DispatchKey::CUDA));
|
||||
|
|
@ -220,7 +208,6 @@ c10::List<int64_t> kernelWithIntListOutput(const Tensor&, int64_t input1, int64_
|
|||
return c10::List<int64_t>({input1, input2, input3});
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithIntListOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::list_output(Tensor dummy, int input1, int input2, int input3) -> int[]", RegisterOperators::options().kernel<decltype(kernelWithIntListOutput), &kernelWithIntListOutput>(DispatchKey::CPU));
|
||||
|
|
@ -249,7 +236,6 @@ std::tuple<Tensor, int64_t, c10::List<Tensor>, c10::optional<int64_t>, Dict<stri
|
|||
);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithMultipleOutputs_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::multiple_outputs(Tensor dummy) -> (Tensor, int, Tensor[], int?, Dict(str, Tensor))", RegisterOperators::options().kernel<decltype(kernelWithMultipleOutputs), &kernelWithMultipleOutputs>(DispatchKey::CPU));
|
||||
|
|
@ -279,7 +265,6 @@ Tensor kernelWithTensorInputByValueWithOutput(Tensor input1) {
|
|||
return input1;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithTensorInputByReference_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_input(Tensor input) -> Tensor", RegisterOperators::options().kernel<decltype(kernelWithTensorInputByReferenceWithOutput), &kernelWithTensorInputByReferenceWithOutput>(DispatchKey::CPU)
|
||||
|
|
@ -297,7 +282,6 @@ TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithTensorInputByR
|
|||
EXPECT_EQ(DispatchKey::CUDA, extractDispatchKey(result[0].toTensor()));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithTensorInputByValue_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_input(Tensor input) -> Tensor", RegisterOperators::options().kernel<decltype(kernelWithTensorInputByValueWithOutput), &kernelWithTensorInputByValueWithOutput>(DispatchKey::CPU)
|
||||
|
|
@ -315,7 +299,6 @@ TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithTensorInputByV
|
|||
EXPECT_EQ(DispatchKey::CUDA, extractDispatchKey(result[0].toTensor()));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
Tensor captured_input;
|
||||
|
||||
void kernelWithTensorInputByReferenceWithoutOutput(const Tensor& input1) {
|
||||
|
|
@ -326,7 +309,6 @@ void kernelWithTensorInputByValueWithoutOutput(Tensor input1) {
|
|||
captured_input = input1;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithTensorInputByReference_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_input(Tensor input) -> ()", RegisterOperators::options().kernel<decltype(kernelWithTensorInputByReferenceWithoutOutput), &kernelWithTensorInputByReferenceWithoutOutput>(DispatchKey::CPU)
|
||||
|
|
@ -344,7 +326,6 @@ TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithTensorInputByR
|
|||
EXPECT_EQ(DispatchKey::CUDA, extractDispatchKey(captured_input));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithTensorInputByValue_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_input(Tensor input) -> ()", RegisterOperators::options().kernel<decltype(kernelWithTensorInputByValueWithoutOutput), &kernelWithTensorInputByValueWithoutOutput>(DispatchKey::CPU)
|
||||
|
|
@ -362,14 +343,12 @@ TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithTensorInputByV
|
|||
EXPECT_EQ(DispatchKey::CUDA, extractDispatchKey(captured_input));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
int64_t captured_int_input = 0;
|
||||
|
||||
void kernelWithIntInputWithoutOutput(Tensor, int64_t input1) {
|
||||
captured_int_input = input1;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithIntInput_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::int_input(Tensor dummy, int input) -> ()", RegisterOperators::options().kernel<decltype(kernelWithIntInputWithoutOutput), &kernelWithIntInputWithoutOutput>(DispatchKey::CPU));
|
||||
|
|
@ -387,7 +366,6 @@ int64_t kernelWithIntInputWithOutput(Tensor, int64_t input1) {
|
|||
return input1 + 1;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithIntInput_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::int_input(Tensor dummy, int input) -> int", RegisterOperators::options().kernel<decltype(kernelWithIntInputWithOutput), &kernelWithIntInputWithOutput>(DispatchKey::CPU));
|
||||
|
|
@ -400,14 +378,12 @@ TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithIntInput_withO
|
|||
EXPECT_EQ(4, outputs[0].toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
int64_t captured_input_list_size = 0;
|
||||
|
||||
void kernelWithIntListInputWithoutOutput(Tensor, const c10::List<int64_t>& input1) {
|
||||
captured_input_list_size = input1.size();
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithIntListInput_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::int_list_input(Tensor dummy, int[] input) -> ()", RegisterOperators::options().kernel<decltype(kernelWithIntListInputWithoutOutput), &kernelWithIntListInputWithoutOutput>(DispatchKey::CPU));
|
||||
|
|
@ -425,7 +401,6 @@ int64_t kernelWithIntListInputWithOutput(Tensor, const c10::List<int64_t>& input
|
|||
return input1.size();
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithIntListInput_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::int_list_input(Tensor dummy, int[] input) -> int", RegisterOperators::options().kernel<decltype(kernelWithIntListInputWithOutput), &kernelWithIntListInputWithOutput>(DispatchKey::CPU));
|
||||
|
|
@ -442,7 +417,6 @@ void kernelWithTensorListInputWithoutOutput(const c10::List<Tensor>& input1) {
|
|||
captured_input_list_size = input1.size();
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithTensorListInput_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_list_input(Tensor[] input) -> ()", RegisterOperators::options().kernel<decltype(kernelWithTensorListInputWithoutOutput), &kernelWithTensorListInputWithoutOutput>(DispatchKey::CPU));
|
||||
|
|
@ -460,7 +434,6 @@ int64_t kernelWithTensorListInputWithOutput(const c10::List<Tensor>& input1) {
|
|||
return input1.size();
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithTensorListInput_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_list_input(Tensor[] input) -> int", RegisterOperators::options().kernel<decltype(kernelWithTensorListInputWithOutput), &kernelWithTensorListInputWithOutput>(DispatchKey::CPU));
|
||||
|
|
@ -473,14 +446,12 @@ TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithTensorListInpu
|
|||
EXPECT_EQ(2, outputs[0].toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
int captured_dict_size = 0;
|
||||
|
||||
void kernelWithDictInputWithoutOutput(Dict<string, Tensor> input1) {
|
||||
captured_dict_size = input1.size();
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithDictInput_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::dict_input(Dict(str, Tensor) input) -> ()", RegisterOperators::options().catchAllKernel<decltype(kernelWithDictInputWithoutOutput), &kernelWithDictInputWithoutOutput>());
|
||||
|
|
@ -501,7 +472,6 @@ string kernelWithDictInputWithOutput(Dict<string, string> input1) {
|
|||
return input1.at("key2");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithDictInput_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::dict_input(Dict(str, str) input) -> str", RegisterOperators::options().catchAllKernel<decltype(kernelWithDictInputWithOutput), &kernelWithDictInputWithOutput>());
|
||||
|
|
@ -521,7 +491,6 @@ Dict<string, string> kernelWithDictOutput(Dict<string, string> input) {
|
|||
return input;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithDictOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::dict_output(Dict(str, str) input) -> Dict(str, str)", RegisterOperators::options().catchAllKernel<decltype(kernelWithDictOutput), &kernelWithDictOutput>());
|
||||
|
|
@ -541,14 +510,12 @@ TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithDictOutput_whe
|
|||
EXPECT_EQ("value2", output.at("key2"));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
bool called = false;
|
||||
|
||||
void kernelWithoutInputs() {
|
||||
called = true;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenFallbackKernelWithoutAnyArguments_whenRegistered_thenCanBeCalled) {
|
||||
// note: non-fallback kernels without tensor arguments don't work because there
|
||||
// is no way to get the dispatch key. For operators that only have a fallback
|
||||
|
|
@ -568,7 +535,6 @@ int64_t kernelWithoutTensorInputs(int64_t arg) {
|
|||
return arg + 1;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenFallbackKernelWithoutTensorArguments_whenRegistered_thenCanBeCalled) {
|
||||
// note: non-fallback kernels without tensor arguments don't work because there
|
||||
// is no way to get the dispatch key. For operators that only have a fallback
|
||||
|
|
@ -584,11 +550,8 @@ TEST(OperatorRegistrationTest_FunctionBasedKernel, givenFallbackKernelWithoutTen
|
|||
EXPECT_EQ(4, outputs[0].toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
c10::optional<Tensor> called_arg2 = c10::nullopt;
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
c10::optional<int64_t> called_arg3 = c10::nullopt;
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
c10::optional<std::string> called_arg4 = c10::nullopt;
|
||||
|
||||
void kernelWithOptInputWithoutOutput(Tensor arg1, const c10::optional<Tensor>& arg2, c10::optional<int64_t> arg3, c10::optional<std::string> arg4) {
|
||||
|
|
@ -598,7 +561,6 @@ void kernelWithOptInputWithoutOutput(Tensor arg1, const c10::optional<Tensor>& a
|
|||
called_arg4 = arg4;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithOptionalInputs_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op("_test::opt_input(Tensor arg1, Tensor? arg2, int? arg3, str? arg4) -> ()", RegisterOperators::options().kernel<decltype(kernelWithOptInputWithoutOutput), &kernelWithOptInputWithoutOutput>(DispatchKey::CPU));
|
||||
auto op = c10::Dispatcher::singleton().findSchema({"_test::opt_input", ""});
|
||||
|
|
@ -634,7 +596,6 @@ c10::optional<Tensor> kernelWithOptInputWithOutput(Tensor arg1, const c10::optio
|
|||
return arg2;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithOptionalInputs_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op("_test::opt_input(Tensor arg1, Tensor? arg2, int? arg3, str? arg4) -> Tensor?", RegisterOperators::options().kernel<decltype(kernelWithOptInputWithOutput), &kernelWithOptInputWithOutput>(DispatchKey::CPU));
|
||||
auto op = c10::Dispatcher::singleton().findSchema({"_test::opt_input", ""});
|
||||
|
|
@ -669,7 +630,6 @@ kernelWithOptInputWithMultipleOutputs(Tensor arg1, const c10::optional<Tensor>&
|
|||
return std::make_tuple(arg2, arg3, arg4);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernelWithOptionalInputs_withMultipleOutputs_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op("_test::opt_input(Tensor arg1, Tensor? arg2, int? arg3, str? arg4) -> (Tensor?, int?, str?)", RegisterOperators::options().kernel<decltype(kernelWithOptInputWithMultipleOutputs), &kernelWithOptInputWithMultipleOutputs>(DispatchKey::CPU));
|
||||
auto op = c10::Dispatcher::singleton().findSchema({"_test::opt_input", ""});
|
||||
|
|
@ -714,7 +674,6 @@ void expectCannotCallConcatBoxed(DispatchKey dispatch_key) {
|
|||
);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernel_whenRegistered_thenCanBeCalledUnboxed) {
|
||||
auto registrar = RegisterOperators().op("_test::my_op(Tensor dummy, str a, str b, int c) -> str", RegisterOperators::options().kernel<decltype(concatKernel), &concatKernel>(DispatchKey::CPU));
|
||||
expectCallsConcatUnboxed(DispatchKey::CPU);
|
||||
|
|
@ -724,7 +683,6 @@ std::tuple<int64_t, Tensor> kernelForSchemaInference(Tensor arg1, int64_t arg2,
|
|||
return {};
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenKernel_whenRegisteredWithoutSpecifyingSchema_thenInfersSchema) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::no_schema_specified", RegisterOperators::options().catchAllKernel<decltype(kernelForSchemaInference), &kernelForSchemaInference>());
|
||||
|
|
@ -743,7 +701,6 @@ template<class... Args> struct kernel_func<void, Args...> final {
|
|||
static void func(Args...) {}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenMismatchedKernel_withDifferentNumArguments_whenRegistering_thenFails) {
|
||||
// assert this does not fail because it matches
|
||||
RegisterOperators()
|
||||
|
|
@ -780,7 +737,6 @@ TEST(OperatorRegistrationTest_FunctionBasedKernel, givenMismatchedKernel_withDif
|
|||
);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenMismatchedKernel_withDifferentArgumentType_whenRegistering_thenFails) {
|
||||
// assert this does not fail because it matches
|
||||
RegisterOperators()
|
||||
|
|
@ -800,7 +756,6 @@ TEST(OperatorRegistrationTest_FunctionBasedKernel, givenMismatchedKernel_withDif
|
|||
);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenMismatchedKernel_withDifferentNumReturns_whenRegistering_thenFails) {
|
||||
// assert this does not fail because it matches
|
||||
RegisterOperators()
|
||||
|
|
@ -860,7 +815,6 @@ TEST(OperatorRegistrationTest_FunctionBasedKernel, givenMismatchedKernel_withDif
|
|||
);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctionBasedKernel, givenMismatchedKernel_withDifferentReturnTypes_whenRegistering_thenFails) {
|
||||
// assert this does not fail because it matches
|
||||
RegisterOperators()
|
||||
|
|
|
|||
|
|
@ -41,7 +41,6 @@ void expectCallsIncrement(DispatchKey dispatch_key) {
|
|||
EXPECT_EQ(6, result[0].toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernel_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op("_test::my_op(Tensor dummy, int input) -> int", [] (const Tensor& tensor, int64_t input) -> int64_t {
|
||||
return input + 1;
|
||||
|
|
@ -49,7 +48,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernel_whenRegistere
|
|||
expectCallsIncrement(DispatchKey::CPU);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernel_whenRegisteredInConstructor_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators("_test::my_op(Tensor dummy, int input) -> int", [] (const Tensor& tensor, int64_t input) -> int64_t {
|
||||
return input + 1;
|
||||
|
|
@ -57,7 +55,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernel_whenRegistere
|
|||
expectCallsIncrement(DispatchKey::CPU);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenMultipleOperatorsAndKernels_whenRegisteredInOneRegistrar_thenCallsRightKernel) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::my_op(Tensor dummy, int input) -> int", [] (const Tensor& tensor, int64_t input) -> int64_t {
|
||||
|
|
@ -70,7 +67,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenMultipleOperatorsAnd
|
|||
expectCallsIncrement(DispatchKey::CPU);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenMultipleOperatorsAndKernels_whenRegisteredInMultipleRegistrars_thenCallsRightKernel) {
|
||||
auto registrar1 = RegisterOperators().op("_test::my_op(Tensor dummy, int input) -> int", [] (const Tensor& tensor, int64_t input) -> int64_t {
|
||||
return input + 1;
|
||||
|
|
@ -82,7 +78,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenMultipleOperatorsAnd
|
|||
expectCallsIncrement(DispatchKey::CPU);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernel_whenRegistrationRunsOutOfScope_thenCannotBeCalledAnymore) {
|
||||
{
|
||||
auto registrar = RegisterOperators().op("_test::my_op(Tensor dummy, int input) -> int", [] (const Tensor& tensor, int64_t input) -> int64_t {
|
||||
|
|
@ -96,10 +91,8 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernel_whenRegistrat
|
|||
expectDoesntFindOperator("_test::my_op");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
bool was_called = false;
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op("_test::no_return(Tensor dummy) -> ()", [] (const Tensor&) -> void {
|
||||
was_called = true;
|
||||
|
|
@ -113,7 +106,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithoutOutput_
|
|||
EXPECT_EQ(0, result.size());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithZeroOutputs_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op("_test::zero_outputs(Tensor dummy) -> ()", [] (const Tensor&) -> std::tuple<> {
|
||||
was_called = true;
|
||||
|
|
@ -128,7 +120,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithZeroOutput
|
|||
EXPECT_EQ(0, result.size());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithIntOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::int_output(Tensor dummy, int a, int b) -> int", [] (Tensor, int64_t a, int64_t b) -> int64_t {
|
||||
|
|
@ -143,7 +134,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithIntOutput_
|
|||
EXPECT_EQ(9, result[0].toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithTensorOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::returning_tensor(Tensor input) -> Tensor", [] (const Tensor& input) -> Tensor {
|
||||
|
|
@ -162,7 +152,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithTensorOutp
|
|||
EXPECT_EQ(DispatchKey::CUDA, extractDispatchKey(result[0].toTensor()));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithTensorListOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::list_output(Tensor input1, Tensor input2, Tensor input3) -> Tensor[]", [] (const Tensor& input1, const Tensor& input2, const Tensor& input3) -> std::vector<Tensor> {
|
||||
|
|
@ -180,7 +169,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithTensorList
|
|||
EXPECT_EQ(DispatchKey::CPU, extractDispatchKey(result[0].toTensorVector()[2]));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithIntListOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::list_output(Tensor dummy, int input1, int input2, int input3) -> int[]", [](const Tensor&, int64_t input1, int64_t input2, int64_t input3) -> std::vector<int64_t> {
|
||||
|
|
@ -198,7 +186,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithIntListOut
|
|||
EXPECT_EQ(6, result[0].toIntVector()[2]);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithMultipleOutputs_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::multiple_outputs(Tensor dummy) -> (Tensor, int, Tensor[], int?, Dict(str, Tensor))", [] (Tensor) -> std::tuple<Tensor, int64_t, std::vector<Tensor>, c10::optional<int64_t>, Dict<string, Tensor>> {
|
||||
|
|
@ -231,7 +218,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithMultipleOu
|
|||
EXPECT_EQ(DispatchKey::CUDA, extractDispatchKey(result_dict.at("second")));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithTensorInputByReference_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_input(Tensor input) -> Tensor", [] (const Tensor& input1) -> Tensor {
|
||||
|
|
@ -250,7 +236,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithTensorInpu
|
|||
EXPECT_EQ(DispatchKey::CUDA, extractDispatchKey(result[0].toTensor()));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithTensorInputByValue_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_input(Tensor input) -> Tensor", [](Tensor input1) -> Tensor {
|
||||
|
|
@ -269,10 +254,8 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithTensorInpu
|
|||
EXPECT_EQ(DispatchKey::CUDA, extractDispatchKey(result[0].toTensor()));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
Tensor captured_input;
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithTensorInputByReference_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_input(Tensor input) -> ()", [] (const Tensor& input1) -> void {
|
||||
|
|
@ -291,7 +274,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithTensorInpu
|
|||
EXPECT_EQ(DispatchKey::CUDA, extractDispatchKey(captured_input));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithTensorInputByValue_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_input(Tensor input) -> ()", [] (Tensor input1) -> void {
|
||||
|
|
@ -310,10 +292,8 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithTensorInpu
|
|||
EXPECT_EQ(DispatchKey::CUDA, extractDispatchKey(captured_input));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
int64_t captured_int_input = 0;
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithIntInput_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::int_input(Tensor dummy, int input) -> ()", [](Tensor, int64_t input1) -> void {
|
||||
|
|
@ -329,7 +309,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithIntInput_w
|
|||
EXPECT_EQ(3, captured_int_input);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithIntInput_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::int_input(Tensor dummy, int input) -> int", [] (Tensor, int64_t input1) -> int64_t {
|
||||
|
|
@ -344,10 +323,8 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithIntInput_w
|
|||
EXPECT_EQ(4, outputs[0].toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
int64_t captured_input_list_size = 0;
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithIntListInput_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::int_list_input(Tensor dummy, int[] input) -> ()", [] (Tensor, const std::vector<int64_t>& input1) -> void {
|
||||
|
|
@ -363,7 +340,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithIntListInp
|
|||
EXPECT_EQ(3, captured_input_list_size);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithIntListInput_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::int_list_input(Tensor dummy, int[] input) -> int", [](Tensor, const std::vector<int64_t>& input1) -> int64_t {
|
||||
|
|
@ -378,7 +354,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithIntListInp
|
|||
EXPECT_EQ(3, outputs[0].toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithTensorListInput_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_list_input(Tensor[] input) -> ()", [] (const std::vector<Tensor>& input1) -> void {
|
||||
|
|
@ -394,7 +369,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithTensorList
|
|||
EXPECT_EQ(2, captured_input_list_size);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithTensorVectorInput_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_list_input(Tensor[] input) -> int", [] (const std::vector<Tensor>& input1) -> int64_t {
|
||||
|
|
@ -409,7 +383,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithTensorVect
|
|||
EXPECT_EQ(2, outputs[0].toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithLegacyTensorVectorInput_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_list_input(Tensor[] input) -> ()", [] (const std::vector<Tensor>& input1) -> void {
|
||||
|
|
@ -425,7 +398,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithLegacyTens
|
|||
EXPECT_EQ(2, captured_input_list_size);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithLegacyTensorVectorInput_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_list_input(Tensor[] input) -> int", [] (const std::vector<Tensor>& input1) -> int64_t {
|
||||
|
|
@ -440,7 +412,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithLegacyTens
|
|||
EXPECT_EQ(2, outputs[0].toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithLegacyTensorListInput_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_list_input(Tensor[] input) -> ()", [] (std::vector<Tensor> input1) -> void {
|
||||
|
|
@ -456,7 +427,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithLegacyTens
|
|||
EXPECT_EQ(2, captured_input_list_size);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithLegacyTensorListInput_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_list_input(Tensor[] input) -> int", [] (std::vector<Tensor> input1) -> int64_t {
|
||||
|
|
@ -471,7 +441,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithLegacyTens
|
|||
EXPECT_EQ(2, outputs[0].toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithStringListOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::stringlist_output(str[] input) -> str[]", [](std::vector<std::string> input) {
|
||||
|
|
@ -491,7 +460,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithStringList
|
|||
EXPECT_EQ("value2", output.get(1).toString()->string());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithDictInput_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
int captured_dict_size = 0;
|
||||
|
||||
|
|
@ -512,7 +480,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithDictInput_
|
|||
EXPECT_EQ(2, captured_dict_size);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithDictInput_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::dict_input(Dict(str, str) input) -> str", [&] (Dict<string, string> input1) {
|
||||
|
|
@ -530,7 +497,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithDictInput_
|
|||
EXPECT_EQ("value2", outputs[0].toString()->string());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithDictOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::dict_output(Dict(str, str) input) -> Dict(str, str)", [] (Dict<string, string> input) {
|
||||
|
|
@ -552,7 +518,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithDictOutput
|
|||
EXPECT_EQ("value2", output.at("key2"));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithUnorderedMapInput_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
int captured_dict_size = 0;
|
||||
|
||||
|
|
@ -573,7 +538,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithUnorderedM
|
|||
EXPECT_EQ(2, captured_dict_size);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithUnorderedMapInput_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::dict_input(Dict(str, str) input) -> str", [&] (std::unordered_map<string, string> input1) {
|
||||
|
|
@ -591,7 +555,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithUnorderedM
|
|||
EXPECT_EQ("value2", outputs[0].toString()->string());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithUnorderedMapOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::dict_output(Dict(str, str) input) -> Dict(str, str)", [] (std::unordered_map<string, string> input) {
|
||||
|
|
@ -613,7 +576,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithUnorderedM
|
|||
EXPECT_EQ("value2", output.at("key2"));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithMapOfList_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::dict_output(Dict(str, int[]) input) -> Dict(str, int[])", [](std::unordered_map<string, std::vector<int64_t>> input) {
|
||||
|
|
@ -640,7 +602,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithMapOfList_
|
|||
}
|
||||
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithMapOfListOfMap_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::dict_output(Dict(str, Dict(int,str)[]) input) -> Dict(str, Dict(int,str)[])", [](std::unordered_map<string, std::vector<std::unordered_map<int64_t, string>>> input) {
|
||||
|
|
@ -673,7 +634,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithMapOfListO
|
|||
EXPECT_EQ("40", output.at("key2").get(0).at(40));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithListOfMap_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::list_output(Dict(str, int)[] input) -> Dict(str, int)[]", [](std::vector<std::unordered_map<string, int64_t>> input) {
|
||||
|
|
@ -703,7 +663,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithListOfMap_
|
|||
EXPECT_EQ(4, output.get(1).toGenericDict().at("4").toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithListOfMapOfIntList_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::list_output(Dict(str, int[])[] input) -> Dict(str, int[])[]", [](std::vector<std::unordered_map<string, std::vector<int64_t>>> input) {
|
||||
|
|
@ -740,7 +699,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithListOfMapO
|
|||
EXPECT_EQ(8, output.get(1).toGenericDict().at("7").toIntVector()[1]);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenFallbackKernelWithoutAnyArguments_whenRegistered_thenCanBeCalled) {
|
||||
// note: non-fallback kernels without tensor arguments don't work because there
|
||||
// is no way to get the dispatch key. For operators that only have a fallback
|
||||
|
|
@ -757,7 +715,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenFallbackKernelWithou
|
|||
EXPECT_TRUE(called);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenFallbackKernelWithoutTensorArguments_whenRegistered_thenCanBeCalled) {
|
||||
// note: non-fallback kernels without tensor arguments don't work because there
|
||||
// is no way to get the dispatch key. For operators that only have a fallback
|
||||
|
|
@ -773,7 +730,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenFallbackKernelWithou
|
|||
EXPECT_EQ(4, outputs[0].toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithOptionalInputs_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-init-variables)
|
||||
bool called;
|
||||
|
|
@ -814,7 +770,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithOptionalIn
|
|||
EXPECT_FALSE(called_arg4.has_value());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithOptionalInputs_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-init-variables)
|
||||
bool called;
|
||||
|
|
@ -858,7 +813,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithOptionalIn
|
|||
EXPECT_FALSE(called_arg4.has_value());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernelWithOptionalInputs_withMultipleOutputs_whenRegistered_thenCanBeCalled) {
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-init-variables)
|
||||
bool called;
|
||||
|
|
@ -897,7 +851,6 @@ void expectCallsConcatUnboxed(DispatchKey dispatch_key) {
|
|||
EXPECT_EQ("prefix123", result);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernel_whenRegistered_thenCanBeCalledUnboxed) {
|
||||
std::string prefix = "prefix";
|
||||
auto registrar = RegisterOperators().op("_test::my_op(Tensor dummy, str a, str b, int c) -> str", [&] (const Tensor& tensor1, std::string a, const std::string& b, int64_t c) {
|
||||
|
|
@ -906,7 +859,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernel_whenRegistere
|
|||
expectCallsConcatUnboxed(DispatchKey::CPU);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernel_whenRegisteredWithoutSpecifyingSchema_thenInfersSchema) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::no_schema_specified", [] (Tensor arg1, int64_t arg2, const std::vector<Tensor>& arg3) -> std::tuple<int64_t, Tensor> {return {};});
|
||||
|
|
@ -918,7 +870,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenKernel_whenRegistere
|
|||
EXPECT_FALSE(differences.has_value());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenMismatchedKernel_withDifferentNumArguments_whenRegistering_thenFails) {
|
||||
// assert this does not fail because it matches
|
||||
RegisterOperators()
|
||||
|
|
@ -955,7 +906,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenMismatchedKernel_wit
|
|||
);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenMismatchedKernel_withDifferentArgumentType_whenRegistering_thenFails) {
|
||||
// assert this does not fail because it matches
|
||||
RegisterOperators()
|
||||
|
|
@ -975,7 +925,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenMismatchedKernel_wit
|
|||
);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenMismatchedKernel_withDifferentNumReturns_whenRegistering_thenFails) {
|
||||
// assert this does not fail because it matches
|
||||
RegisterOperators()
|
||||
|
|
@ -1035,7 +984,6 @@ TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenMismatchedKernel_wit
|
|||
);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LegacyLambdaBasedKernel, givenMismatchedKernel_withDifferentReturnTypes_whenRegistering_thenFails) {
|
||||
// assert this does not fail because it matches
|
||||
RegisterOperators()
|
||||
|
|
|
|||
|
|
@ -42,20 +42,17 @@ void expectCallsDecrement(DispatchKey dispatch_key) {
|
|||
EXPECT_EQ(4, result[0].toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernel_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op("_test::my_op(Tensor dummy, int input) -> int", RegisterOperators::options().kernel(DispatchKey::CPU, [] (Tensor, int64_t i) {return i+1;}));
|
||||
expectCallsIncrement(DispatchKey::CPU);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenOutOfLineKernel_whenRegistered_thenCanBeCalled) {
|
||||
auto my_kernel = [] (Tensor, int64_t i) {return i+1;};
|
||||
auto registrar = RegisterOperators().op("_test::my_op(Tensor dummy, int input) -> int", RegisterOperators::options().kernel(DispatchKey::CPU, my_kernel));
|
||||
expectCallsIncrement(DispatchKey::CPU);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenMultipleOperatorsAndKernels_whenRegisteredInOneRegistrar_thenCallsRightKernel) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::my_op(Tensor dummy, int input) -> int", RegisterOperators::options().kernel(DispatchKey::CPU, [] (Tensor, int64_t i) {return i+1;})
|
||||
|
|
@ -65,7 +62,6 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenMultipleOperatorsAndKernel
|
|||
expectCallsIncrement(DispatchKey::CPU);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenMultipleOperatorsAndKernels_whenRegisteredInMultipleRegistrars_thenCallsRightKernel) {
|
||||
auto registrar1 = RegisterOperators().op("_test::my_op(Tensor dummy, int input) -> int", RegisterOperators::options().kernel(DispatchKey::CPU, [] (Tensor, int64_t i) {return i+1;})
|
||||
.kernel(DispatchKey::CUDA, [] (Tensor, int64_t) -> int64_t {EXPECT_TRUE(false); return 0;}));
|
||||
|
|
@ -74,7 +70,6 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenMultipleOperatorsAndKernel
|
|||
expectCallsIncrement(DispatchKey::CPU);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernel_whenRegistrationRunsOutOfScope_thenCannotBeCalledAnymore) {
|
||||
{
|
||||
auto m = MAKE_TORCH_LIBRARY(_test);
|
||||
|
|
@ -99,10 +94,8 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernel_whenRegistrationRun
|
|||
expectDoesntFindOperator("_test::my_op");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
bool was_called = false;
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op("_test::no_return(Tensor dummy) -> ()",
|
||||
RegisterOperators::options()
|
||||
|
|
@ -116,7 +109,6 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithoutOutput_whenRe
|
|||
EXPECT_EQ(0, result.size());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithZeroOutputs_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op("_test::zero_outputs(Tensor dummy) -> ()",
|
||||
RegisterOperators::options().kernel(DispatchKey::CPU, [] (const Tensor&) -> std::tuple<> {was_called = true; return {};}));
|
||||
|
|
@ -129,7 +121,6 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithZeroOutputs_when
|
|||
EXPECT_EQ(0, result.size());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithIntOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::int_output(Tensor dummy, int a, int b) -> int",
|
||||
|
|
@ -143,7 +134,6 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithIntOutput_whenRe
|
|||
EXPECT_EQ(9, result[0].toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithTensorOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::returning_tensor(Tensor input) -> Tensor",
|
||||
|
|
@ -162,7 +152,6 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithTensorOutput_whe
|
|||
EXPECT_EQ(DispatchKey::CUDA, extractDispatchKey(result[0].toTensor()));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithTensorListOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::list_output(Tensor input1, Tensor input2, Tensor input3) -> Tensor[]",
|
||||
|
|
@ -179,7 +168,6 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithTensorListOutput
|
|||
EXPECT_EQ(DispatchKey::CPU, extractDispatchKey(result[0].toTensorVector()[2]));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithIntListOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::list_output(Tensor dummy, int input1, int input2, int input3) -> int[]",
|
||||
|
|
@ -196,7 +184,6 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithIntListOutput_wh
|
|||
EXPECT_EQ(6, result[0].toIntVector()[2]);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithMultipleOutputs_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::multiple_outputs(Tensor dummy) -> (Tensor, int, Tensor[], int?, Dict(str, Tensor))",
|
||||
|
|
@ -230,7 +217,6 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithMultipleOutputs_
|
|||
EXPECT_EQ(DispatchKey::CUDA, extractDispatchKey(result_dict.at("second")));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithTensorInputByReference_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_input(Tensor input) -> Tensor",
|
||||
|
|
@ -249,7 +235,6 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithTensorInputByRef
|
|||
EXPECT_EQ(DispatchKey::CUDA, extractDispatchKey(result[0].toTensor()));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithTensorInputByValue_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_input(Tensor input) -> Tensor",
|
||||
|
|
@ -268,10 +253,8 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithTensorInputByVal
|
|||
EXPECT_EQ(DispatchKey::CUDA, extractDispatchKey(result[0].toTensor()));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
Tensor captured_input;
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithTensorInputByReference_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_input(Tensor input) -> ()",
|
||||
|
|
@ -290,7 +273,6 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithTensorInputByRef
|
|||
EXPECT_EQ(DispatchKey::CUDA, extractDispatchKey(captured_input));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithTensorInputByValue_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_input(Tensor input) -> ()",
|
||||
|
|
@ -309,10 +291,8 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithTensorInputByVal
|
|||
EXPECT_EQ(DispatchKey::CUDA, extractDispatchKey(captured_input));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
int64_t captured_int_input = 0;
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithIntInput_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::int_input(Tensor dummy, int input) -> ()",
|
||||
|
|
@ -327,7 +307,6 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithIntInput_without
|
|||
EXPECT_EQ(3, captured_int_input);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithIntInput_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::int_input(Tensor dummy, int input) -> int",
|
||||
|
|
@ -341,10 +320,8 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithIntInput_withOut
|
|||
EXPECT_EQ(4, outputs[0].toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
int64_t captured_input_list_size = 0;
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithIntListInput_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::int_list_input(Tensor dummy, int[] input) -> ()",
|
||||
|
|
@ -359,7 +336,6 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithIntListInput_wit
|
|||
EXPECT_EQ(3, captured_input_list_size);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithIntListInput_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::int_list_input(Tensor dummy, int[] input) -> int",
|
||||
|
|
@ -373,7 +349,6 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithIntListInput_wit
|
|||
EXPECT_EQ(3, outputs[0].toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithTensorListInput_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_list_input(Tensor[] input) -> ()",
|
||||
|
|
@ -388,7 +363,6 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithTensorListInput_
|
|||
EXPECT_EQ(2, captured_input_list_size);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithTensorListInput_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_list_input(Tensor[] input) -> int",
|
||||
|
|
@ -402,10 +376,8 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithTensorListInput_
|
|||
EXPECT_EQ(2, outputs[0].toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
int captured_dict_size = 0;
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithDictInput_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::dict_input(Dict(str, Tensor) input) -> ()", RegisterOperators::options().catchAllKernel([] (Dict<string, Tensor> input1) {
|
||||
|
|
@ -424,7 +396,6 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithDictInput_withou
|
|||
EXPECT_EQ(2, captured_dict_size);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithDictInput_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::dict_input(Dict(str, str) input) -> str", RegisterOperators::options().catchAllKernel([] (Dict<string, string> input1) {
|
||||
|
|
@ -442,7 +413,6 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithDictInput_withOu
|
|||
EXPECT_EQ("value2", outputs[0].toString()->string());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithDictOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::dict_output(Dict(str, str) input) -> Dict(str, str)", RegisterOperators::options().catchAllKernel([] (Dict<string, string> input) {
|
||||
|
|
@ -464,10 +434,8 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithDictOutput_whenR
|
|||
EXPECT_EQ("value2", output.at("key2"));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
bool called = false;
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenFallbackKernelWithoutAnyArguments_whenRegistered_thenCanBeCalled) {
|
||||
// note: non-fallback kernels without tensor arguments don't work because there
|
||||
// is no way to get the dispatch key. For operators that only have a fallback
|
||||
|
|
@ -483,7 +451,6 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenFallbackKernelWithoutAnyAr
|
|||
EXPECT_TRUE(called);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenFallbackKernelWithoutTensorArguments_whenRegistered_thenCanBeCalled) {
|
||||
// note: non-fallback kernels without tensor arguments don't work because there
|
||||
// is no way to get the dispatch key. For operators that only have a fallback
|
||||
|
|
@ -499,14 +466,10 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenFallbackKernelWithoutTenso
|
|||
EXPECT_EQ(4, outputs[0].toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
c10::optional<Tensor> called_arg2 = c10::nullopt;
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
c10::optional<int64_t> called_arg3 = c10::nullopt;
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
c10::optional<std::string> called_arg4 = c10::nullopt;
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithOptionalInputs_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op(
|
||||
"_test::opt_input(Tensor arg1, Tensor? arg2, int? arg3, str? arg4) -> ()",
|
||||
|
|
@ -541,7 +504,6 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithOptionalInputs_w
|
|||
EXPECT_FALSE(called_arg4.has_value());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithOptionalInputs_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op(
|
||||
"_test::opt_input(Tensor arg1, Tensor? arg2, int? arg3, str? arg4) -> Tensor?",
|
||||
|
|
@ -579,7 +541,6 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithOptionalInputs_w
|
|||
EXPECT_FALSE(called_arg4.has_value());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernelWithOptionalInputs_withMultipleOutputs_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op(
|
||||
"_test::opt_input(Tensor arg1, Tensor? arg2, int? arg3, str? arg4) -> (Tensor?, int?, str?)",
|
||||
|
|
@ -612,7 +573,6 @@ void expectCallsConcatUnboxed(DispatchKey dispatch_key) {
|
|||
EXPECT_EQ("123", result);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernel_whenRegistered_thenCanBeCalledUnboxed) {
|
||||
auto registrar = RegisterOperators().op("_test::my_op(Tensor dummy, str a, str b, int c) -> str", torch::RegisterOperators::options()
|
||||
.kernel(DispatchKey::CPU, [] (const Tensor& tensor1, std::string a, const std::string& b, int64_t c) {
|
||||
|
|
@ -621,7 +581,6 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernel_whenRegistered_then
|
|||
expectCallsConcatUnboxed(DispatchKey::CPU);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernel_whenRegisteredWithoutSpecifyingSchema_thenInfersSchema) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::no_schema_specified", RegisterOperators::options().catchAllKernel([] (Tensor arg1, int64_t arg2, const c10::List<Tensor>& arg3) -> std::tuple<int64_t, Tensor> {return {};}));
|
||||
|
|
@ -633,7 +592,6 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenKernel_whenRegisteredWitho
|
|||
EXPECT_FALSE(differences.has_value());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenMismatchedKernel_withDifferentNumArguments_whenRegistering_thenFails) {
|
||||
// assert this does not fail because it matches
|
||||
RegisterOperators()
|
||||
|
|
@ -670,7 +628,6 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenMismatchedKernel_withDiffe
|
|||
);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenMismatchedKernel_withDifferentArgumentType_whenRegistering_thenFails) {
|
||||
// assert this does not fail because it matches
|
||||
RegisterOperators()
|
||||
|
|
@ -690,7 +647,6 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenMismatchedKernel_withDiffe
|
|||
);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenMismatchedKernel_withDifferentNumReturns_whenRegistering_thenFails) {
|
||||
// assert this does not fail because it matches
|
||||
RegisterOperators()
|
||||
|
|
@ -750,7 +706,6 @@ TEST(OperatorRegistrationTest_LambdaBasedKernel, givenMismatchedKernel_withDiffe
|
|||
);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_LambdaBasedKernel, givenMismatchedKernel_withDifferentReturnTypes_whenRegistering_thenFails) {
|
||||
// assert this does not fail because it matches
|
||||
RegisterOperators()
|
||||
|
|
|
|||
|
|
@ -34,7 +34,6 @@ void decrementKernel(const OperatorHandle&, Stack* stack) {
|
|||
torch::jit::push(*stack, input - 1);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
bool called_redispatching_kernel = false;
|
||||
void redispatchingKernel_with_DispatchKeySet(const OperatorHandle& op, c10::DispatchKeySet ks, Stack* stack) {
|
||||
// this kernel is a no-op- it just redispatches to the lower-priority kernel
|
||||
|
|
@ -79,13 +78,11 @@ void expectCallsDecrement(DispatchKey dispatch_key) {
|
|||
EXPECT_EQ(4, result[0].toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_StackBasedKernel, givenKernel_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op("_test::my_op(Tensor dummy, int input) -> int", RegisterOperators::options().kernel<&incrementKernel>(DispatchKey::CPU));
|
||||
expectCallsIncrement(DispatchKey::CPU);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_StackBasedKernel, givenMultipleOperatorsAndKernels_whenRegisteredInOneRegistrar_thenCallsRightKernel) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::my_op(Tensor dummy, int input) -> int", RegisterOperators::options().kernel<&incrementKernel>(DispatchKey::CPU)
|
||||
|
|
@ -95,7 +92,6 @@ TEST(OperatorRegistrationTest_StackBasedKernel, givenMultipleOperatorsAndKernels
|
|||
expectCallsIncrement(DispatchKey::CPU);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_StackBasedKernel, givenMultipleOperatorsAndKernels_whenRegisteredInMultipleRegistrars_thenCallsRightKernel) {
|
||||
auto registrar1 = RegisterOperators().op("_test::my_op(Tensor dummy, int input) -> int", RegisterOperators::options().kernel<&incrementKernel>(DispatchKey::CPU)
|
||||
.kernel<&errorKernel>(DispatchKey::CUDA));
|
||||
|
|
@ -104,7 +100,6 @@ TEST(OperatorRegistrationTest_StackBasedKernel, givenMultipleOperatorsAndKernels
|
|||
expectCallsIncrement(DispatchKey::CPU);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_StackBasedKernel, givenKernel_whenRegistrationRunsOutOfScope_thenCannotBeCalledAnymore) {
|
||||
{
|
||||
auto m = MAKE_TORCH_LIBRARY(_test);
|
||||
|
|
@ -129,14 +124,12 @@ TEST(OperatorRegistrationTest_StackBasedKernel, givenKernel_whenRegistrationRuns
|
|||
expectDoesntFindOperator("_test::my_op");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
bool called = false;
|
||||
|
||||
void kernelWithoutInputs(const OperatorHandle&, Stack*) {
|
||||
called = true;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_StackBasedKernel, givenFallbackKernelWithoutAnyArguments_whenRegistered_thenCanBeCalled) {
|
||||
// note: non-fallback kernels without tensor arguments don't work because there
|
||||
// is no way to get the dispatch key. For operators that only have a fallback
|
||||
|
|
@ -156,7 +149,6 @@ void kernelWithoutTensorInputs(const OperatorHandle&, Stack* stack) {
|
|||
stack->back() = stack->back().toInt() + 1;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_StackBasedKernel, givenFallbackKernelWithoutTensorArguments_whenRegistered_thenCanBeCalled) {
|
||||
// note: non-fallback kernels without tensor arguments don't work because there
|
||||
// is no way to get the dispatch key. For operators that only have a fallback
|
||||
|
|
@ -175,20 +167,17 @@ TEST(OperatorRegistrationTest_StackBasedKernel, givenFallbackKernelWithoutTensor
|
|||
void kernelForSchemaInference(const OperatorHandle&, Stack* stack) {
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_StackBasedKernel, givenKernel_whenRegisteredWithoutSpecifyingSchema_thenFailsBecauseItCannotInferFromStackBasedKernel) {
|
||||
expectThrows<c10::Error>([] {
|
||||
RegisterOperators().op("_test::no_schema_specified", RegisterOperators::options().catchAllKernel<&kernelForSchemaInference>());
|
||||
}, "Cannot infer operator schema for this kind of kernel in registration of operator _test::no_schema_specified");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_StackBasedKernel, givenKernel_whenRegistered_thenCanAlsoBeCalledUnboxed) {
|
||||
auto registrar = RegisterOperators().op("_test::my_op(Tensor dummy, int input) -> int", RegisterOperators::options().kernel<&incrementKernel>(DispatchKey::CPU));
|
||||
expectCallsIncrementUnboxed(DispatchKey::CPU);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_StackBasedKernel, callKernelsWithDispatchKeySetConvention_redispatchesToLowerPriorityKernels) {
|
||||
auto m = MAKE_TORCH_LIBRARY(_test);
|
||||
m.def("my_op(Tensor dummy, int input) -> int");
|
||||
|
|
|
|||
|
|
@ -62,13 +62,11 @@ void expectCallsDecrement(DispatchKey dispatch_key) {
|
|||
EXPECT_EQ(4, result[0].toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernel_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op("_test::my_op(Tensor dummy, int input) -> int", RegisterOperators::options().kernel<IncrementKernel>(DispatchKey::CPU));
|
||||
expectCallsIncrement(DispatchKey::CPU);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenMultipleOperatorsAndKernels_whenRegisteredInOneRegistrar_thenCallsRightKernel) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::my_op(Tensor dummy, int input) -> int", RegisterOperators::options().kernel<IncrementKernel>(DispatchKey::CPU)
|
||||
|
|
@ -78,7 +76,6 @@ TEST(OperatorRegistrationTest_FunctorBasedKernel, givenMultipleOperatorsAndKerne
|
|||
expectCallsIncrement(DispatchKey::CPU);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenMultipleOperatorsAndKernels_whenRegisteredInMultipleRegistrars_thenCallsRightKernel) {
|
||||
auto registrar1 = RegisterOperators().op("_test::my_op(Tensor dummy, int input) -> int", RegisterOperators::options().kernel<IncrementKernel>(DispatchKey::CPU)
|
||||
.kernel<ErrorKernel>(DispatchKey::CUDA));
|
||||
|
|
@ -87,7 +84,6 @@ TEST(OperatorRegistrationTest_FunctorBasedKernel, givenMultipleOperatorsAndKerne
|
|||
expectCallsIncrement(DispatchKey::CPU);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
bool was_called = false;
|
||||
|
||||
struct KernelWithoutOutput final : OperatorKernel {
|
||||
|
|
@ -96,7 +92,6 @@ struct KernelWithoutOutput final : OperatorKernel {
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op("_test::no_return(Tensor dummy) -> ()", RegisterOperators::options().kernel<KernelWithoutOutput>(DispatchKey::CPU));
|
||||
|
||||
|
|
@ -115,7 +110,6 @@ struct KernelWithZeroOutputs final : OperatorKernel {
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithZeroOutputs_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op("_test::zero_outputs(Tensor dummy) -> ()", RegisterOperators::options().kernel<KernelWithZeroOutputs>(DispatchKey::CPU));
|
||||
|
||||
|
|
@ -133,7 +127,6 @@ struct KernelWithIntOutput final : OperatorKernel {
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithIntOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::int_output(Tensor dummy, int a, int b) -> int", RegisterOperators::options().kernel<KernelWithIntOutput>(DispatchKey::CPU));
|
||||
|
|
@ -152,7 +145,6 @@ struct KernelWithTensorOutput final : OperatorKernel {
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithTensorOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::returning_tensor(Tensor input) -> Tensor", RegisterOperators::options().kernel<KernelWithTensorOutput>(DispatchKey::CPU)
|
||||
|
|
@ -176,7 +168,6 @@ struct KernelWithTensorListOutput final : OperatorKernel {
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithTensorListOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::list_output(Tensor input1, Tensor input2, Tensor input3) -> Tensor[]", RegisterOperators::options().kernel<KernelWithTensorListOutput>(DispatchKey::CUDA));
|
||||
|
|
@ -198,7 +189,6 @@ struct KernelWithIntListOutput final : OperatorKernel {
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithIntListOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::list_output(Tensor dummy, int input1, int input2, int input3) -> int[]", RegisterOperators::options().kernel<KernelWithIntListOutput>(DispatchKey::CPU));
|
||||
|
|
@ -229,7 +219,6 @@ struct KernelWithMultipleOutputs final : OperatorKernel {
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithMultipleOutputs_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::multiple_outputs(Tensor dummy) -> (Tensor, int, Tensor[], int?, Dict(str, Tensor))", RegisterOperators::options().kernel<KernelWithMultipleOutputs>(DispatchKey::CPU));
|
||||
|
|
@ -263,7 +252,6 @@ struct KernelWithTensorInputByValueWithOutput final : OperatorKernel {
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithTensorInputByReference_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_input(Tensor input) -> Tensor", RegisterOperators::options().kernel<KernelWithTensorInputByReferenceWithOutput>(DispatchKey::CPU)
|
||||
|
|
@ -281,7 +269,6 @@ TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithTensorInputByRe
|
|||
EXPECT_EQ(DispatchKey::CUDA, extractDispatchKey(result[0].toTensor()));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithTensorInputByValue_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_input(Tensor input) -> Tensor", RegisterOperators::options().kernel<KernelWithTensorInputByValueWithOutput>(DispatchKey::CPU)
|
||||
|
|
@ -299,7 +286,6 @@ TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithTensorInputByVa
|
|||
EXPECT_EQ(DispatchKey::CUDA, extractDispatchKey(result[0].toTensor()));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
Tensor captured_input;
|
||||
|
||||
struct KernelWithTensorInputByReferenceWithoutOutput final : OperatorKernel {
|
||||
|
|
@ -314,7 +300,6 @@ struct KernelWithTensorInputByValueWithoutOutput final : OperatorKernel {
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithTensorInputByReference_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_input(Tensor input) -> ()", RegisterOperators::options().kernel<KernelWithTensorInputByReferenceWithoutOutput>(DispatchKey::CPU)
|
||||
|
|
@ -332,7 +317,6 @@ TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithTensorInputByRe
|
|||
EXPECT_EQ(DispatchKey::CUDA, extractDispatchKey(captured_input));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithTensorInputByValue_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_input(Tensor input) -> ()", RegisterOperators::options().kernel<KernelWithTensorInputByValueWithoutOutput>(DispatchKey::CPU)
|
||||
|
|
@ -350,7 +334,6 @@ TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithTensorInputByVa
|
|||
EXPECT_EQ(DispatchKey::CUDA, extractDispatchKey(captured_input));
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
int64_t captured_int_input = 0;
|
||||
|
||||
struct KernelWithIntInputWithoutOutput final : OperatorKernel {
|
||||
|
|
@ -359,7 +342,6 @@ struct KernelWithIntInputWithoutOutput final : OperatorKernel {
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithIntInput_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::int_input(Tensor dummy, int input) -> ()", RegisterOperators::options().kernel<KernelWithIntInputWithoutOutput>(DispatchKey::CPU));
|
||||
|
|
@ -379,7 +361,6 @@ struct KernelWithIntInputWithOutput final : OperatorKernel {
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithIntInput_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::int_input(Tensor dummy, int input) -> int", RegisterOperators::options().kernel<KernelWithIntInputWithOutput>(DispatchKey::CPU));
|
||||
|
|
@ -392,7 +373,6 @@ TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithIntInput_withOu
|
|||
EXPECT_EQ(4, outputs[0].toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
int64_t captured_input_list_size = 0;
|
||||
|
||||
struct KernelWithIntListInputWithoutOutput final : OperatorKernel {
|
||||
|
|
@ -401,7 +381,6 @@ struct KernelWithIntListInputWithoutOutput final : OperatorKernel {
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithIntListInput_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::int_list_input(Tensor dummy, int[] input) -> ()", RegisterOperators::options().kernel<KernelWithIntListInputWithoutOutput>(DispatchKey::CPU));
|
||||
|
|
@ -421,7 +400,6 @@ struct KernelWithIntListInputWithOutput final : OperatorKernel {
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithIntListInput_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::int_list_input(Tensor dummy, int[] input) -> int", RegisterOperators::options().kernel<KernelWithIntListInputWithOutput>(DispatchKey::CPU));
|
||||
|
|
@ -440,7 +418,6 @@ struct KernelWithTensorListInputWithoutOutput final : OperatorKernel {
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithTensorListInput_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_list_input(Tensor[] input) -> ()", RegisterOperators::options().kernel<KernelWithTensorListInputWithoutOutput>(DispatchKey::CPU));
|
||||
|
|
@ -460,7 +437,6 @@ struct KernelWithTensorListInputWithOutput final : OperatorKernel {
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithTensorListInput_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tensor_list_input(Tensor[] input) -> int", RegisterOperators::options().kernel<KernelWithTensorListInputWithOutput>(DispatchKey::CPU));
|
||||
|
|
@ -473,7 +449,6 @@ TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithTensorListInput
|
|||
EXPECT_EQ(2, outputs[0].toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
int captured_dict_size = 0;
|
||||
|
||||
struct KernelWithDictInputWithoutOutput final : OperatorKernel {
|
||||
|
|
@ -482,7 +457,6 @@ struct KernelWithDictInputWithoutOutput final : OperatorKernel {
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithDictInput_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::dict_input(Dict(str, Tensor) input) -> ()", RegisterOperators::options().catchAllKernel<KernelWithDictInputWithoutOutput>());
|
||||
|
|
@ -505,7 +479,6 @@ struct KernelWithDictInputWithOutput final : OperatorKernel {
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithDictInput_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::dict_input(Dict(str, str) input) -> str", RegisterOperators::options().catchAllKernel<KernelWithDictInputWithOutput>());
|
||||
|
|
@ -527,7 +500,6 @@ struct KernelWithDictOutput final : OperatorKernel {
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithDictOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::dict_output(Dict(str, str) input) -> Dict(str, str)", RegisterOperators::options().catchAllKernel<KernelWithDictOutput>());
|
||||
|
|
@ -564,7 +536,6 @@ struct KernelWithTupleInput final : OperatorKernel {
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithTupleInput_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::tuple_input((str, int, float) input) -> str", RegisterOperators::options().catchAllKernel<KernelWithTupleInput>());
|
||||
|
|
@ -578,7 +549,6 @@ TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithTupleInput_with
|
|||
EXPECT_EQ("foobar", outputs[0].toString()->string());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithCache_thenCacheIsKeptCorrectly) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::cache_op(Tensor input) -> int", RegisterOperators::options().kernel<KernelWithCache>(DispatchKey::CPU));
|
||||
|
|
@ -618,7 +588,6 @@ private:
|
|||
int64_t offset_;
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithConstructorArg_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::offset_op(Tensor tensor, int input) -> int", RegisterOperators::options().kernel<KernelWithConstructorArg>(DispatchKey::CPU, 2)
|
||||
|
|
@ -649,7 +618,6 @@ private:
|
|||
int64_t offset_;
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithMultipleConstructorArgs_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::offset_op(Tensor tensor, int input) -> int", RegisterOperators::options().kernel<KernelWithMultipleConstructorArgs>(DispatchKey::CPU, 2, 3)
|
||||
|
|
@ -667,7 +635,6 @@ TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithMultipleConstru
|
|||
EXPECT_EQ(13, outputs[0].toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
bool called = false;
|
||||
|
||||
struct KernelWithoutInputs final : OperatorKernel {
|
||||
|
|
@ -676,7 +643,6 @@ struct KernelWithoutInputs final : OperatorKernel {
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenFallbackKernelWithoutAnyArguments_whenRegistered_thenCanBeCalled) {
|
||||
// note: non-fallback kernels without tensor arguments don't work because there
|
||||
// is no way to get the dispatch key. For operators that only have a fallback
|
||||
|
|
@ -698,7 +664,6 @@ struct KernelWithoutTensorInputs final : OperatorKernel {
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenFallbackKernelWithoutTensorArguments_whenRegistered_thenCanBeCalled) {
|
||||
// note: non-fallback kernels without tensor arguments don't work because there
|
||||
// is no way to get the dispatch key. For operators that only have a fallback
|
||||
|
|
@ -714,11 +679,8 @@ TEST(OperatorRegistrationTest_FunctorBasedKernel, givenFallbackKernelWithoutTens
|
|||
EXPECT_EQ(4, outputs[0].toInt());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
c10::optional<Tensor> called_arg2 = c10::nullopt;
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
c10::optional<int64_t> called_arg3 = c10::nullopt;
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
c10::optional<std::string> called_arg4 = c10::nullopt;
|
||||
|
||||
struct KernelWithOptInputWithoutOutput final : OperatorKernel {
|
||||
|
|
@ -730,7 +692,6 @@ struct KernelWithOptInputWithoutOutput final : OperatorKernel {
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithOptionalInputs_withoutOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op("_test::opt_input(Tensor arg1, Tensor? arg2, int? arg3, str? arg4) -> ()", RegisterOperators::options().kernel<KernelWithOptInputWithoutOutput>(DispatchKey::CPU));
|
||||
auto op = c10::Dispatcher::singleton().findSchema({"_test::opt_input", ""});
|
||||
|
|
@ -768,7 +729,6 @@ struct KernelWithOptInputWithOutput final : OperatorKernel {
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithOptionalInputs_withOutput_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op("_test::opt_input(Tensor arg1, Tensor? arg2, int? arg3, str? arg4) -> Tensor?", RegisterOperators::options().kernel<KernelWithOptInputWithOutput>(DispatchKey::CPU));
|
||||
auto op = c10::Dispatcher::singleton().findSchema({"_test::opt_input", ""});
|
||||
|
|
@ -805,7 +765,6 @@ struct KernelWithOptInputWithMultipleOutputs final : OperatorKernel {
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernelWithOptionalInputs_withMultipleOutputs_whenRegistered_thenCanBeCalled) {
|
||||
auto registrar = RegisterOperators().op("_test::opt_input(Tensor arg1, Tensor? arg2, int? arg3, str? arg4) -> (Tensor?, int?, str?)", RegisterOperators::options().kernel<KernelWithOptInputWithMultipleOutputs>(DispatchKey::CPU));
|
||||
auto op = c10::Dispatcher::singleton().findSchema({"_test::opt_input", ""});
|
||||
|
|
@ -844,7 +803,6 @@ void expectCallsConcatUnboxed(DispatchKey dispatch_key) {
|
|||
EXPECT_EQ("prefix123", result);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernel_whenRegistered_thenCanBeCalledUnboxed) {
|
||||
auto registrar = RegisterOperators().op("_test::my_op(Tensor dummy, str a, str b, int c) -> str", RegisterOperators::options().kernel<ConcatKernel>(DispatchKey::CPU, "prefix"));
|
||||
expectCallsConcatUnboxed(DispatchKey::CPU);
|
||||
|
|
@ -856,7 +814,6 @@ struct KernelForSchemaInference final : OperatorKernel {
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernel_whenRegisteredWithoutSpecifyingSchema_thenInfersSchema) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::no_schema_specified", RegisterOperators::options().kernel<KernelForSchemaInference>(DispatchKey::CPU));
|
||||
|
|
@ -868,7 +825,6 @@ TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernel_whenRegisteredWith
|
|||
EXPECT_FALSE(differences.has_value());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenKernel_whenRegisteredCatchAllWithoutSpecifyingSchema_thenInfersSchema) {
|
||||
auto registrar = RegisterOperators()
|
||||
.op("_test::no_schema_specified", RegisterOperators::options().catchAllKernel<KernelForSchemaInference>());
|
||||
|
|
@ -887,7 +843,6 @@ template<class... Args> struct KernelFunc<void, Args...> final : OperatorKernel
|
|||
void operator()(Args...) {}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenMismatchedKernel_withDifferentNumArguments_whenRegistering_thenFails) {
|
||||
// assert this does not fail because it matches
|
||||
RegisterOperators()
|
||||
|
|
@ -924,7 +879,6 @@ TEST(OperatorRegistrationTest_FunctorBasedKernel, givenMismatchedKernel_withDiff
|
|||
);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenMismatchedKernel_withDifferentArgumentType_whenRegistering_thenFails) {
|
||||
// assert this does not fail because it matches
|
||||
RegisterOperators()
|
||||
|
|
@ -944,7 +898,6 @@ TEST(OperatorRegistrationTest_FunctorBasedKernel, givenMismatchedKernel_withDiff
|
|||
);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenMismatchedKernel_withDifferentNumReturns_whenRegistering_thenFails) {
|
||||
// assert this does not fail because it matches
|
||||
RegisterOperators()
|
||||
|
|
@ -1004,7 +957,6 @@ TEST(OperatorRegistrationTest_FunctorBasedKernel, givenMismatchedKernel_withDiff
|
|||
);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest_FunctorBasedKernel, givenMismatchedKernel_withDifferentReturnTypes_whenRegistering_thenFails) {
|
||||
// assert this does not fail because it matches
|
||||
RegisterOperators()
|
||||
|
|
|
|||
|
|
@ -6,20 +6,17 @@ using c10::impl::CppSignature;
|
|||
|
||||
namespace {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(CppSignatureTest, given_equalSignature_then_areEqual) {
|
||||
EXPECT_EQ(CppSignature::make<void()>(), CppSignature::make<void()>());
|
||||
EXPECT_EQ(CppSignature::make<int64_t(std::string, int64_t)>(), CppSignature::make<int64_t(std::string, int64_t)>());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(CppSignatureTest, given_differentSignature_then_areDifferent) {
|
||||
EXPECT_NE(CppSignature::make<void()>(), CppSignature::make<int64_t()>());
|
||||
EXPECT_NE(CppSignature::make<int64_t(std::string)>(), CppSignature::make<int64_t(std::string, int64_t)>());
|
||||
EXPECT_NE(CppSignature::make<std::string(std::string)>(), CppSignature::make<int64_t(std::string)>());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(CppSignatureTest, given_equalFunctorAndFunction_then_areEqual) {
|
||||
struct Functor final {
|
||||
int64_t operator()(std::string) {return 0;}
|
||||
|
|
@ -27,7 +24,6 @@ TEST(CppSignatureTest, given_equalFunctorAndFunction_then_areEqual) {
|
|||
EXPECT_EQ(CppSignature::make<Functor>(), CppSignature::make<int64_t(std::string)>());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(CppSignatureTest, given_differentFunctorAndFunction_then_areDifferent) {
|
||||
struct Functor final {
|
||||
int64_t operator()(std::string) {return 0;}
|
||||
|
|
@ -35,7 +31,6 @@ TEST(CppSignatureTest, given_differentFunctorAndFunction_then_areDifferent) {
|
|||
EXPECT_NE(CppSignature::make<Functor>(), CppSignature::make<int64_t(std::string, int64_t)>());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(CppSignatureTest, given_cppSignature_then_canQueryNameWithoutCrashing) {
|
||||
CppSignature::make<void(int64_t, const int64_t&)>().name();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ namespace {
|
|||
// but this could be used as a starting point to do more interesting things.
|
||||
|
||||
// Global counter for ease of testing
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
static int64_t override_call_count = 0;
|
||||
|
||||
// Mode implementation
|
||||
|
|
@ -82,7 +81,6 @@ void generic_wrapper_fallback(const c10::OperatorHandle& op, torch::jit::Stack*
|
|||
}
|
||||
|
||||
#ifndef ATEN_CPU_STATIC_DISPATCH
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(BackendFallbackTest, TestBackendFallbackWithMode) {
|
||||
auto m = MAKE_TORCH_LIBRARY_IMPL(_, TESTING_ONLY_GenericMode);
|
||||
m.fallback(torch::CppFunction::makeFromBoxedFunction<&generic_mode_fallback>());
|
||||
|
|
@ -95,7 +93,6 @@ TEST(BackendFallbackTest, TestBackendFallbackWithMode) {
|
|||
ASSERT_EQ(override_call_count, 2);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(BackendFallbackTest, TestBackendFallbackWithWrapper) {
|
||||
auto m = MAKE_TORCH_LIBRARY_IMPL(_, TESTING_ONLY_GenericWrapper);
|
||||
m.fallback(torch::CppFunction::makeFromBoxedFunction<&generic_wrapper_fallback>());
|
||||
|
|
@ -106,7 +103,6 @@ TEST(BackendFallbackTest, TestBackendFallbackWithWrapper) {
|
|||
ASSERT_EQ(override_call_count, 1);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(BackendFallbackTest, TestFallthroughBackendFallback) {
|
||||
auto m = MAKE_TORCH_LIBRARY_IMPL(aten, TESTING_ONLY_GenericMode);
|
||||
m.impl("mul.Tensor", torch::CppFunction::makeFromBoxedFunction<&generic_mode_fallback>());
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ private:
|
|||
bool* called_;
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, whenRegisteringWithSchemaBeforeKernelInOptionsObject_thenCanBeCalled) {
|
||||
bool called = false;
|
||||
auto registrar = c10::RegisterOperators().op(c10::RegisterOperators::options().schema("_test::dummy(Tensor dummy) -> ()").catchAllKernel<MockKernel>(&called));
|
||||
|
|
@ -58,7 +57,6 @@ TEST(OperatorRegistrationTest, whenRegisteringWithSchemaBeforeKernelInOptionsObj
|
|||
EXPECT_TRUE(called);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, whenRegisteringWithSchemaAfterKernelInOptionsObject_thenCanBeCalled) {
|
||||
bool called = false;
|
||||
auto registrar = c10::RegisterOperators().op(c10::RegisterOperators::options().catchAllKernel<MockKernel>(&called).schema("_test::dummy(Tensor dummy) -> ()"));
|
||||
|
|
@ -70,7 +68,6 @@ TEST(OperatorRegistrationTest, whenRegisteringWithSchemaAfterKernelInOptionsObje
|
|||
EXPECT_TRUE(called);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, whenRegisteringWithNameBeforeKernelInOptionsObject_thenCanBeCalled) {
|
||||
bool called = false;
|
||||
auto registrar = c10::RegisterOperators().op(c10::RegisterOperators::options().schema("_test::dummy").catchAllKernel<MockKernel>(&called));
|
||||
|
|
@ -82,7 +79,6 @@ TEST(OperatorRegistrationTest, whenRegisteringWithNameBeforeKernelInOptionsObjec
|
|||
EXPECT_TRUE(called);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, whenRegisteringWithNameAfterKernelInOptionsObject_thenCanBeCalled) {
|
||||
bool called = false;
|
||||
auto registrar = c10::RegisterOperators().op(c10::RegisterOperators::options().catchAllKernel<MockKernel>(&called).schema("_test::dummy"));
|
||||
|
|
@ -94,14 +90,12 @@ TEST(OperatorRegistrationTest, whenRegisteringWithNameAfterKernelInOptionsObject
|
|||
EXPECT_TRUE(called);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, whenRegisteringWithoutSchema_thenFails) {
|
||||
expectThrows<c10::Error>([] {
|
||||
c10::RegisterOperators().op(c10::RegisterOperators::options().catchAllKernel<DummyKernel>());
|
||||
}, "In operator registration: Tried to register an operator without specifying a schema or operator name.");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, whenCallingOpWithWrongDispatchKey_thenFails) {
|
||||
auto registrar = c10::RegisterOperators().op("_test::dummy(Tensor dummy) -> ()", c10::RegisterOperators::options().kernel<DummyKernel>(c10::DispatchKey::CPU));
|
||||
|
||||
|
|
@ -113,7 +107,6 @@ TEST(OperatorRegistrationTest, whenCallingOpWithWrongDispatchKey_thenFails) {
|
|||
" backend.");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, givenOpWithCatchallKernel_whenCallingOp_thenCallsCatchallKernel) {
|
||||
bool called = false;
|
||||
auto registrar = c10::RegisterOperators().op("_test::dummy(Tensor dummy) -> ()", c10::RegisterOperators::options().catchAllKernel<MockKernel>(&called));
|
||||
|
|
@ -143,7 +136,6 @@ TEST(OperatorRegistrationTest, givenOpWithCatchallKernel_whenCallingOp_thenCalls
|
|||
// }, "for an operator which already has a catch-all kernel registered");
|
||||
// }
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, givenOpWithDispatchedKernelOutOfScope_whenRegisteringCatchallKernelAndCallingOp_thenCallsCatchallKernel) {
|
||||
bool called = false;
|
||||
{
|
||||
|
|
@ -177,7 +169,6 @@ TEST(OperatorRegistrationTest, givenOpWithDispatchedKernelOutOfScope_whenRegiste
|
|||
// }, "Tried to register a catch-all kernel for an operator which already has kernels for dispatch keys CPU. An operator can only have either a catch-all kernel or kernels with dispatch keys. The operator schema is _test::dummy");
|
||||
// }
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, givenOpWithCatchallKernelOutOfScope_whenRegisteringDispatchedKernelAndCallingOp_thenCallsCatchallKernel) {
|
||||
bool called = false;
|
||||
{
|
||||
|
|
@ -193,7 +184,6 @@ TEST(OperatorRegistrationTest, givenOpWithCatchallKernelOutOfScope_whenRegisteri
|
|||
EXPECT_TRUE(called);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, givenOpWithoutKernels_whenRegisteringWithSchema_thenOnlyRegistersSchema) {
|
||||
auto registrar = c10::RegisterOperators().op("_test::dummy(Tensor dummy) -> ()");
|
||||
|
||||
|
|
@ -205,14 +195,12 @@ TEST(OperatorRegistrationTest, givenOpWithoutKernels_whenRegisteringWithSchema_t
|
|||
" backend.");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, givenOpWithoutKernels_whenRegisteringWithoutSchema_thenFails) {
|
||||
expectThrows<c10::Error>([&] {
|
||||
c10::RegisterOperators().op("_test::dummy");
|
||||
}, "Cannot infer operator schema in registration of operator _test::dummy because there is no kernel specified.");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, givenOpWithoutKernels_whenRunningOutOfScope_thenSchemaIsGone) {
|
||||
{
|
||||
auto registrar = c10::RegisterOperators().op("_test::dummy(Tensor dummy) -> ()");
|
||||
|
|
@ -222,7 +210,6 @@ TEST(OperatorRegistrationTest, givenOpWithoutKernels_whenRunningOutOfScope_thenS
|
|||
EXPECT_FALSE(op.has_value());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, givenOpWithoutKernelsWithoutTensorInputs_whenRegistering_thenRegisters) {
|
||||
// as long as we don't register non-catchall kernels, ops without tensor arguments are fine
|
||||
auto registrar = c10::RegisterOperators().op("_test::dummy() -> ()");
|
||||
|
|
@ -231,7 +218,6 @@ TEST(OperatorRegistrationTest, givenOpWithoutKernelsWithoutTensorInputs_whenRegi
|
|||
ASSERT_TRUE(op.has_value()); // assert schema is registered
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, givenMultipleKernelsWithSameDispatchKey_whenRegisteringInSameOpCall_thenFails) {
|
||||
expectThrows<c10::Error>([&] {
|
||||
auto registrar = c10::RegisterOperators()
|
||||
|
|
@ -241,7 +227,6 @@ TEST(OperatorRegistrationTest, givenMultipleKernelsWithSameDispatchKey_whenRegis
|
|||
}, "In operator registration: Tried to register multiple kernels with same dispatch key CPU for operator schema _test::dummy");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, givenMultipleCatchallKernels_whenRegisteringInSameOpCall_thenFails) {
|
||||
expectThrows<c10::Error>([&] {
|
||||
auto registrar = c10::RegisterOperators()
|
||||
|
|
@ -251,7 +236,6 @@ TEST(OperatorRegistrationTest, givenMultipleCatchallKernels_whenRegisteringInSam
|
|||
}, "Tried to register multiple catch-all kernels for operator schema _test::dummy");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, whenRegisteringCPUTensorType_thenCanOnlyCallUnboxedWithCPUDispatchKey) {
|
||||
bool called_kernel_cpu = false;
|
||||
auto registrar= c10::RegisterOperators().op("_test::dummy(Tensor dummy) -> ()", c10::RegisterOperators::options()
|
||||
|
|
@ -273,7 +257,6 @@ TEST(OperatorRegistrationTest, whenRegisteringCPUTensorType_thenCanOnlyCallUnbox
|
|||
" backend.");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, whenRegisteringMultipleKernelsInSameOpCallAndCalling_thenCallsCorrectKernel) {
|
||||
bool called_kernel1 = false;
|
||||
bool called_kernel2 = false;
|
||||
|
|
@ -308,13 +291,11 @@ TEST(OperatorRegistrationTest, whenRegisteringMultipleKernelsInSameOpCallAndCall
|
|||
}, "CUDA");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
bool called_stackbased_kernel = false;
|
||||
void stackBasedKernel(const OperatorHandle&, c10::Stack* stack) {
|
||||
called_stackbased_kernel = true;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, whenRegisteringMultipleKernelsByNameAndNoneCanInferSchema_thenFails) {
|
||||
bool called_kernel = false;
|
||||
expectThrows<c10::Error>([&] {
|
||||
|
|
@ -325,7 +306,6 @@ TEST(OperatorRegistrationTest, whenRegisteringMultipleKernelsByNameAndNoneCanInf
|
|||
}, "Cannot infer operator schema for this kind of kernel in registration of operator _test::dummy");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, whenRegisteringMultipleKernelsBySchemaAndNoneCanInferSchema_thenSucceeds) {
|
||||
bool called_kernel = false;
|
||||
auto registrar1 = c10::RegisterOperators().op("_test::dummy(Tensor dummy) -> ()", c10::RegisterOperators::options()
|
||||
|
|
@ -352,7 +332,6 @@ TEST(OperatorRegistrationTest, whenRegisteringMultipleKernelsBySchemaAndNoneCanI
|
|||
EXPECT_FALSE(called_kernel);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, whenRegisteringMultipleKernelsByNameAndOnlyOneCanInferSchema_thenSucceeds) {
|
||||
bool called_kernel = false;
|
||||
auto registrar1 = c10::RegisterOperators().op("_test::dummy", c10::RegisterOperators::options()
|
||||
|
|
@ -379,7 +358,6 @@ TEST(OperatorRegistrationTest, whenRegisteringMultipleKernelsByNameAndOnlyOneCan
|
|||
EXPECT_FALSE(called_kernel);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, whenRegisteringMultipleKernelsBySchemaAndOnlyOneCanInferSchema_thenSucceeds) {
|
||||
bool called_kernel = false;
|
||||
auto registrar1 = c10::RegisterOperators().op("_test::dummy(Tensor dummy) -> ()", c10::RegisterOperators::options()
|
||||
|
|
@ -410,7 +388,6 @@ struct DummyKernelWithIntParam final : OperatorKernel {
|
|||
void operator()(Tensor, int64_t) {}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, whenRegisteringMismatchingKernelsInSameOpCall_thenFails) {
|
||||
bool called_kernel = false;
|
||||
expectThrows<c10::Error>([&] {
|
||||
|
|
@ -424,7 +401,6 @@ void backend_fallback_kernel(const c10::OperatorHandle& op, c10::Stack* stack) {
|
|||
(*stack)[1] = (*stack)[1].toString()->string() + op.schema().name();
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, whenRegisteringBackendFallbackKernel_thenCanBeCalled) {
|
||||
auto registrar = c10::Dispatcher::singleton().registerFallback(c10::DispatchKey::CPU, c10::KernelFunction::makeFromBoxedFunction<&backend_fallback_kernel>(), "");
|
||||
|
||||
|
|
@ -435,7 +411,6 @@ TEST(OperatorRegistrationTest, whenRegisteringBackendFallbackKernel_thenCanBeCal
|
|||
EXPECT_EQ("hello _test::dummy", stack[1].toString()->string());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, whenRegisteringBackendFallbackKernelForWrongBackend_thenCannotBeCalled) {
|
||||
auto registrar = c10::Dispatcher::singleton().registerFallback(c10::DispatchKey::CUDA, c10::KernelFunction::makeFromBoxedFunction<&backend_fallback_kernel>(), "");
|
||||
|
||||
|
|
@ -447,10 +422,8 @@ TEST(OperatorRegistrationTest, whenRegisteringBackendFallbackKernelForWrongBacke
|
|||
}, "Could not run '_test::dummy' with arguments from the 'CPU' backend.");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
bool called = false;
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, whenRegisteringBackendFallbackKernelAndRegularKernelForDifferentBackend_thenRegularKernelCanBeCalled) {
|
||||
auto registrar = c10::Dispatcher::singleton().registerFallback(c10::DispatchKey::CPU, c10::KernelFunction::makeFromBoxedFunction<&backend_fallback_kernel>(), "");
|
||||
|
||||
|
|
@ -466,7 +439,6 @@ TEST(OperatorRegistrationTest, whenRegisteringBackendFallbackKernelAndRegularKer
|
|||
EXPECT_TRUE(called);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, whenRegisteringBackendFallbackKernelAndRegularKernelForDifferentBackend_thenFallbackKernelCanBeCalled) {
|
||||
auto registrar = c10::Dispatcher::singleton().registerFallback(c10::DispatchKey::CPU, c10::KernelFunction::makeFromBoxedFunction<&backend_fallback_kernel>(), "");
|
||||
|
||||
|
|
@ -483,7 +455,6 @@ TEST(OperatorRegistrationTest, whenRegisteringBackendFallbackKernelAndRegularKer
|
|||
EXPECT_EQ("hello _test::dummy", stack[1].toString()->string());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, whenRegisteringBackendFallbackKernelAndRegularKernelForSameBackend_thenCallsRegularKernel) {
|
||||
auto registrar = c10::Dispatcher::singleton().registerFallback(c10::DispatchKey::CPU, c10::KernelFunction::makeFromBoxedFunction<&backend_fallback_kernel>(), "");
|
||||
|
||||
|
|
@ -499,9 +470,7 @@ TEST(OperatorRegistrationTest, whenRegisteringBackendFallbackKernelAndRegularKer
|
|||
EXPECT_TRUE(called);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
bool called_autograd = false;
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
bool called_nonautograd = false;
|
||||
|
||||
void nonautograd_kernel(Tensor a) {
|
||||
|
|
@ -512,7 +481,6 @@ void autograd_kernel(Tensor a) {
|
|||
called_autograd = true;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, whenRegisteringAutogradKernel_thenCanCallAutogradKernel) {
|
||||
auto registrar = c10::RegisterOperators().op("_test::dummy(Tensor dummy) -> ()", c10::RegisterOperators::options()
|
||||
.kernel<decltype(autograd_kernel), &autograd_kernel>(DispatchKey::Autograd));
|
||||
|
|
@ -530,7 +498,6 @@ TEST(OperatorRegistrationTest, whenRegisteringAutogradKernel_thenCanCallAutograd
|
|||
EXPECT_TRUE(called_autograd);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, whenRegisteringAutogradKernelWithRegularKernel_thenCanCallAutogradKernel) {
|
||||
auto registrar = c10::RegisterOperators().op("_test::dummy(Tensor dummy) -> ()", c10::RegisterOperators::options()
|
||||
.kernel<decltype(nonautograd_kernel), nonautograd_kernel>(DispatchKey::CPU)
|
||||
|
|
@ -545,7 +512,6 @@ TEST(OperatorRegistrationTest, whenRegisteringAutogradKernelWithRegularKernel_th
|
|||
EXPECT_TRUE(called_autograd);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, whenRegisteringAutogradKernelWithCatchAllKernel_thenCanCallAutogradKernel) {
|
||||
auto registrar = c10::RegisterOperators().op("_test::dummy(Tensor dummy) -> ()", c10::RegisterOperators::options()
|
||||
.catchAllKernel<decltype(nonautograd_kernel), nonautograd_kernel>()
|
||||
|
|
@ -561,7 +527,6 @@ TEST(OperatorRegistrationTest, whenRegisteringAutogradKernelWithCatchAllKernel_t
|
|||
EXPECT_FALSE(called_autograd);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, whenRegisteringAutogradKernelWithCatchAllKernel_thenCanCallCatchallKernel) {
|
||||
auto registrar = c10::RegisterOperators().op("_test::dummy(Tensor dummy) -> ()", c10::RegisterOperators::options()
|
||||
.catchAllKernel<decltype(nonautograd_kernel), nonautograd_kernel>()
|
||||
|
|
@ -576,7 +541,6 @@ TEST(OperatorRegistrationTest, whenRegisteringAutogradKernelWithCatchAllKernel_t
|
|||
EXPECT_FALSE(called_autograd);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, AutogradBackendOverridesAutogradKernel) {
|
||||
auto registrar = c10::RegisterOperators().op("_test::dummy(Tensor dummy) -> ()", c10::RegisterOperators::options()
|
||||
.kernel<decltype(nonautograd_kernel), &nonautograd_kernel>(DispatchKey::AutogradCPU)
|
||||
|
|
@ -606,7 +570,6 @@ TEST(OperatorRegistrationTest, AutogradBackendOverridesAutogradKernel) {
|
|||
EXPECT_FALSE(called_nonautograd);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, AutogradXLAOverridesAutogradKernel) {
|
||||
auto registrar = c10::RegisterOperators().op("_test::dummy(Tensor dummy) -> ()", c10::RegisterOperators::options()
|
||||
.kernel<decltype(nonautograd_kernel), &nonautograd_kernel>(DispatchKey::AutogradXLA)
|
||||
|
|
@ -631,7 +594,6 @@ TEST(OperatorRegistrationTest, AutogradXLAOverridesAutogradKernel) {
|
|||
EXPECT_FALSE(called_nonautograd);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, whenRegisterWithXLAKernelAndCatchAll_AutogradXLAIsNotFilled) {
|
||||
{
|
||||
auto registrar = c10::RegisterOperators().op("_test::dummy(Tensor dummy) -> ()", c10::RegisterOperators::options()
|
||||
|
|
@ -673,7 +635,6 @@ TEST(OperatorRegistrationTest, whenRegisterWithXLAKernelAndCatchAll_AutogradXLAI
|
|||
}
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, givenLambdaKernel_whenRegisteringWithMismatchingCppSignatures_thenFails) {
|
||||
expectThrows<c10::Error>([] {
|
||||
auto registrar = c10::RegisterOperators().op("_test::dummy", c10::RegisterOperators::options()
|
||||
|
|
@ -682,7 +643,6 @@ TEST(OperatorRegistrationTest, givenLambdaKernel_whenRegisteringWithMismatchingC
|
|||
}, "Mismatch in kernel C++ signatures");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, givenLambdaKernel_whenRegisteringCatchAllAndBackendWithMismatchingCppSignatures_thenFails) {
|
||||
expectThrows<c10::Error>([] {
|
||||
auto registrar = c10::RegisterOperators().op("_test::dummy", c10::RegisterOperators::options()
|
||||
|
|
@ -691,7 +651,6 @@ TEST(OperatorRegistrationTest, givenLambdaKernel_whenRegisteringCatchAllAndBacke
|
|||
}, "Mismatch in kernel C++ signatures");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, givenLambdaKernel_whenRegisteringBackendAndCatchAllWithMismatchingCppSignatures_thenFails) {
|
||||
expectThrows<c10::Error>([] {
|
||||
auto registrar = c10::RegisterOperators().op("_test::dummy", c10::RegisterOperators::options()
|
||||
|
|
@ -700,7 +659,6 @@ TEST(OperatorRegistrationTest, givenLambdaKernel_whenRegisteringBackendAndCatchA
|
|||
}, "Mismatch in kernel C++ signatures");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, givenLambdaKernel_whenAccessingWithMismatchingCppSignatures_thenFails) {
|
||||
auto registrar = c10::RegisterOperators().op("_test::dummy", c10::RegisterOperators::options()
|
||||
.kernel(DispatchKey::CPU, [] (int64_t) {}));
|
||||
|
|
@ -710,7 +668,6 @@ TEST(OperatorRegistrationTest, givenLambdaKernel_whenAccessingWithMismatchingCpp
|
|||
}, "Tried to access or call an operator with a wrong signature.\n operator: _test::dummy(int _0) -> ()");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, givenLambdaKernel_whenAccessingCatchAllWithMismatchingCppSignatures_thenFails) {
|
||||
auto registrar = c10::RegisterOperators().op("_test::dummy", c10::RegisterOperators::options()
|
||||
.catchAllKernel([] (int64_t) {}));
|
||||
|
|
@ -720,7 +677,6 @@ TEST(OperatorRegistrationTest, givenLambdaKernel_whenAccessingCatchAllWithMismat
|
|||
}, "Tried to access or call an operator with a wrong signature.\n operator: _test::dummy(int _0) -> ()");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, givenTorchLibrary_whenRegisteringWithMismatchingCppSignatures_thenFails) {
|
||||
auto m = MAKE_TORCH_LIBRARY(_test);
|
||||
m.def("dummy(int a) -> ()");
|
||||
|
|
@ -730,7 +686,6 @@ TEST(OperatorRegistrationTest, givenTorchLibrary_whenRegisteringWithMismatchingC
|
|||
}, "Mismatch in kernel C++ signatures");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, givenTorchLibrary_whenAccessingWithMismatchingCppSignatures_thenFails) {
|
||||
auto m = MAKE_TORCH_LIBRARY(_test);
|
||||
m.def("dummy(int a) -> ()");
|
||||
|
|
@ -741,7 +696,6 @@ TEST(OperatorRegistrationTest, givenTorchLibrary_whenAccessingWithMismatchingCpp
|
|||
}, "Tried to access or call an operator with a wrong signature.\n operator: _test::dummy(int a) -> ()");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, givenTorchLibrary_whenAccessingCatchAllWithMismatchingCppSignatures_thenFails) {
|
||||
auto m = MAKE_TORCH_LIBRARY(_test);
|
||||
m.def("dummy(int a) -> ()", [] (int64_t) {});
|
||||
|
|
@ -853,7 +807,6 @@ struct testArgTypes final {
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, testAvailableArgTypes) {
|
||||
// TODO Test Scalar
|
||||
|
||||
|
|
@ -1255,7 +1208,6 @@ TEST(OperatorRegistrationTest, testAvailableArgTypes) {
|
|||
"(Dict(str, Dict(int, str)?[])[] a) -> Dict(str, Dict(int, str)?[])[]");
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(NewOperatorRegistrationTest, testBasics) {
|
||||
auto m = MAKE_TORCH_LIBRARY(_test);
|
||||
m.def("dummy(Tensor self) -> Tensor");
|
||||
|
|
@ -1277,7 +1229,6 @@ TEST(NewOperatorRegistrationTest, testBasics) {
|
|||
ASSERT_TRUE(Dispatcher::singleton().findSchema({"_test::dummy4", ""}).has_value());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(NewOperatorRegistrationTest, importTopLevel) {
|
||||
auto m = MAKE_TORCH_LIBRARY(test);
|
||||
m.def("def1(Tensor self) -> Tensor");
|
||||
|
|
@ -1296,7 +1247,6 @@ TEST(NewOperatorRegistrationTest, importTopLevel) {
|
|||
ASSERT_TRUE(Dispatcher::singleton().findOp({"test::impl1", ""}).has_value());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(NewOperatorRegistrationTest, overload) {
|
||||
auto m = MAKE_TORCH_LIBRARY(test);
|
||||
m.def("fn(Tensor self) -> Tensor");
|
||||
|
|
@ -1308,7 +1258,6 @@ TEST(NewOperatorRegistrationTest, overload) {
|
|||
ASSERT_TRUE(Dispatcher::singleton().findSchema({"test::fn", "overload2"}).has_value());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(NewOperatorRegistrationTest, importNamespace) {
|
||||
auto m = MAKE_TORCH_LIBRARY(test);
|
||||
m.def("def1(Tensor self) -> Tensor");
|
||||
|
|
@ -1325,7 +1274,6 @@ TEST(NewOperatorRegistrationTest, importNamespace) {
|
|||
ASSERT_TRUE(Dispatcher::singleton().findOp({"test::impl1", ""}).has_value());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(NewOperatorRegistrationTest, schema) {
|
||||
auto m = MAKE_TORCH_LIBRARY(test);
|
||||
m.def("def1(Tensor self) -> Tensor");
|
||||
|
|
@ -1344,7 +1292,6 @@ TEST(NewOperatorRegistrationTest, schema) {
|
|||
ASSERT_TRUE(Dispatcher::singleton().findSchema({"test::def4", ""})->schema().isDefaultAliasAnalysisKind());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(NewOperatorRegistrationTest, whenRegisteringBackendFallbackKernelAndCatchallKernelForSameBackend_thenCallsFallbackKernel) {
|
||||
auto m1 = MAKE_TORCH_LIBRARY_IMPL(_, CPU);
|
||||
m1.fallback(CppFunction::makeFromBoxedFunction<&backend_fallback_kernel>());
|
||||
|
|
@ -1363,7 +1310,6 @@ TEST(NewOperatorRegistrationTest, whenRegisteringBackendFallbackKernelAndCatchal
|
|||
EXPECT_TRUE(called);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(NewOperatorRegistrationTest, whenRegisteringAutogradKernelWithRegularKernel_thenCanCallRegularKernel) {
|
||||
auto m = MAKE_TORCH_LIBRARY(test);
|
||||
m.def("fn(Tensor dummy) -> ()");
|
||||
|
|
@ -1379,7 +1325,6 @@ TEST(NewOperatorRegistrationTest, whenRegisteringAutogradKernelWithRegularKernel
|
|||
EXPECT_FALSE(called_autograd);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(NewOperatorRegistrationTest, dispatchWithCompositeImplicitAutogradKernel) {
|
||||
bool math_called = false;
|
||||
auto m = MAKE_TORCH_LIBRARY(test);
|
||||
|
|
@ -1425,7 +1370,6 @@ TEST(NewOperatorRegistrationTest, dispatchWithCompositeImplicitAutogradKernel) {
|
|||
}
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(NewOperatorRegistrationTest, dispatchWithCompositeImplicitAutogradAndAutogradKernel) {
|
||||
bool math_called = false;
|
||||
bool autograd_called = false;
|
||||
|
|
@ -1452,7 +1396,6 @@ TEST(NewOperatorRegistrationTest, dispatchWithCompositeImplicitAutogradAndAutogr
|
|||
}
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(NewOperatorRegistrationTest, dispatchWithCompositeImplicitAutogradAndCatchAllKernel) {
|
||||
bool math_called = false;
|
||||
bool catchall_called = false;
|
||||
|
|
@ -1480,7 +1423,6 @@ TEST(NewOperatorRegistrationTest, dispatchWithCompositeImplicitAutogradAndCatchA
|
|||
}
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(NewOperatorRegistrationTest, AutogradBackendOverridesCompositeImplicitAutogradKernel) {
|
||||
bool math_called = false;
|
||||
bool autograd_called = false;
|
||||
|
|
@ -1520,7 +1462,6 @@ TEST(NewOperatorRegistrationTest, AutogradBackendOverridesCompositeImplicitAutog
|
|||
}
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(NewOperatorRegistrationTest, BackendOverridesCompositeImplicitAutogradKernel) {
|
||||
bool math_called = false;
|
||||
bool backend_called = false;
|
||||
|
|
@ -1561,7 +1502,6 @@ TEST(NewOperatorRegistrationTest, BackendOverridesCompositeImplicitAutogradKerne
|
|||
}
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(NewOperatorRegistrationTest, dispatchWithCompositeExplicitAutogradKernel) {
|
||||
bool called = false;
|
||||
auto m = MAKE_TORCH_LIBRARY(test);
|
||||
|
|
@ -1610,7 +1550,6 @@ TEST(NewOperatorRegistrationTest, dispatchWithCompositeExplicitAutogradKernel) {
|
|||
}
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(NewOperatorRegistrationTest, dispatchWithCompositeExplicitAutogradAndCompositeImplicitAutogradKernel) {
|
||||
bool backend_called = false;
|
||||
bool math_called = false;
|
||||
|
|
@ -1667,7 +1606,6 @@ TEST(NewOperatorRegistrationTest, dispatchWithCompositeExplicitAutogradAndCompos
|
|||
}
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(NewOperatorRegistrationTest, BackendOverridesCompositeExplicitAutogradKernel) {
|
||||
bool default_called = false;
|
||||
bool backend_called = false;
|
||||
|
|
@ -1710,7 +1648,6 @@ TEST(NewOperatorRegistrationTest, BackendOverridesCompositeExplicitAutogradKerne
|
|||
}
|
||||
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(NewOperatorRegistrationTest, dispatch) {
|
||||
bool cpu_called = false;
|
||||
bool cuda_called = false;
|
||||
|
|
@ -1753,7 +1690,6 @@ TEST(NewOperatorRegistrationTest, dispatch) {
|
|||
}
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(NewOperatorRegistrationTest, dispatchAutogradPrecedence) {
|
||||
bool cpu_called = false;
|
||||
auto m = MAKE_TORCH_LIBRARY(test);
|
||||
|
|
@ -1795,7 +1731,6 @@ TEST(NewOperatorRegistrationTest, dispatchAutogradPrecedence) {
|
|||
}
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(NewOperatorRegistrationTest, throwsWhenRegisterToBackendMapsToAutogradOther) {
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-init-variables)
|
||||
bool sparsecpu_called, math_called = false;
|
||||
|
|
@ -1818,7 +1753,6 @@ TEST(NewOperatorRegistrationTest, throwsWhenRegisterToBackendMapsToAutogradOther
|
|||
}
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(NewOperatorRegistrationTest, dispatchMultipleTensors) {
|
||||
bool privateuse1_called = false;
|
||||
bool catchall_called = false;
|
||||
|
|
@ -1884,7 +1818,6 @@ TEST(NewOperatorRegistrationTest, dispatchMultipleTensors) {
|
|||
}
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(NewOperatorRegistrationTest, dispatchMultiple) {
|
||||
bool cpu_called = false;
|
||||
bool cuda_called = false;
|
||||
|
|
@ -1921,7 +1854,6 @@ TEST(NewOperatorRegistrationTest, dispatchMultiple) {
|
|||
}
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(NewOperatorRegistrationTest, fallback) {
|
||||
auto m = MAKE_TORCH_LIBRARY_IMPL(_, CPU);
|
||||
m.fallback(CppFunction::makeFromBoxedFunction<&backend_fallback_kernel>());
|
||||
|
|
@ -1934,7 +1866,6 @@ TEST(NewOperatorRegistrationTest, fallback) {
|
|||
EXPECT_EQ("hello _test::dummy", stack[1].toString()->string());
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(NewOperatorRegistrationTest, BackendSelectRedispatchesToCPU) {
|
||||
bool cpu_called = false;
|
||||
bool backend_generic_called = false;
|
||||
|
|
@ -1955,7 +1886,6 @@ TEST(NewOperatorRegistrationTest, BackendSelectRedispatchesToCPU) {
|
|||
ASSERT_TRUE(backend_generic_called);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(NewOperatorRegistrationTest, TorchLibraryTwiceIsError) {
|
||||
{
|
||||
auto m = MAKE_TORCH_LIBRARY(test);
|
||||
|
|
@ -1971,7 +1901,6 @@ Tensor dummy_fn(const Tensor& x) {
|
|||
return x;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(NewOperatorRegistrationTest, CppFunction) {
|
||||
// Just show off the possible ways to register functions
|
||||
auto m = MAKE_TORCH_LIBRARY(test);
|
||||
|
|
@ -1999,7 +1928,6 @@ struct OpRegistrationListenerForDelayedListenerTest : public c10::OpRegistration
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(NewOperatorRegistrationTest, testDelayedListener) {
|
||||
auto listener = std::make_unique<OpRegistrationListenerForDelayedListenerTest>();
|
||||
auto listener_ptr = listener.get();
|
||||
|
|
@ -2019,7 +1947,6 @@ TEST(NewOperatorRegistrationTest, testDelayedListener) {
|
|||
EXPECT_EQ(initial_num_deregisters + 1, listener_ptr->num_deregisters_);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(NewOperatorRegistrationTest, testImplNoDefGetsCaught) {
|
||||
auto danglingImpls = Dispatcher::singleton().findDanglingImpls();
|
||||
std::string error_str = "Discovered operators that have been registered through the dispatcher"
|
||||
|
|
@ -2036,11 +1963,8 @@ TEST(NewOperatorRegistrationTest, testImplNoDefGetsCaught) {
|
|||
ASSERT_EQ(danglingImpls.size(), 0) << error_str;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
bool called_kernel_cpu = false;
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
bool called_kernel_autograd = false;
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
bool called_kernel_tracing = false;
|
||||
|
||||
void cpu_kernel(Tensor) {
|
||||
|
|
@ -2071,7 +1995,6 @@ void tracing_kernel_redispatching_with_DispatchKeySet(c10::DispatchKeySet ks, Te
|
|||
callOpUnboxedWithPrecomputedDispatchKeySet<void, Tensor>(*op, updatedDispatchKeySet, a);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, callKernelsWithDispatchKeySetConvention_call_redispatchesToLowerPriorityKernels) {
|
||||
auto m = MAKE_TORCH_LIBRARY(test);
|
||||
m.def("fn(Tensor dummy) -> ()");
|
||||
|
|
@ -2095,7 +2018,6 @@ TEST(OperatorRegistrationTest, callKernelsWithDispatchKeySetConvention_call_redi
|
|||
EXPECT_TRUE(called_kernel_cpu);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, callKernelsWithDispatchKeySetConvention_callBoxed_redispatchesToLowerPriorityKernels) {
|
||||
auto m = MAKE_TORCH_LIBRARY(test);
|
||||
m.def("fn(Tensor dummy) -> ()");
|
||||
|
|
@ -2119,7 +2041,6 @@ TEST(OperatorRegistrationTest, callKernelsWithDispatchKeySetConvention_callBoxed
|
|||
EXPECT_TRUE(called_kernel_cpu);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
TEST(OperatorRegistrationTest, callKernelsWithDispatchKeySetConvention_mixedCallingConventions_redispatchesToLowerPriorityKernels) {
|
||||
auto m = MAKE_TORCH_LIBRARY(test);
|
||||
m.def("fn(Tensor dummy) -> ()");
|
||||
|
|
|
|||
|
|
@ -988,7 +988,6 @@ VaryingShape<Stride> TensorType::computeStrideProps(
|
|||
return VaryingShape<Stride>{stride_properties};
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
std::atomic<size_t> ShapeSymbol::num_symbols{1};
|
||||
|
||||
template struct VaryingShape<c10::ShapeSymbol>;
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
namespace at {
|
||||
namespace detail {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
C10_REGISTER_GUARD_IMPL(CPU, c10::impl::NoOpDeviceGuardImpl<DeviceType::CPU>);
|
||||
|
||||
}} // namespace at::detail
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ namespace detail {
|
|||
//
|
||||
// CUDAHooks doesn't actually contain any data, so leaking it is very benign;
|
||||
// you're probably losing only a word (the vptr in the allocated object.)
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
static CUDAHooksInterface* cuda_hooks = nullptr;
|
||||
|
||||
const CUDAHooksInterface& getCUDAHooks() {
|
||||
|
|
@ -52,7 +51,6 @@ const CUDAHooksInterface& getCUDAHooks() {
|
|||
}
|
||||
} // namespace detail
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
C10_DEFINE_REGISTRY(CUDAHooksRegistry, CUDAHooksInterface, CUDAHooksArgs)
|
||||
|
||||
} // namespace at
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ const HIPHooksInterface& getHIPHooks() {
|
|||
}
|
||||
} // namespace detail
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
C10_DEFINE_REGISTRY(HIPHooksRegistry, HIPHooksInterface, HIPHooksArgs)
|
||||
|
||||
} // namespace at
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
namespace at {
|
||||
namespace detail {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
C10_REGISTER_GUARD_IMPL(Meta, c10::impl::NoOpDeviceGuardImpl<DeviceType::Meta>);
|
||||
|
||||
}} // namespace at::detail
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
namespace at {
|
||||
namespace metal {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
std::atomic<const MetalInterface*> g_metal_impl_registry;
|
||||
|
||||
MetalImplRegistrar::MetalImplRegistrar(MetalInterface* impl) {
|
||||
|
|
|
|||
|
|
@ -178,47 +178,26 @@ namespace native {
|
|||
static const double SELU_ALPHA = 1.6732632423543772848170429916717;
|
||||
static const double SELU_SCALE = 1.0507009873554804934193349852946;
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(elu_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(elu_backward_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(softplus_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(softplus_backward_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(log_sigmoid_cpu_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(log_sigmoid_backward_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(threshold_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(hardtanh_backward_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(hardsigmoid_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(hardsigmoid_backward_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(hardswish_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(hardswish_backward_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(hardshrink_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(softshrink_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(shrink_backward_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(leaky_relu_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(leaky_relu_backward_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(silu_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(silu_backward_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(mish_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(mish_backward_stub);
|
||||
|
||||
TORCH_IMPL_FUNC(elu_out) (
|
||||
|
|
@ -911,9 +890,7 @@ Tensor& log_sigmoid_backward_cpu_out(const Tensor& grad_output,
|
|||
return grad_input;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(GeluKernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(GeluBackwardKernel);
|
||||
|
||||
}} // namespace at::native
|
||||
|
|
|
|||
|
|
@ -139,9 +139,7 @@ namespace {
|
|||
return grad_input;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(adaptive_avg_pool2d_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(adaptive_avg_pool2d_backward_kernel);
|
||||
|
||||
} // at::native
|
||||
|
|
|
|||
|
|
@ -1462,7 +1462,6 @@ Tensor& linalg_cholesky_out(const Tensor &self, Tensor &result) {
|
|||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cholesky_inverse ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(cholesky_inverse_stub);
|
||||
|
||||
Tensor& cholesky_inverse_out_info(Tensor& result, Tensor& infos, const Tensor& input, bool upper) {
|
||||
|
|
@ -1576,7 +1575,6 @@ std::tuple<Tensor, Tensor, Tensor> _lu_with_info(const Tensor& self, bool comput
|
|||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ triangular_solve ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(triangular_solve_stub);
|
||||
|
||||
/*
|
||||
|
|
@ -1686,7 +1684,6 @@ std::tuple<Tensor&, Tensor&> triangular_solve_out(const Tensor& self, const Tens
|
|||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ qr ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(geqrf_stub);
|
||||
|
||||
static void geqrf_out_helper(const Tensor& input, const Tensor& QR, const Tensor& tau) {
|
||||
|
|
@ -1950,7 +1947,6 @@ std::tuple<Tensor&,Tensor&> qr_out(const Tensor& self, bool some, Tensor& Q, Ten
|
|||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ orgqr ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(orgqr_stub);
|
||||
|
||||
/*
|
||||
|
|
@ -2088,7 +2084,6 @@ Tensor orgqr(const Tensor& input, const Tensor& tau) {
|
|||
return at::linalg_householder_product(input, tau);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(ormqr_stub);
|
||||
|
||||
void ormqr_out_helper(const Tensor& input, const Tensor& tau, const Tensor& other, const Tensor& result, bool left, bool transpose) {
|
||||
|
|
@ -2233,7 +2228,6 @@ Tensor ormqr(const Tensor& input, const Tensor& tau, const Tensor& other, bool l
|
|||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ linalg_eigh ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(linalg_eigh_stub);
|
||||
|
||||
/*
|
||||
|
|
@ -2591,7 +2585,6 @@ static Tensor& linalg_eig_make_complex_eigenvectors(Tensor& complex_vectors, con
|
|||
return complex_vectors;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(linalg_eig_stub);
|
||||
|
||||
std::tuple<Tensor&, Tensor&> linalg_eig_out_info(const Tensor& input, Tensor& values, Tensor& vectors, Tensor& infos, bool compute_eigenvectors) {
|
||||
|
|
@ -2877,7 +2870,6 @@ Tensor linalg_eigvals(const Tensor& input) {
|
|||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ eig ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(eig_stub);
|
||||
|
||||
std::tuple<Tensor&, Tensor&> eig_out(const Tensor& self, bool eigenvectors, Tensor& e, Tensor& v) {
|
||||
|
|
|
|||
|
|
@ -949,112 +949,64 @@ void lu_solve_kernel(const Tensor& b, const Tensor& lu, const Tensor& pivots) {
|
|||
|
||||
} // anonymous namespace
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_ARCH_DISPATCH(cholesky_stub, DEFAULT, &cholesky_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX512_DISPATCH(cholesky_stub, &cholesky_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX2_DISPATCH(cholesky_stub, &cholesky_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_VSX_DISPATCH(cholesky_stub, &cholesky_kernel);
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_ARCH_DISPATCH(cholesky_inverse_stub, DEFAULT, &cholesky_inverse_kernel_impl);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX512_DISPATCH(cholesky_inverse_stub, &cholesky_inverse_kernel_impl);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX2_DISPATCH(cholesky_inverse_stub, &cholesky_inverse_kernel_impl);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_VSX_DISPATCH(cholesky_inverse_stub, &cholesky_inverse_kernel_impl);
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_ARCH_DISPATCH(eig_stub, DEFAULT, &eig_kernel_impl);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX512_DISPATCH(eig_stub, &eig_kernel_impl);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX2_DISPATCH(eig_stub, &eig_kernel_impl);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_VSX_DISPATCH(eig_stub, &eig_kernel_impl);
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_ARCH_DISPATCH(linalg_eig_stub, DEFAULT, &linalg_eig_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX512_DISPATCH(linalg_eig_stub, &linalg_eig_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX2_DISPATCH(linalg_eig_stub, &linalg_eig_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_VSX_DISPATCH(linalg_eig_stub, &linalg_eig_kernel);
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_ARCH_DISPATCH(linalg_eigh_stub, DEFAULT, &linalg_eigh_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX512_DISPATCH(linalg_eigh_stub, &linalg_eigh_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX2_DISPATCH(linalg_eigh_stub, &linalg_eigh_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_VSX_DISPATCH(linalg_eigh_stub, &linalg_eigh_kernel);
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_ARCH_DISPATCH(geqrf_stub, DEFAULT, &geqrf_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX512_DISPATCH(geqrf_stub, &geqrf_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX2_DISPATCH(geqrf_stub, &geqrf_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_VSX_DISPATCH(geqrf_stub, &geqrf_kernel);
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_ARCH_DISPATCH(orgqr_stub, DEFAULT, &orgqr_kernel_impl);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX512_DISPATCH(orgqr_stub, &orgqr_kernel_impl);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX2_DISPATCH(orgqr_stub, &orgqr_kernel_impl);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_VSX_DISPATCH(orgqr_stub, &orgqr_kernel_impl);
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_ARCH_DISPATCH(ormqr_stub, DEFAULT, &ormqr_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX512_DISPATCH(ormqr_stub, &ormqr_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX2_DISPATCH(ormqr_stub, &ormqr_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_VSX_DISPATCH(ormqr_stub, &ormqr_kernel);
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_ARCH_DISPATCH(lstsq_stub, DEFAULT, &lstsq_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX512_DISPATCH(lstsq_stub, &lstsq_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX2_DISPATCH(lstsq_stub, &lstsq_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_VSX_DISPATCH(lstsq_stub, &lstsq_kernel);
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_ARCH_DISPATCH(triangular_solve_stub, DEFAULT, &triangular_solve_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX512_DISPATCH(triangular_solve_stub, &triangular_solve_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX2_DISPATCH(triangular_solve_stub, &triangular_solve_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_VSX_DISPATCH(triangular_solve_stub, &triangular_solve_kernel);
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_ARCH_DISPATCH(lu_stub, DEFAULT, &lu_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX512_DISPATCH(lu_stub, &lu_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX2_DISPATCH(lu_stub, &lu_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_VSX_DISPATCH(lu_stub, &lu_kernel);
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_ARCH_DISPATCH(lu_solve_stub, DEFAULT, &lu_solve_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX512_DISPATCH(lu_solve_stub, &lu_solve_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX2_DISPATCH(lu_solve_stub, &lu_solve_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_VSX_DISPATCH(lu_solve_stub, &lu_solve_kernel);
|
||||
|
||||
}} // namespace at::native
|
||||
|
|
|
|||
|
|
@ -230,89 +230,47 @@ CREATE_COMPARISON_SCALAR_TENSOR_META_FUNC(ge);
|
|||
|
||||
namespace native {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(add_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(add_clamp_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(sub_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(mul_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(div_true_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(div_floor_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(div_trunc_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(remainder_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(atan2_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(bitwise_and_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(bitwise_or_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(bitwise_xor_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(lshift_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(rshift_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(logical_and_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(logical_or_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(logical_xor_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(lt_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(le_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(gt_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(ge_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(eq_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(ne_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(sigmoid_backward_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(logit_backward_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(tanh_backward_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(maximum_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(minimum_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(fmax_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(fmin_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(fmod_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(logaddexp_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(logaddexp2_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(gcd_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(lcm_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(hypot_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(igamma_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(igammac_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(nextafter_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(heaviside_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(copysign_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(xlogy_stub);
|
||||
DEFINE_DISPATCH(xlog1py_stub);
|
||||
DEFINE_DISPATCH(zeta_stub);
|
||||
|
|
|
|||
|
|
@ -97,7 +97,6 @@ fbgemm::matrix_op_t to_fbgemm(TransposeType trans) {
|
|||
|
||||
} // namespace (anonymous)
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(gemm_stub);
|
||||
|
||||
void gemm(
|
||||
|
|
@ -263,7 +262,6 @@ void gemm(
|
|||
transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(axpy_stub);
|
||||
|
||||
void axpy(int64_t n, double a, const double *x, int64_t incx, double *y, int64_t incy) {
|
||||
|
|
@ -350,7 +348,6 @@ void axpy(int64_t n, c10::complex<float> a, const c10::complex<float> *x, int64_
|
|||
n, a, x, incx, y, incy);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(copy_stub);
|
||||
|
||||
void copy(int64_t n, const double *x, int64_t incx, double *y, int64_t incy) {
|
||||
|
|
|
|||
|
|
@ -23,7 +23,6 @@ constexpr int MIOPEN_DIM_MAX = 5;
|
|||
|
||||
namespace at { namespace native {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(convolution_depthwise3x3_winograd_stub);
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-pro-type-member-init)
|
||||
|
|
|
|||
|
|
@ -253,7 +253,6 @@ Tensor& copy_(Tensor& self, const Tensor& src, bool non_blocking) {
|
|||
return self;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(copy_stub);
|
||||
|
||||
} // namespace native
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
namespace at { namespace native {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(cross_stub);
|
||||
|
||||
Tensor cross(const Tensor & input, const Tensor & other, const c10::optional<int64_t> dimension) {
|
||||
|
|
|
|||
|
|
@ -203,9 +203,7 @@ const Tensor& gradInput) {
|
|||
gradOutput, indices);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(max_pool2d_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(max_pool2d_backward_kernel);
|
||||
|
||||
} // at::native
|
||||
|
|
|
|||
|
|
@ -8,13 +8,9 @@
|
|||
|
||||
namespace at { namespace native {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(pdist_forward_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(pdist_backward_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(cdist_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(cdist_backward_stub);
|
||||
|
||||
Tensor pairwise_distance(const Tensor& x1, const Tensor& x2, double p, double eps, bool keepdim) {
|
||||
|
|
|
|||
|
|
@ -122,29 +122,17 @@ int64_t sample_poisson(double lambda, at::CPUGeneratorImpl* generator) {
|
|||
namespace at {
|
||||
namespace native {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(bernoulli_tensor_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(bernoulli_scalar_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(cauchy_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(exponential_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(multinomial_with_replacement_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(geometric_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(log_normal_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(uniform_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(normal_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(random_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(random_from_to_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(random_full_64_bits_range_stub);
|
||||
|
||||
// ==================================================== Bernoulli =====================================================
|
||||
|
|
|
|||
|
|
@ -50,7 +50,6 @@ Tensor& fill_meta_(Tensor& self, const Tensor& value) {
|
|||
return self;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(fill_stub);
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ fill_diagonal ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace at { namespace native {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(_compute_linear_combination_stub);
|
||||
|
||||
// If `coefficients` is a [m, n] Tensor and
|
||||
|
|
|
|||
|
|
@ -5,9 +5,7 @@
|
|||
namespace at {
|
||||
namespace native {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(glu_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(glu_backward_stub);
|
||||
|
||||
Tensor& glu_out(const Tensor& self, int64_t dim, Tensor &result) {
|
||||
|
|
|
|||
|
|
@ -758,7 +758,6 @@ Tensor grid_sampler_2d_cpu(const Tensor& input, const Tensor& grid,
|
|||
kCPU, input, grid, interpolation_mode, padding_mode, align_corners);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(grid_sampler_2d_cpu_kernel);
|
||||
|
||||
|
||||
|
|
@ -805,7 +804,6 @@ grid_sampler_2d_backward_cpu(const Tensor& grad_output, const Tensor& input, con
|
|||
kCPU, grad_output, input, grid, interpolation_mode, padding_mode, align_corners);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(grid_sampler_2d_backward_cpu_kernel);
|
||||
|
||||
// No shape checking needed here. See # NOTE [ grid_sampler Native Functions ].
|
||||
|
|
|
|||
|
|
@ -34,10 +34,8 @@
|
|||
|
||||
namespace at { namespace native {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(histogram_stub);
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(histogram_linear_stub);
|
||||
|
||||
namespace {
|
||||
|
|
|
|||
|
|
@ -10,10 +10,8 @@ namespace at { namespace native {
|
|||
using histogram_fn = void(*)(const Tensor&, const c10::optional<Tensor>&, bool, Tensor&, const Tensor&);
|
||||
using histogram_linear_fn = void(*)(const Tensor&, const c10::optional<Tensor>&, bool, Tensor&, const Tensor&, bool);
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DECLARE_DISPATCH(histogram_fn, histogram_stub);
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DECLARE_DISPATCH(histogram_linear_fn, histogram_linear_stub);
|
||||
|
||||
}} // namespace at::native
|
||||
|
|
|
|||
|
|
@ -43,9 +43,7 @@ Tensor lerp_cpu_scalar(const Tensor& self, const Tensor& end, const Scalar& weig
|
|||
return result;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(lerp_kernel_scalar_weight);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(lerp_kernel_tensor_weight);
|
||||
|
||||
} // namespace native
|
||||
|
|
|
|||
|
|
@ -60,9 +60,7 @@ TORCH_META_FUNC(mm)(const Tensor & self, const Tensor & mat2) {
|
|||
} // namespace meta
|
||||
namespace native {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(addr_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(linalg_vector_norm_stub);
|
||||
|
||||
// Helper function for det methods.
|
||||
|
|
|
|||
|
|
@ -22,17 +22,11 @@ namespace {
|
|||
|
||||
namespace at { namespace native {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(smooth_l1_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(smooth_l1_backward_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(huber_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(huber_backward_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(mse_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(mse_backward_stub);
|
||||
|
||||
Tensor cosine_embedding_loss(const Tensor& input1, const Tensor& input2, const Tensor& target, double margin, int64_t reduction) {
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
namespace at {
|
||||
namespace native {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(max_pool1d_stub);
|
||||
|
||||
namespace {
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ struct MetaAllocator final : public at::Allocator {
|
|||
}
|
||||
};
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
static MetaAllocator g_meta_alloc;
|
||||
|
||||
at::Allocator* GetMetaAllocator() {
|
||||
|
|
|
|||
|
|
@ -118,9 +118,7 @@ bool _nnpack_available() {
|
|||
|
||||
// Make thread_local for safety in cases where we have multiple threads running
|
||||
// Convs at once
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
static thread_local void* workspace = nullptr;
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
static thread_local size_t workspace_size = 0;
|
||||
|
||||
static inline void deallocate_workspace() {
|
||||
|
|
|
|||
|
|
@ -33,13 +33,9 @@ TORCH_META_FUNC(renorm)(const Tensor& self, const Scalar& p, int64_t dim, const
|
|||
|
||||
namespace native {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(batch_norm_cpu_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(batch_norm_cpu_collect_stats_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(batch_norm_cpu_backward_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(renorm_scale_factor_stub);
|
||||
|
||||
namespace {
|
||||
|
|
|
|||
|
|
@ -89,9 +89,7 @@ Tensor& addcdiv_out(const Tensor& self,
|
|||
return result;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(addcmul_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(addcdiv_stub);
|
||||
|
||||
} // namespace native
|
||||
|
|
|
|||
|
|
@ -34,9 +34,7 @@ TORCH_META_FUNC2(pow, Scalar) (const Scalar& base, const Tensor& exp) {
|
|||
|
||||
namespace native {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(pow_tensor_tensor_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(pow_tensor_scalar_stub);
|
||||
|
||||
TORCH_IMPL_FUNC(pow_Tensor_Tensor_out) (const Tensor& base, const Tensor& exp, const Tensor& out) {
|
||||
|
|
|
|||
|
|
@ -487,7 +487,6 @@ c10::intrusive_ptr<CellParamsBase> make_quantized_cell_params_fp16(
|
|||
static std::unordered_map<
|
||||
std::string,
|
||||
c10::intrusive_ptr<CellParamsBase> (*)(CellParamsSerializationType)>
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
cell_params_deserializers = {
|
||||
{"quantized", &QuantizedCellParams::__setstate__},
|
||||
{"quantized_dynamic", &QuantizedCellParamsDynamic::__setstate__},
|
||||
|
|
@ -1396,7 +1395,6 @@ bool _use_cudnn_rnn_flatten_weight() {
|
|||
std::move(packed_output.data), std::move(std::get<1>(result))); \
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
ONE_HIDDEN_RNN(gru, GRUCell<CellParams>)
|
||||
ONE_HIDDEN_QRNN(quantized_gru, GRUCell<QRNNCellParamsWrapper>)
|
||||
|
||||
|
|
@ -1457,27 +1455,17 @@ std::tuple<Tensor, Tensor> quantized_gru_data_legacy(
|
|||
}
|
||||
|
||||
using tanf_cell_type = SimpleCell<tanh_f, CellParams>;
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
ONE_HIDDEN_RNN(rnn_tanh, tanf_cell_type)
|
||||
using relu_cell_type = SimpleCell<relu_f, CellParams>;
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
ONE_HIDDEN_RNN(rnn_relu, relu_cell_type);
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(lstm_cudnn_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(lstm_packed_cudnn_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(lstm_miopen_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(lstm_packed_miopen_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_NO_CPU_DISPATCH(lstm_cudnn_stub, lstm_fn);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_NO_CPU_DISPATCH(lstm_packed_cudnn_stub, lstm_packed_fn);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_NO_CPU_DISPATCH(lstm_miopen_stub, lstm_fn);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_NO_CPU_DISPATCH(lstm_packed_miopen_stub, lstm_packed_fn);
|
||||
|
||||
std::tuple<Tensor, Tensor, Tensor> lstm(
|
||||
|
|
@ -1993,10 +1981,8 @@ DEFINE_QUANTIZED_RNN_CELL_DYNAMIC(quantized_rnn_tanh_cell_dynamic, simple_hx_typ
|
|||
|
||||
namespace {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
static auto ensure_linear_params_registered = register_linear_params();
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
static auto cell_params_base_registry =
|
||||
torch::class_<CellParamsBase>("rnn", "CellParamsBase")
|
||||
.def_pickle(
|
||||
|
|
|
|||
|
|
@ -9,9 +9,7 @@
|
|||
|
||||
namespace at { namespace native {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DECLARE_DISPATCH(void(*)(TensorIterator&, const Scalar&, const Scalar&, const Scalar&), arange_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DECLARE_DISPATCH(void(*)(TensorIterator&, const Scalar&, const Scalar&, int64_t), linspace_stub);
|
||||
|
||||
Tensor& linspace_cpu_out(const Scalar& start, const Scalar& end, c10::optional<int64_t> optional_steps, Tensor& result) {
|
||||
|
|
@ -206,9 +204,7 @@ Tensor& arange_cpu_out(const Scalar& start, const Scalar& end, const Scalar& ste
|
|||
return result;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(arange_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(linspace_stub);
|
||||
|
||||
}} // namespace at::native
|
||||
|
|
|
|||
|
|
@ -6,11 +6,8 @@
|
|||
namespace at {
|
||||
namespace native {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(min_all_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(max_all_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(_aminmax_all_stub);
|
||||
|
||||
Tensor min(const Tensor &self) {
|
||||
|
|
|
|||
|
|
@ -120,35 +120,20 @@ TORCH_META_FUNC(argmin)
|
|||
|
||||
namespace native {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(sum_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(nansum_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(std_var_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(prod_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(norm_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(mean_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(and_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(or_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(min_values_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(max_values_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(argmax_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(argmin_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(cumsum_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(cumprod_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(logcumsumexp_stub);
|
||||
|
||||
Tensor _logcumsumexp_cpu(const Tensor& self, int64_t dim) {
|
||||
|
|
|
|||
|
|
@ -7,9 +7,7 @@
|
|||
namespace at {
|
||||
namespace native {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(_segment_reduce_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(_segment_reduce_backward_stub);
|
||||
|
||||
namespace {
|
||||
|
|
@ -271,14 +269,10 @@ Tensor segment_reduce_kernel(
|
|||
|
||||
REGISTER_ARCH_DISPATCH(
|
||||
_segment_reduce_stub,
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFAULT,
|
||||
&_segment_reduce_cpu_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX2_DISPATCH(_segment_reduce_stub, &_segment_reduce_cpu_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX512_DISPATCH(_segment_reduce_stub, &_segment_reduce_cpu_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_VSX_DISPATCH(_segment_reduce_stub, &_segment_reduce_cpu_kernel);
|
||||
|
||||
// Currently some computation is being duplicated across forward and backward.
|
||||
|
|
@ -315,14 +309,11 @@ Tensor _segment_reduce_backward_kernel(
|
|||
|
||||
REGISTER_ARCH_DISPATCH(
|
||||
_segment_reduce_backward_stub,
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFAULT,
|
||||
&_segment_reduce_cpu_backward_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX512_DISPATCH(
|
||||
_segment_reduce_backward_stub,
|
||||
&_segment_reduce_cpu_backward_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_AVX2_DISPATCH(
|
||||
_segment_reduce_backward_stub,
|
||||
&_segment_reduce_cpu_backward_kernel);
|
||||
|
|
|
|||
|
|
@ -303,13 +303,9 @@ Tensor special_log_softmax(const Tensor& input, const int64_t dim, c10::optional
|
|||
return at::log_softmax(input, dim, dtype);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(softmax_lastdim_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(log_softmax_lastdim_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(softmax_backward_lastdim_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(log_softmax_backward_lastdim_kernel);
|
||||
|
||||
DEFINE_DISPATCH(softmax_kernel);
|
||||
|
|
|
|||
|
|
@ -41,9 +41,7 @@ using namespace native;
|
|||
|
||||
namespace native {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(sort_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(topk_stub);
|
||||
|
||||
namespace {
|
||||
|
|
|
|||
|
|
@ -1048,7 +1048,6 @@ void _fft_fill_with_conjugate_symmetry_(const Tensor& input, IntArrayRef dim_) {
|
|||
mirror_dims, signal_half_sizes, in_strides, in_data, out_strides, out_data);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(fft_fill_with_conjugate_symmetry_stub);
|
||||
|
||||
}} // at::native
|
||||
|
|
|
|||
|
|
@ -148,42 +148,24 @@ TORCH_META_FUNC(scatter_add)
|
|||
|
||||
namespace native {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(index_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(index_fill_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(index_copy_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(index_put_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(index_put_with_sort_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(put_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(take_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(masked_fill_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_NO_CPU_DISPATCH(index_put_with_sort_stub, index_put_with_sort_fn);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(masked_select_serial_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(masked_select_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(masked_scatter_stub);
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(gather_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(scatter_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(scatter_fill_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(scatter_add_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(scatter_reduce_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(scatter_scalar_reduce_stub);
|
||||
|
||||
static bool all_strides_match(TensorList tensors) {
|
||||
|
|
|
|||
|
|
@ -49,9 +49,7 @@ void window_function_checks(
|
|||
|
||||
} // namespace
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(complex_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(polar_stub);
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ arange ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
|
@ -1526,7 +1524,6 @@ Tensor rand(
|
|||
}
|
||||
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(kaiser_window_stub);
|
||||
|
||||
} // namespace native
|
||||
|
|
|
|||
|
|
@ -29,9 +29,7 @@
|
|||
namespace at {
|
||||
namespace native {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(cat_serial_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(stack_serial_stub);
|
||||
|
||||
Tensor _reshape_from_tensor(const Tensor& self, const Tensor& shape_tensor) {
|
||||
|
|
|
|||
|
|
@ -209,7 +209,6 @@ std::vector<Tensor> atleast_3d(TensorList tensors) {
|
|||
return result;
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(flip_stub);
|
||||
|
||||
}} // namespace at::native
|
||||
|
|
|
|||
|
|
@ -2,9 +2,7 @@
|
|||
|
||||
namespace at { namespace native {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(unfolded2d_copy_stub);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(unfolded2d_acc_stub);
|
||||
|
||||
}}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace at { namespace native {
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(unfold_backward_stub);
|
||||
|
||||
Tensor unfold_backward(
|
||||
|
|
|
|||
|
|
@ -219,7 +219,6 @@ Tensor upsample_bicubic2d_backward(
|
|||
return at::upsample_bicubic2d_backward(grad_output, osize, input_size, align_corners, scale_h, scale_w);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(upsample_bicubic2d_kernel);
|
||||
|
||||
} // namespace native
|
||||
|
|
|
|||
|
|
@ -101,9 +101,7 @@ Tensor upsample_bilinear2d_backward(
|
|||
return at::upsample_bilinear2d_backward(grad_output, osize, input_size, align_corners, scale_h, scale_w);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(upsample_bilinear2d_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(upsample_bilinear2d_backward_kernel);
|
||||
|
||||
} // namespace native
|
||||
|
|
|
|||
|
|
@ -98,9 +98,7 @@ Tensor upsample_linear1d_backward(
|
|||
return at::upsample_linear1d_backward(grad_output, osize, input_size, align_corners, scale_w);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(upsample_linear1d_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(upsample_linear1d_backward_kernel);
|
||||
|
||||
} // namespace native
|
||||
|
|
|
|||
|
|
@ -80,9 +80,7 @@ Tensor upsample_nearest1d_backward(
|
|||
return at::upsample_nearest1d_backward(grad_output, osize, input_size, scale_w);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(upsample_nearest1d_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(upsample_nearest1d_backward_kernel);
|
||||
|
||||
} // namespace native
|
||||
|
|
|
|||
|
|
@ -93,9 +93,7 @@ Tensor upsample_nearest2d_backward(
|
|||
return at::upsample_nearest2d_backward(grad_output, osize, input_size, scale_h, scale_w);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(upsample_nearest2d_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(upsample_nearest2d_backward_kernel);
|
||||
|
||||
} // namespace native
|
||||
|
|
|
|||
|
|
@ -104,9 +104,7 @@ Tensor upsample_nearest3d_backward_cpu(
|
|||
return at::upsample_nearest3d_backward(grad_output, osize, input_size, scale_d, scale_h, scale_w);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(upsample_nearest3d_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(upsample_nearest3d_backward_kernel);
|
||||
|
||||
} // namespace native
|
||||
|
|
|
|||
|
|
@ -112,9 +112,7 @@ Tensor upsample_trilinear3d_backward(
|
|||
return at::upsample_trilinear3d_backward(grad_output, osize, input_size, align_corners, scale_d, scale_h, scale_w);
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(upsample_trilinear3d_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
DEFINE_DISPATCH(upsample_trilinear3d_backward_kernel);
|
||||
|
||||
} // namespace native
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@ torch::class_<LinearPackedParamsBase> register_linear_params() {
|
|||
}
|
||||
|
||||
namespace {
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
static auto linear_params = register_linear_params();
|
||||
} // namespace
|
||||
|
||||
|
|
|
|||
|
|
@ -689,55 +689,30 @@ void mish_backward_kernel(TensorIterator& iter) {
|
|||
|
||||
} // namespace
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(log_sigmoid_cpu_stub, &log_sigmoid_cpu_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(log_sigmoid_backward_stub, &log_sigmoid_backward_cpu_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(threshold_stub, &threshold_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(elu_stub, &elu_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(elu_backward_stub, &elu_backward_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(GeluKernel, &GeluKernelImpl);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(GeluBackwardKernel, &GeluBackwardKernelImpl);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(hardtanh_backward_stub, &hardtanh_backward_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(hardsigmoid_stub, &hardsigmoid_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(hardsigmoid_backward_stub, &hardsigmoid_backward_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(hardswish_stub, &hardswish_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(hardswish_backward_stub, &hardswish_backward_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(hardshrink_stub, &hardshrink_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(softshrink_stub, &softshrink_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(shrink_backward_stub, &shrink_backward_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(leaky_relu_stub, &leaky_relu_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(leaky_relu_backward_stub, &leaky_relu_backward_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(softplus_stub, &softplus_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(softplus_backward_stub, &softplus_backward_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(glu_stub, &glu_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(glu_backward_stub, &glu_backward_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(silu_stub, &silu_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(silu_backward_stub, &silu_backward_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(mish_stub, &mish_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(mish_backward_stub, &mish_backward_kernel);
|
||||
|
||||
} // namespace native
|
||||
|
|
|
|||
|
|
@ -305,9 +305,7 @@ void adapative_avg_pool2d_backward_kernel_impl(
|
|||
|
||||
} // anonymous namespace
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(adaptive_avg_pool2d_kernel, &adaptive_avg_pool2d_kernel_impl);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(adaptive_avg_pool2d_backward_kernel, &adapative_avg_pool2d_backward_kernel_impl);
|
||||
|
||||
}} // at::native
|
||||
|
|
|
|||
|
|
@ -999,95 +999,50 @@ void zeta_kernel(TensorIteratorBase& iter) {
|
|||
|
||||
} // namespace
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(add_stub, &add_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(add_clamp_stub, &add_clamp_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(sub_stub, &sub_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(mul_stub, &mul_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(div_true_stub, &div_true_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(div_trunc_stub, &div_trunc_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(div_floor_stub, &div_floor_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(remainder_stub, &remainder_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(atan2_stub, &atan2_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(bitwise_and_stub, &bitwise_and_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(bitwise_or_stub, &bitwise_or_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(bitwise_xor_stub, &bitwise_xor_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(lshift_stub, &lshift_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(rshift_stub, &rshift_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(logical_xor_stub, &logical_xor_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(logical_and_stub, &logical_and_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(logical_or_stub, &logical_or_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(lt_stub, <_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(le_stub, &le_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(gt_stub, >_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(ge_stub, &ge_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(eq_stub, &eq_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(ne_stub, &ne_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(maximum_stub, &maximum_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(minimum_stub, &minimum_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(fmax_stub, &fmax_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(fmin_stub, &fmin_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(smooth_l1_stub, &smooth_l1_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(huber_stub, &huber_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(sigmoid_backward_stub, &sigmoid_backward_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(logit_backward_stub, &logit_backward_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(tanh_backward_stub, &tanh_backward_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(mse_stub, &mse_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(fmod_stub, &fmod_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(logaddexp_stub, &logaddexp_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(logaddexp2_stub, &logaddexp2_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(gcd_stub, &gcd_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(lcm_stub, &lcm_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(hypot_stub, &hypot_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(igamma_stub, &igamma_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(igammac_stub, &igammac_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(nextafter_stub, &nextafter_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(heaviside_stub, &heaviside_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(copysign_stub, ©sign_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(xlogy_stub, &xlogy_kernel);
|
||||
REGISTER_DISPATCH(xlog1py_stub, &xlog1py_kernel);
|
||||
REGISTER_DISPATCH(zeta_stub, &zeta_kernel);
|
||||
|
|
|
|||
|
|
@ -215,11 +215,8 @@ void cpublas_copy_impl(at::ScalarType type, int64_t n, const void *_x, int64_t i
|
|||
}} // namespace cpublas::(anonymous)
|
||||
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(cpublas::gemm_stub, &cpublas::cpublas_gemm_impl);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(cpublas::axpy_stub, &cpublas::cpublas_axpy_impl);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(cpublas::copy_stub, &cpublas::cpublas_copy_impl);
|
||||
|
||||
}} // namespace at::native
|
||||
|
|
|
|||
|
|
@ -61,7 +61,6 @@ void cat_serial_kernel(Tensor& result, TensorList tensors, int64_t dim) {
|
|||
|
||||
} // anonymous namespace
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(cat_serial_stub, &cat_serial_kernel);
|
||||
|
||||
}} // at::native
|
||||
|
|
|
|||
|
|
@ -25,9 +25,7 @@ void polar_kernel(TensorIterator& iter) {
|
|||
|
||||
} // anonymous namespace
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(complex_stub, &complex_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(polar_stub, &polar_kernel);
|
||||
|
||||
} // namespace native
|
||||
|
|
|
|||
|
|
@ -124,7 +124,6 @@ static void copy_kernel(TensorIterator& iter, bool non_blocking) {
|
|||
|
||||
} // anonymous namespace
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(copy_stub, ©_kernel);
|
||||
|
||||
} // namespace native
|
||||
|
|
|
|||
|
|
@ -72,7 +72,6 @@ static void cross_kernel_impl(Tensor& result, const Tensor& a, const Tensor& b,
|
|||
|
||||
} // anonymous namespace
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(cross_stub, &cross_kernel_impl);
|
||||
|
||||
}} // namespace at::native
|
||||
|
|
|
|||
|
|
@ -302,7 +302,6 @@ Tensor _convolution_depthwise3x3_winograd(
|
|||
|
||||
} // namespace
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(convolution_depthwise3x3_winograd_stub, &_convolution_depthwise3x3_winograd);
|
||||
|
||||
} // namespace native
|
||||
|
|
|
|||
|
|
@ -440,13 +440,9 @@ static void cdist_backward_kernel_impl(Tensor& result, const Tensor& grad, const
|
|||
|
||||
} // anonymous namespace
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(pdist_forward_stub, &pdist_forward_kernel_impl);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(pdist_backward_stub, &pdist_backward_kernel_impl);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(cdist_stub, &cdist_kernel_impl);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(cdist_backward_stub, &cdist_backward_kernel_impl);
|
||||
|
||||
}} // namespace at::native
|
||||
|
|
|
|||
|
|
@ -54,7 +54,6 @@ void fill_kernel(TensorIterator& iter, const Scalar& value_scalar) {
|
|||
|
||||
} // namespace
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(fill_stub, &fill_kernel);
|
||||
|
||||
} // namespace native
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@ void _compute_linear_combination_cpu_kernel(
|
|||
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(_compute_linear_combination_stub, &_compute_linear_combination_cpu_kernel);
|
||||
|
||||
}} // namespace at::native
|
||||
|
|
|
|||
|
|
@ -1267,9 +1267,7 @@ grid_sampler_2d_backward_cpu_kernel_impl(const Tensor& grad_output_,
|
|||
|
||||
}
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(grid_sampler_2d_cpu_kernel, &grid_sampler_2d_cpu_kernel_impl);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(grid_sampler_2d_backward_cpu_kernel, &grid_sampler_2d_backward_cpu_kernel_impl);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -211,10 +211,8 @@ static void histogram_linear_kernel_impl(const Tensor& self, const c10::optional
|
|||
|
||||
} // namespace
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(histogram_stub, &histogram_kernel_impl);
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(histogram_linear_stub, &histogram_linear_kernel_impl);
|
||||
|
||||
}} // namespace at::native
|
||||
|
|
|
|||
|
|
@ -559,27 +559,16 @@ void flip_kernel(TensorIterator& iter, const bool quantized) {
|
|||
|
||||
} // anonymous namespace
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(index_stub, &index_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(index_fill_stub, &index_fill_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(index_copy_stub, &index_copy_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(index_put_stub, &index_put_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(put_stub, &put_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(take_stub, &take_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(masked_fill_stub, &masked_fill_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(masked_select_serial_stub, &masked_select_serial_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(masked_select_stub, &masked_select_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(masked_scatter_stub, &masked_scatter_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(flip_stub, &flip_kernel);
|
||||
|
||||
}} // namespace at::native
|
||||
|
|
|
|||
|
|
@ -56,9 +56,7 @@ static void lerp_kernel_tensor(
|
|||
|
||||
} // anonymous namespace
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(lerp_kernel_scalar_weight, &lerp_kernel_scalar);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(lerp_kernel_tensor_weight, &lerp_kernel_tensor);
|
||||
|
||||
} // namespace native
|
||||
|
|
|
|||
|
|
@ -158,11 +158,8 @@ void unpack_pivots_cpu_kernel(
|
|||
|
||||
} // anonymous namespace
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(addr_stub, &addr_kernel);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(linalg_vector_norm_stub, &linalg_vector_norm_kernel_cpu);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(unpack_pivots_stub, &unpack_pivots_cpu_kernel);
|
||||
|
||||
}} // namespace at::native
|
||||
|
|
|
|||
|
|
@ -354,9 +354,7 @@ void max_pool2d_backward_kernel_impl(
|
|||
|
||||
} // anonymous namespace
|
||||
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(max_pool2d_kernel, &max_pool2d_kernel_impl);
|
||||
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||
REGISTER_DISPATCH(max_pool2d_backward_kernel, &max_pool2d_backward_kernel_impl);
|
||||
|
||||
}} // at::native
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user