mirror of
https://github.com/microsoft/mscclpp.git
synced 2026-05-12 09:17:06 +00:00
Python bindings (#125)
Co-authored-by: Olli Saarikivi <olsaarik@microsoft.com> Co-authored-by: Changho Hwang <changhohwang@microsoft.com> Co-authored-by: Binyang Li <binyli@microsoft.com>
This commit is contained in:
23
python/utils_py.cpp
Normal file
23
python/utils_py.cpp
Normal file
@@ -0,0 +1,23 @@
|
||||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT license.
|
||||
|
||||
#include <nanobind/nanobind.h>
|
||||
#include <nanobind/stl/string.h>
|
||||
|
||||
#include <mscclpp/utils.hpp>
|
||||
|
||||
namespace nb = nanobind;
|
||||
using namespace mscclpp;
|
||||
|
||||
void register_utils(nb::module_& m) {
|
||||
nb::class_<Timer>(m, "Timer")
|
||||
.def(nb::init<int>(), nb::arg("timeout") = -1)
|
||||
.def("elapsed", &Timer::elapsed)
|
||||
.def("set", &Timer::set, nb::arg("timeout"))
|
||||
.def("reset", &Timer::reset)
|
||||
.def("print", &Timer::print, nb::arg("name"));
|
||||
|
||||
nb::class_<ScopedTimer, Timer>(m, "ScopedTimer").def(nb::init<std::string>(), nb::arg("name"));
|
||||
|
||||
m.def("get_host_name", &getHostName, nb::arg("maxlen"), nb::arg("delim"));
|
||||
}
|
||||
Reference in New Issue
Block a user