Save parameter dictionary to binary bytes. The result binary bytes can be loaded by the GraphModule with API "load_params". Parameters ---------- params : dict of str to Tensor The parameter dictionary. Returns ------- param_bytes: bytearray Seriali
(params)
| 33 | |
| 34 | |
| 35 | def save_param_dict(params): |
| 36 | """Save parameter dictionary to binary bytes. |
| 37 | |
| 38 | The result binary bytes can be loaded by the |
| 39 | GraphModule with API "load_params". |
| 40 | |
| 41 | Parameters |
| 42 | ---------- |
| 43 | params : dict of str to Tensor |
| 44 | The parameter dictionary. |
| 45 | |
| 46 | Returns |
| 47 | ------- |
| 48 | param_bytes: bytearray |
| 49 | Serialized parameters. |
| 50 | |
| 51 | Examples |
| 52 | -------- |
| 53 | .. code-block:: python |
| 54 | |
| 55 | # set up the parameter dict |
| 56 | params = {"param0": arr0, "param1": arr1} |
| 57 | # save the parameters as byte array |
| 58 | param_bytes = tvm.runtime.save_param_dict(params) |
| 59 | # We can serialize the param_bytes and load it back later. |
| 60 | # Pass in byte array to module to directly set parameters |
| 61 | tvm.runtime.load_param_dict(param_bytes) |
| 62 | """ |
| 63 | return _ffi_api.SaveParams(_to_tensor(params)) |
| 64 | |
| 65 | |
| 66 | def save_param_dict_to_file(params, path): |
no test coverage detected
searching dependent graphs…