From: Sebastian Messmer Date: Thu, 18 Apr 2019 09:00:51 +0000 (-0700) Subject: Add some tests (#19288) X-Git-Tag: accepted/tizen/6.5/unified/20211028.231830~167 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fa96de2b3f556a2aa7f6a13dad8155d599e74338;p=platform%2Fupstream%2Fpytorch.git Add some tests (#19288) Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/19288 - Reviewed By: dzhulgakov Differential Revision: D14931924 fbshipit-source-id: 6c53b5d1679080939973d33868e58ca4ad70361d --- diff --git a/aten/src/ATen/core/op_registration/op_registration_test.cpp b/aten/src/ATen/core/op_registration/op_registration_test.cpp index 7a7016f..4f46b30 100644 --- a/aten/src/ATen/core/op_registration/op_registration_test.cpp +++ b/aten/src/ATen/core/op_registration/op_registration_test.cpp @@ -207,4 +207,16 @@ TEST(OperatorRegistrationTest, givenOpWithoutKernelsWithoutTensorInputs_whenRegi ASSERT_TRUE(op.has_value()); // assert schema is registered } +TEST(OperatorRegistrationTest, givenOpWithMultipleKernels_whenKernelsHaveSameDispatchKey_thenFails) { + auto registrar = c10::RegisterOperators() + .op("_test::dummy(Tensor dummy) -> ()", kernel(), dispatchKey(TensorType1())); + + auto op = Dispatcher::singleton().findSchema("_test::dummy", ""); + ASSERT_TRUE(op.has_value()); // assert schema is registered + + expectThrows([&] { + c10::RegisterOperators().op("_test::dummy(Tensor dummy) -> ()", kernel(), dispatchKey(TensorType1())); + }, "Tried to register multiple kernels with same dispatch key"); +} + }