1 #include "smart_tensor_printer.h" 3 #include "caffe2/core/operator.h" 14 bool DoRunWithType() {
15 tensorPrinter->Print<
T>(*tensor);
22 DispatchHelper<TensorTypes<
33 char>>::call(
this, tensor->dtype());
37 TensorPrinter* tensorPrinter;
41 SmartTensorPrinter::SmartTensorPrinter(
const std::string& tensor_name)
42 : tensorPrinter_(tensor_name) {}
44 SmartTensorPrinter::SmartTensorPrinter(
45 const std::string& tensor_name,
46 const std::string& file_name)
47 : tensorPrinter_(tensor_name, file_name) {}
49 SmartTensorPrinter::SmartTensorPrinter(
50 const std::string& tensor_name,
51 const std::string& file_name,
53 : tensorPrinter_(tensor_name, file_name, limit) {}
55 void SmartTensorPrinter::Print(
const Tensor& tensor) {
58 printer.tensor = &tensor;
59 printer.tensorPrinter = &tensorPrinter_;
63 SmartTensorPrinter& SmartTensorPrinter::DefaultTensorPrinter() {
67 "SmartTensorPrinter does not work on mac yet due to thread_local.");
69 static thread_local SmartTensorPrinter printer;
74 void SmartTensorPrinter::PrintTensor(
const Tensor& tensor) {
75 DefaultTensorPrinter().Print(tensor);
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...