mirror of
https://github.com/saymrwulf/pytorch.git
synced 2026-05-14 20:57:59 +00:00
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/25440 See the comments deleted for what this PR is all about Test Plan: Imported from OSS Differential Revision: D17125690 Pulled By: suo fbshipit-source-id: a4a2f541a3e161f9c15b51df475130e7bf683cf8
31 lines
773 B
C++
31 lines
773 B
C++
#include <torch/csrc/jit/hooks_for_testing.h>
|
|
#include <torch/csrc/jit/script/module.h>
|
|
|
|
namespace torch {
|
|
namespace jit {
|
|
|
|
static ModuleHook emit_module_callback;
|
|
void didFinishEmitModule(script::Module module) {
|
|
if (emit_module_callback) {
|
|
emit_module_callback(module);
|
|
}
|
|
}
|
|
|
|
static FunctionHook emit_function_callback;
|
|
void didFinishEmitFunction(StrongFunctionPtr fn) {
|
|
if (emit_function_callback) {
|
|
emit_function_callback(fn);
|
|
}
|
|
}
|
|
|
|
void setEmitHooks(ModuleHook for_mod, FunctionHook for_fn) {
|
|
emit_module_callback = std::move(for_mod);
|
|
emit_function_callback = std::move(for_fn);
|
|
}
|
|
|
|
std::pair<ModuleHook, FunctionHook> getEmitHooks() {
|
|
return std::make_pair(emit_module_callback, emit_function_callback);
|
|
}
|
|
|
|
} // namespace jit
|
|
} // namespace torch
|