Struct GraphDumpConfig

Struct Documentation

struct mgb::serialization::GraphDumpConfig

config for dumping a whole graph; setup in GraphDumper

Public Types

using TensorValueDumper = thin_function<void(OutputFile &fout, const cg::OperatorNodeBase &opr, const HostTensorND &tensor)>

write tensor value (excluding metainfo like layout or dtype) to output file

  • opr: the operator that requests to dump this tensor

  • tensor: tensor to be dumped; layout guaranteed to be contiguous

Public Functions

GraphDumpConfig(int keep_var_name_ = 1, bool keep_param_name_ = false, bool keep_opr_priority_ = false, const std::shared_ptr<UserDataContainer> &user_data_ = std::make_shared<UserDataContainer>(), const TensorValueDumper &tensor_value_dumper_ = {})

Public Members

int keep_var_name

specify the vars whose names should be kept: 0 for none; 1 for output vars; 2 for all vars (internal + output vars)

bool keep_param_name

whether to keep param names

bool keep_opr_priority

whether to keep operator priorities

std::shared_ptr<UserDataContainer> user_data

extra user data to be passed by dump caller into opr dump implementations; useful for implementing nested opr dump

TensorValueDumper tensor_value_dumper

intercept how a single tensor is dumped; it should only dump the tensor value without layout; useful for compression or encryption

std::vector<std::pair<std::string, SymbolVar>> alias_name_map

a list of output nodes and names. one output node may have multiple names. this list record the mapping between output node and it’s name

Public Static Functions

void default_tensor_value_dumper(OutputFile &fout, const cg::OperatorNodeBase &opr, const HostTensorND &tensor)

a fallback to implement custom tensor value dumper; it just writes the raw tensor value to output file. Implemented in serializer.cpp