mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Add optional support to C++ extensions (#7055)
This commit is contained in:
committed by
GitHub
parent
7b09bc72a5
commit
2e023a29e4
@ -20,8 +20,16 @@ struct MatrixMultiplier {
|
||||
at::Tensor tensor_;
|
||||
};
|
||||
|
||||
bool function_taking_optional(at::optional<at::Tensor> tensor) {
|
||||
return tensor.has_value();
|
||||
}
|
||||
|
||||
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
|
||||
m.def("sigmoid_add", &sigmoid_add, "sigmoid(x) + sigmoid(y)");
|
||||
m.def(
|
||||
"function_taking_optional",
|
||||
&function_taking_optional,
|
||||
"function_taking_optional");
|
||||
py::class_<MatrixMultiplier>(m, "MatrixMultiplier")
|
||||
.def(py::init<int, int>())
|
||||
.def("forward", &MatrixMultiplier::forward)
|
||||
|
Reference in New Issue
Block a user