Files
mscclpp/python/utils_py.cpp
Saeed Maleki e7d5e652df 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>
2023-07-19 15:35:54 +08:00

24 lines
702 B
C++

// 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"));
}