/** * Copyright (c) 2023 by Contributors * Copyright (c) 2023, GT-TDAlab (Muhammed Fatih Balin & Umit V. Catalyurek) * @file cuda/isin.cu * @brief IsIn operator implementation on CUDA. */ #include #include #include "./common.h" namespace graphbolt { namespace ops { torch::Tensor IsIn(torch::Tensor elements, torch::Tensor test_elements) { auto sorted_test_elements = Sort(test_elements); auto result = torch::empty_like(elements, torch::kBool); AT_DISPATCH_INTEGRAL_TYPES( elements.scalar_type(), "IsInOperation", ([&] { THRUST_CALL( binary_search, sorted_test_elements.data_ptr(), sorted_test_elements.data_ptr() + sorted_test_elements.size(0), elements.data_ptr(), elements.data_ptr() + elements.size(0), result.data_ptr()); })); return result; } } // namespace ops } // namespace graphbolt