3 #include "caffe2/core/logging.h" 4 #include "caffe2/opt/shape_info.h" 5 #include "caffe2/proto/caffe2_pb.h" 9 #include <unordered_map> 10 #include <unordered_set> 18 : max_batch_size(b), max_seq_size(q) {}
19 int64_t max_batch_size;
33 CAFFE_ENFORCE_GE(spec_.max_batch_size, 0);
34 CAFFE_ENFORCE_GE(spec_.max_seq_size, 0);
37 void InferBoundShapeAndType(
39 const std::unordered_map<std::string, ShapeInfo>& info);
41 const ShapeInfoMap& shape_info()
const {
48 for (
const auto& kv : shape_info_) {
49 const auto& s = kv.second;
50 ss << s.shape.name() <<
": dim_type: " << s.dim_type <<
", dims: [";
51 for (
const auto d : s.shape.dims()) {
54 ss <<
"], dtype: " << s.shape.data_type() <<
"\n";
60 TensorShape& CheckAndSetTensorShapeAndType(
61 const std::string& name,
63 std::vector<int64_t> bound_dims,
64 TensorProto::DataType type);
66 void InferGivenTensorFill(
const OperatorDef& op);
67 void InferSparseLengthsSum(
const OperatorDef& op);
68 void InferFC(
const OperatorDef& op);
69 void InferConcat(
const OperatorDef& op);
70 void InferShape(
const OperatorDef& op);
71 void InferReshape(
const OperatorDef& op);
72 void InferLengthsRangeFill(
const OperatorDef& op);
76 void InferCommonOp(
const OperatorDef& op);
79 ShapeInfo::DimType current_dim_type_{ShapeInfo::DimType::BATCH};
80 int64_t current_max_batch_size_{0};
81 std::unordered_map<std::string, ShapeInfo> shape_info_;
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...
std::string PrintShapeInfo() const
Print out all the shape info.