Fixed correctness of nvbench.State.getStream() method

Fix run-time exception:

```
Fail: Unexpected error: RuntimeError: return_value_policy = copy, but type is non-copyable! (#define PYBIND11_DETAILED_ERROR_MESSAGES or compile in debug mode for details)
```

caused by attempt to returning move-only `nvbench::cuda_stream` class
instance using default `pybind11::return_value_policy::copy`.
This commit is contained in:
Oleksandr Pavlyk
2025-07-01 14:53:54 -05:00
parent e768ce28b6
commit 6f8bcdc774

View File

@@ -345,7 +345,10 @@ PYBIND11_MODULE(_nvbench, m)
return state.get_benchmark().get_printer().has_value();
});
pystate_cls.def("getStream", &nvbench::state::get_cuda_stream);
pystate_cls.def(
"getStream",
[](nvbench::state &state) { return std::ref(state.get_cuda_stream()); },
py::return_value_policy::reference);
pystate_cls.def("getInt64", &nvbench::state::get_int64);
pystate_cls.def("getInt64", &nvbench::state::get_int64_or_default);