mirror of
https://github.com/NVIDIA/nvbench.git
synced 2026-05-13 17:55:39 +00:00
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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user