1 #include "caffe2/onnx/helper.h" 3 #include "caffe2/core/logging.h" 4 #include "caffe2/core/operator.h" 8 std::string DummyName::NewDummyName() {
10 const std::string name = c10::str(
"OC2_DUMMY_", counter_++);
11 auto ret = used_names_.insert(name);
18 void DummyName::Reset(
const std::unordered_set<std::string> &used_names) {
19 used_names_ = used_names;
23 ::ONNX_NAMESPACE::TypeProto ExtraTypeProto(
24 const ::ONNX_NAMESPACE::TensorProto& tensor) {
25 ::ONNX_NAMESPACE::TypeProto t;
26 auto* tensor_type = t.mutable_tensor_type();
27 tensor_type->set_elem_type(tensor.data_type());
28 auto* shape = tensor_type->mutable_shape();
29 for (
const auto d : tensor.dims()) {
30 shape->add_dim()->set_dim_value(d);
36 const std::string& type,
37 const std::vector<std::string>& inputs,
38 const std::vector<std::string>& outputs,
39 const std::vector<AttributeProto>& attributes,
40 const std::string& name) {
45 node.set_op_type(type);
46 for (
const auto& input: inputs) {
47 node.add_input(input);
49 for (
const auto& output: outputs) {
50 node.add_output(output);
52 for (
const auto& attr: attributes) {
53 node.add_attribute()->CopyFrom(attr);
A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...