Skip to content

None Default Arguments #5

@rusty1s

Description

@rusty1s

Hello and thanks for this great repository!

Can you give me a hint on how to implement default arguments? I tried the following so far but it does not work:

at::Tensor torch_func(at::Tensor tensor1, at::Tensor tensor2={}) {
  ...
}

PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
  m.def("torch_func", &torch_func, py::arg("tensor1"), py::arg("tensor2")={});
}
torch_func(tensor1, None)

I would be very grateful for help.

  • OS: macOS
  • PyTorch version: 0.4.0
  • How you installed PyTorch (conda, pip, source): source
  • Python version: 3.6
  • CUDA/cuDNN version: -
  • GPU models and configuration: -
  • GCC version (if compiling from source): 4.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions