| 137 | } |
| 138 | |
| 139 | TEST(test_torch_library, TestLibraryOperators) { |
| 140 | auto qualified_name = "example_library::mymuladd"; |
| 141 | auto* op = torch::OperatorRegistry::instance().find_operator(qualified_name); |
| 142 | ASSERT_NE(op, nullptr); |
| 143 | auto impl_it = op->implementations.find(c10::DispatchKey::CPU); |
| 144 | ASSERT_NE(impl_it, op->implementations.end()); |
| 145 | torch::FunctionArgs function_args; |
| 146 | function_args.add_arg(torch::IValue(at::ones({2, 2}, at::kFloat))); |
| 147 | function_args.add_arg(torch::IValue(at::ones({2, 2}, at::kFloat))); |
| 148 | function_args.add_arg(torch::IValue(2.0)); |
| 149 | auto result = impl_it->second.call_with_args(function_args); |
| 150 | ASSERT_TRUE(result.get_value().is_tensor()); |
| 151 | auto result_tensor = result.get_value().to_tensor(); |
| 152 | } |
| 153 | |
| 154 | TEST(test_torch_library, TestLibraryClasses) { |
| 155 | auto qualified_name = "example_library::TestClass"; |
nothing calls this directly
no test coverage detected