MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / to_json

Method to_json

src/core/impl/graph/var_node.cpp:153–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

151
152#if MGB_ENABLE_JSON
153std::shared_ptr<json::Value> MemAllocPlan::to_json() const {
154 auto cvt_layout = [](const TensorLayout& layout) {
155 auto shape = json::Array::make(), stride = json::Array::make();
156 for (size_t i = 0; i < layout.ndim; i++) {
157 shape->add(json::Number::make(layout.shape[i]));
158 stride->add(json::Number::make(layout.stride[i]));
159 }
160 return json::Object::make(
161 {{"shape", shape},
162 {"stride", stride},
163 {"dtype", json::String::make(layout.dtype.name())}});
164 };
165
166 return json::Object::make(
167 {{"mem_chunk_id", json::String::make(m_chunk->id_str())},
168 {"layout", cvt_layout(m_layout)},
169 {"offset_byte", json::Number::make(m_offset_byte)}});
170}
171#endif
172
173std::string MemAllocPlan::Chunk::id_str() const {

Callers 4

do_trainMethod · 0.45
TESTFunction · 0.45
TESTFunction · 0.45
TESTFunction · 0.45

Calls 13

comp_nodeFunction · 0.85
dev_tensor_validMethod · 0.80
spanMethod · 0.80
makeFunction · 0.70
nameFunction · 0.50
addMethod · 0.45
nameMethod · 0.45
id_strMethod · 0.45
raw_ptrMethod · 0.45
dev_tensorMethod · 0.45
validMethod · 0.45
to_stringMethod · 0.45

Tested by 4

do_trainMethod · 0.36
TESTFunction · 0.36
TESTFunction · 0.36
TESTFunction · 0.36