Files
pytorch/test/cpp_extensions/jit_extension.cpp
Peter Goldsborough 67d0d14908 Rename autograd namespace to torch and change torch.h into python.h (#7267)
* Rename autograd namespace to torch and change torch.h into python.h

* Include torch.h instead of python.h in test/cpp/api

* Change some mentions of torch.h to python.h in C++ extensions

* Set paths directly, without find_path
2018-05-04 08:04:57 -07:00

21 lines
457 B
C++

#include <torch/python.h>
#include "doubler.h"
using namespace at;
Tensor exp_add(Tensor x, Tensor y);
Tensor tanh_add(Tensor x, Tensor y) {
return x.tanh() + y.tanh();
}
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
m.def("tanh_add", &tanh_add, "tanh(x) + tanh(y)");
m.def("exp_add", &exp_add, "exp(x) + exp(y)");
py::class_<Doubler>(m, "Doubler")
.def(py::init<int, int>())
.def("forward", &Doubler::forward)
.def("get", &Doubler::get);
}