mindspore.load
- mindspore.load(file_name, **kwargs)[source]
Load MindIR.
The returned object can be executed by a GraphCell, see class
mindspore.nn.GraphCell
for more details.- Parameters
file_name (str) – MindIR file name.
kwargs (dict) –
Configuration options dictionary.
dec_key (bytes): Byte type key used for decryption. The valid length is 16, 24, or 32.
dec_mode (str): Specifies the decryption mode, to take effect when dec_key is set. Option: ‘AES-GCM’ | ‘AES-CBC’. Default: ‘AES-GCM’.
- Returns
Object, a compiled graph that can executed by GraphCell.
- Raises
ValueError – MindIR file name is incorrect.
RuntimeError – Failed to parse MindIR file.
Examples
>>> import numpy as np >>> import mindspore.nn as nn >>> from mindspore import Tensor, export, load >>> >>> net = nn.Conv2d(1, 1, kernel_size=3, weight_init="ones") >>> input_tensor = Tensor(np.ones([1, 1, 3, 3]).astype(np.float32)) >>> export(net, input_tensor, file_name="net", file_format="MINDIR") >>> graph = load("net.mindir") >>> net = nn.GraphCell(graph) >>> output = net(input_tensor) >>> print(output) [[[[4. 6. 4.] [6. 9. 6.] [4. 6. 4.]]]]