Defined in File serializer.h
Struct GraphLoader::LoadResult
mgb::serialization::
::
GraphLoader
load graph from megbrain dump file
Each GraphLoader instance can create multiple graphs, but all the created graphs share underlying params (i.e. values for SharedDeviceTensor are shared)
Public Types
LoadConfig
SharedTensorMapEntry
mem_node => tensor_value
SharedTensorIDMap
tensor_id => (tensor_name, (mem_node => tensor_value))
Since tensor IDs are guaranteed to be consecutive, a vector is used to implement the map.
Either all tensor names are empty, or they are guaranteed to be distinct non-empty strings at dump time.
SharedTensorNameMap
tensor_name => SharedTensorMapEntry
Public Functions
~GraphLoader
reset_file
reset underlying input file from which further load() would read
This method can be used to release the currently owned file to the caller.
original input file that is currently used
file: new input file, can be null
file
load
create a new graph instance; not thread safe
rewind: whether to call InputFile::rewind before loading
rewind
shared_tensor_id_map
get mapping from tensor ID to device tensor shared between instances
The shared tensors are usually used as model params in a machine learning context. For each param name, the returned value has a map from a memory node to the first param loaded on that mem node
shared_tensor_name_map
helper for constructing SharedTensorNameMap from SharedTensorIDMap
format
Public Static Functions
make
identify_graph_dump_format
LoadResult
TensorMap
~LoadResult
expliit dtor decl to reduce binary size
graph_compile
call graph->compile() but also checks for comp seq rec
graph would be destructed if comp_node_seq_record_level == 2; this method should be called in favor of graph->compile().
Public Members
graph
tensor_map
name to host tensor used in this graph, usually for input tensors
output_var_map
name to output var nodes specified during serializing
output_var_map_id
map from original id to loaded output vars
output_var_list
original output vars in the order passed to GraphDumper::dump