Caffe2 - C++ API
A deep learning, cross platform ML framework
smart_tensor_printer.h
1 #pragma once
2 
3 #include "caffe2/core/tensor.h"
4 
5 namespace caffe2 {
6 
7 // This is a wrapper around the TensorPrinter that doesn't require the user to
8 // explicit specify the type of the tensor while calling the Print() method.
9 // It also supports a convenience function with a default constructed printer as
10 // a static method.
11 class CAFFE2_API SmartTensorPrinter {
12  public:
13  // The proliferation of constructors is to give the feature parity with
14  // TensorPrinter
15  // yet not repeat the default arguments explicitly in case they change in the
16  // future.
17  SmartTensorPrinter() = default;
18 
19  explicit SmartTensorPrinter(const std::string& tensor_name);
20 
22  const std::string& tensor_name,
23  const std::string& file_name);
24 
26  const std::string& tensor_name,
27  const std::string& file_name,
28  int limit);
29 
30  void Print(const Tensor& tensor);
31 
32  void PrintMeta(const Tensor& tensor) {
33  tensorPrinter_.PrintMeta(tensor);
34  }
35 
36  // Uses a default constructed SmartTensorPrinter
37  static void PrintTensor(const Tensor& tensor);
38 
39  // Uses a default constructed SmartTensorPrinter
40  void PrintTensorMeta(const Tensor& tensor) {
41  DefaultTensorPrinter().PrintMeta(tensor);
42  }
43 
44  private:
45  // Returns a thread local default constructed TensorPrinter
46  static SmartTensorPrinter& DefaultTensorPrinter();
47 
48  TensorPrinter tensorPrinter_;
49 };
50 }
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
Definition: blob.h:13