-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
39f48f2
commit 0cbb079
Showing
5 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include "module.h" | ||
#include <sstream> | ||
#include <ctranslate2/profiler.h> | ||
|
||
namespace ctranslate2 { | ||
namespace python { | ||
|
||
void register_profiling(py::module& m) { | ||
|
||
m.def("init_profiling", &ctranslate2::init_profiling); | ||
m.def("dump_profiling", []() { | ||
std::ostringstream oss; | ||
ctranslate2::dump_profiling(oss); | ||
return oss.str(); | ||
}); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from ctranslate2 import _ext, Device | ||
import sys | ||
|
||
def init_profiler(device = Device.cpu, num_threads = 1): | ||
_ext.init_profiling(device, num_threads) | ||
|
||
|
||
def dump_profiler(): | ||
profiling_data = _ext.dump_profiling() | ||
sys.stdout.write(profiling_data) |