1 #include <torch/script.h> 9 std::vector<torch::Tensor> custom_op(
13 std::vector<torch::Tensor> output;
14 output.reserve(repeat);
15 for (int64_t i = 0; i < repeat; ++i) {
16 output.push_back(tensor * scalar);
21 int64_t custom_op2(std::string s1, std::string s2) {
22 return s1.compare(s2);
25 static auto registry =
28 .
op(
"custom::op", &custom_op)
29 .
op(
"custom::op2", &custom_op2)
33 .
op(
"custom::op_with_defaults(Tensor tensor, float scalar = 1, int repeat = 1) -> Tensor[]",
RegisterOperators & op(const std::string &name, Implementation &&implementation)
Creates a new operator from a name and implementation function (function pointer or function object/l...
Registration class for new operators.