MCPcopy Create free account
hub / github.com/Samsung/ONE / write

Function write

compiler/fme-detect/src/EqualizePatternWrite.cpp:59–82  ·  view source on GitHub ↗

Write the below information into a json file ('filename') [ { "front": String (tensor name) "back": String (tensor name) "type": String (ScaleOnly/ShiftOnly/ScaleShift) }, ... ]

Source from the content-addressed store, hash-verified

57// ...
58// ]
59void write(const std::vector<EqualizePattern> &patterns, const std::string &filename)
60{
61 Json::Value root(Json::arrayValue);
62
63 for (auto &pattern : patterns)
64 {
65 Json::Value p;
66 p["front"] = pattern.front;
67 p["back"] = pattern.back;
68 p["type"] = to_string(pattern.type);
69 root.append(p);
70 }
71
72 Json::StreamWriterBuilder builder;
73 builder["commentStyle"] = "None";
74 builder["indentation"] = " ";
75
76 std::unique_ptr<Json::StreamWriter> writer(builder.newStreamWriter());
77 std::ofstream out(filename);
78 if (out.fail())
79 throw std::runtime_error("Cannot open file \"" + filename + "\".\n");
80
81 writer->write(root, &out);
82}
83
84} // namespace fme_detect

Callers 3

TEST_FFunction · 0.85
entryFunction · 0.85
writeHeaderMethod · 0.85

Calls 5

newStreamWriterMethod · 0.80
to_stringFunction · 0.70
appendMethod · 0.45
failMethod · 0.45
writeMethod · 0.45

Tested by 1

TEST_FFunction · 0.68