Files
pytorch/torch/csrc/jit/runtime/print_handler.cpp
Oleg Khabinov 5079321b71 Fix issue with prim::Print() and torch::deploy (#74513)
Summary: Pull Request resolved: https://github.com/pytorch/pytorch/pull/74513

Reviewed By: d4l3k, houseroad

Differential Revision: D35035089

fbshipit-source-id: d67b98600c74e2ed16b4d80f52148cd64b9e6ca0
(cherry picked from commit 16caf865077e28be31b805f015b9a61962632c8f)
2022-03-25 03:14:34 +00:00

29 lines
497 B
C++

#include <torch/csrc/jit/runtime/print_handler.h>
#include <iostream>
#include <string>
namespace torch {
namespace jit {
namespace {
std::atomic<PrintHandler> print_handler(getDefaultPrintHandler());
} // namespace
PrintHandler getDefaultPrintHandler() {
return [](const std::string& s) { std::cout << s; };
}
PrintHandler getPrintHandler() {
return print_handler.load();
}
void setPrintHandler(PrintHandler ph) {
print_handler.store(ph);
}
} // namespace jit
} // namespace torch