MCPcopy Create free account
hub / github.com/OpenNMT/CTranslate2 / register_translation_stats

Function register_translation_stats

python/cpp/execution_stats.cc:8–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6 namespace python {
7
8 void register_translation_stats(py::module& m) {
9 py::class_<ExecutionStats>(m, "ExecutionStats",
10 "A structure containing some execution statistics.")
11
12 .def_readonly("num_tokens", &ExecutionStats::num_tokens,
13 "Number of output tokens.")
14 .def_readonly("num_examples", &ExecutionStats::num_examples,
15 "Number of processed examples.")
16 .def_readonly("total_time_in_ms", &ExecutionStats::total_time_in_ms,
17 "Total processing time in milliseconds.")
18
19 .def("__repr__", [](const ExecutionStats& stats) {
20 return "ExecutionStats(num_tokens=" + std::string(py::repr(py::cast(stats.num_tokens)))
21 + ", num_examples=" + std::string(py::repr(py::cast(stats.num_examples)))
22 + ", total_time_in_ms=" + std::string(py::repr(py::cast(stats.total_time_in_ms)))
23 + ")";
24 })
25 ;
26 }
27
28 }
29}

Callers 1

PYBIND11_MODULEFunction · 0.85

Calls 1

stringFunction · 0.85

Tested by

no test coverage detected