forked from mindspore-Ecosystem/mindspore
mindir_suffix
This commit is contained in:
parent
51d885815a
commit
c46c4dffe4
|
@ -26,7 +26,7 @@ context.set_context(mode=context.GRAPH_MODE, device_target="Ascend")
|
|||
|
||||
parser = argparse.ArgumentParser(description='CNNCTC_export')
|
||||
parser.add_argument('--ckpt_file', type=str, default='./ckpts/cnn_ctc.ckpt', help='CNN&CTC ckpt file.')
|
||||
parser.add_argument('--output_file', type=str, default='cnn_ctc.air', help='CNN&CTC output air name.')
|
||||
parser.add_argument('--output_file', type=str, default='cnn_ctc', help='CNN&CTC output air name.')
|
||||
args_opt = parser.parse_args()
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
|
@ -39,4 +39,4 @@ if __name__ == '__main__':
|
|||
# load the parameter into net
|
||||
load_param_into_net(network, param_dict)
|
||||
input_data = np.random.uniform(0.0, 1.0, size=[32, 3, 513, 513]).astype(np.float32)
|
||||
export(network, Tensor(input_data), file_name=args.model+'-300_11.air', file_format='AIR')
|
||||
export(network, Tensor(input_data), file_name=args.model+'-300_11', file_format='AIR')
|
||||
|
|
|
@ -33,8 +33,8 @@ cifar_cfg = edict({
|
|||
'device_id': 0,
|
||||
'keep_checkpoint_max': 10,
|
||||
'checkpoint_path': './train_googlenet_cifar10-125_390.ckpt',
|
||||
'onnx_filename': 'googlenet.onnx',
|
||||
'air_filename': 'googlenet.air'
|
||||
'onnx_filename': 'googlenet',
|
||||
'air_filename': 'googlenet'
|
||||
})
|
||||
|
||||
imagenet_cfg = edict({
|
||||
|
@ -54,8 +54,8 @@ imagenet_cfg = edict({
|
|||
'device_id': 0,
|
||||
'keep_checkpoint_max': 10,
|
||||
'checkpoint_path': None,
|
||||
'onnx_filename': 'googlenet.onnx',
|
||||
'air_filename': 'googlenet.air',
|
||||
'onnx_filename': 'googlenet',
|
||||
'air_filename': 'googlenet',
|
||||
|
||||
# optimizer and lr related
|
||||
'lr_scheduler': 'exponential',
|
||||
|
|
|
@ -26,7 +26,7 @@ from src.inception_v3 import InceptionV3
|
|||
|
||||
parser = argparse.ArgumentParser(description='inceptionv3 export')
|
||||
parser.add_argument('--ckpt_file', type=str, required=True, help='inceptionv3 ckpt file.')
|
||||
parser.add_argument('--output_file', type=str, default='inceptionv3.air', help='inceptionv3 output air name.')
|
||||
parser.add_argument('--output_file', type=str, default='inceptionv3', help='inceptionv3 output air name.')
|
||||
parser.add_argument('--file_format', type=str, choices=["AIR", "ONNX", "MINDIR"], default='AIR', help='file format')
|
||||
parser.add_argument('--width', type=int, default=299, help='input width')
|
||||
parser.add_argument('--height', type=int, default=299, help='input height')
|
||||
|
|
|
@ -29,5 +29,5 @@ mnist_cfg = edict({
|
|||
'image_width': 32,
|
||||
'save_checkpoint_steps': 1875,
|
||||
'keep_checkpoint_max': 10,
|
||||
'air_name': "lenet.air",
|
||||
'air_name': "lenet",
|
||||
})
|
||||
|
|
|
@ -54,4 +54,4 @@ if __name__ == "__main__":
|
|||
|
||||
# export network
|
||||
inputs = Tensor(np.ones([1, 1, cfg.image_height, cfg.image_width]), mindspore.float32)
|
||||
export(network, inputs, file_name="lenet_quant.mindir", file_format='MINDIR', quant_mode='AUTO')
|
||||
export(network, inputs, file_name="lenet_quant", file_format='MINDIR', quant_mode='AUTO')
|
||||
|
|
|
@ -42,7 +42,7 @@ def set_config(args):
|
|||
"platform": args.platform,
|
||||
"activation": "Softmax",
|
||||
"export_format": "MINDIR",
|
||||
"export_file": "mobilenetv2.mindir"
|
||||
"export_file": "mobilenetv2"
|
||||
})
|
||||
config_gpu = ed({
|
||||
"num_classes": 1000,
|
||||
|
@ -66,7 +66,7 @@ def set_config(args):
|
|||
"run_distribute": args.run_distribute,
|
||||
"activation": "Softmax",
|
||||
"export_format": "MINDIR",
|
||||
"export_file": "mobilenetv2.mindir"
|
||||
"export_file": "mobilenetv2"
|
||||
})
|
||||
config_ascend = ed({
|
||||
"num_classes": 1000,
|
||||
|
@ -93,7 +93,7 @@ def set_config(args):
|
|||
"run_distribute": int(os.getenv('RANK_SIZE', '1')) > 1.,
|
||||
"activation": "Softmax",
|
||||
"export_format": "MINDIR",
|
||||
"export_file": "mobilenetv2.mindir"
|
||||
"export_file": "mobilenetv2"
|
||||
})
|
||||
config = ed({"CPU": config_cpu,
|
||||
"GPU": config_gpu,
|
||||
|
|
|
@ -51,5 +51,5 @@ if __name__ == '__main__':
|
|||
# export network
|
||||
print("============== Starting export ==============")
|
||||
inputs = Tensor(np.ones([1, 3, cfg.image_height, cfg.image_width]), mindspore.float32)
|
||||
export(network, inputs, file_name="mobilenet_quant.mindir", file_format='MINDIR', quant_mode='AUTO')
|
||||
export(network, inputs, file_name="mobilenet_quant", file_format='MINDIR', quant_mode='AUTO')
|
||||
print("============== End export ==============")
|
||||
|
|
|
@ -34,5 +34,5 @@ config_gpu = ed({
|
|||
"keep_checkpoint_max": 500,
|
||||
"save_checkpoint_path": "./checkpoint",
|
||||
"export_format": "MINDIR",
|
||||
"export_file": "mobilenetv3.mindir"
|
||||
"export_file": "mobilenetv3"
|
||||
})
|
||||
|
|
|
@ -51,6 +51,6 @@ nasnet_a_mobile_config_gpu = edict({
|
|||
"loss_scale": 1,
|
||||
|
||||
### onnx&air Config
|
||||
'onnx_filename': 'nasnet_a_mobile.onnx',
|
||||
'air_filename': 'nasnet_a_mobile.air'
|
||||
'onnx_filename': 'nasnet_a_mobile',
|
||||
'air_filename': 'nasnet_a_mobile'
|
||||
})
|
||||
|
|
|
@ -41,4 +41,4 @@ if __name__ == '__main__':
|
|||
load_param_into_net(net, param_dict)
|
||||
|
||||
inputs = np.random.uniform(0.0, 1.0, size=[1, 3, 224, 224]).astype(np.float32)
|
||||
export(net, Tensor(inputs), file_name='resnet-42_5004.air', file_format='AIR')
|
||||
export(net, Tensor(inputs), file_name='resnet-42_5004', file_format='AIR')
|
||||
|
|
|
@ -44,5 +44,5 @@ config = ed({
|
|||
"rank": 0,
|
||||
"group_size": 1,
|
||||
"export_format": "MINDIR",
|
||||
"export_file": "resnext50.mindir"
|
||||
"export_file": "resnext50"
|
||||
})
|
||||
|
|
|
@ -39,8 +39,8 @@ if __name__ == '__main__':
|
|||
else:
|
||||
num_classes = 1000
|
||||
|
||||
onnx_filename = args_opt.net + '_' + args_opt.dataset + '.onnx'
|
||||
air_filename = args_opt.net + '_' + args_opt.dataset + '.air'
|
||||
onnx_filename = args_opt.net + '_' + args_opt.dataset
|
||||
air_filename = args_opt.net + '_' + args_opt.dataset
|
||||
|
||||
net = squeezenet(num_classes=num_classes)
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ parser = argparse.ArgumentParser(description='SSD export')
|
|||
parser.add_argument("--device_id", type=int, default=0, help="Device id")
|
||||
parser.add_argument("--batch_size", type=int, default=1, help="batch size")
|
||||
parser.add_argument("--ckpt_file", type=str, required=True, help="Checkpoint file path.")
|
||||
parser.add_argument("--file_name", type=str, default="ssd.air", help="output file name.")
|
||||
parser.add_argument("--file_name", type=str, default="ssd", help="output file name.")
|
||||
parser.add_argument('--file_format', type=str, choices=["AIR", "ONNX", "MINDIR"], default='AIR', help='file format')
|
||||
args = parser.parse_args()
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ from src.unet.unet_model import UNet
|
|||
parser = argparse.ArgumentParser(description='Export ckpt to air')
|
||||
parser.add_argument('--ckpt_file', type=str, default="ckpt_unet_medical_adam-1_600.ckpt",
|
||||
help='The path of input ckpt file')
|
||||
parser.add_argument('--air_file', type=str, default="unet_medical_adam-1_600.air", help='The path of output air file')
|
||||
parser.add_argument('--air_file', type=str, default="unet_medical_adam-1_600", help='The path of output air file')
|
||||
args = parser.parse_args()
|
||||
|
||||
net = UNet(n_channels=1, n_classes=2)
|
||||
|
|
|
@ -27,7 +27,7 @@ context.set_context(mode=context.GRAPH_MODE, device_target="Ascend")
|
|||
parser = argparse.ArgumentParser(description='VGG16 export')
|
||||
parser.add_argument('--dataset', type=str, choices=["cifar10", "imagenet2012"], default="cifar10", help='ckpt file')
|
||||
parser.add_argument('--ckpt_file', type=str, required=True, help='vgg16 ckpt file.')
|
||||
parser.add_argument('--output_file', type=str, default='vgg16.air', help='vgg16 output air name.')
|
||||
parser.add_argument('--output_file', type=str, default='vgg16', help='vgg16 output air name.')
|
||||
parser.add_argument('--file_format', type=str, choices=["AIR", "ONNX", "MINDIR"], default='AIR', help='file format')
|
||||
args = parser.parse_args()
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ parser = argparse.ArgumentParser(description='yolov3_darknet53 export')
|
|||
parser.add_argument("--device_id", type=int, default=0, help="Device id")
|
||||
parser.add_argument("--batch_size", type=int, default=1, help="batch size")
|
||||
parser.add_argument("--ckpt_file", type=str, required=True, help="Checkpoint file path.")
|
||||
parser.add_argument("--file_name", type=str, default="yolov3_darknet53.air", help="output file name.")
|
||||
parser.add_argument("--file_name", type=str, default="yolov3_darknet53", help="output file name.")
|
||||
parser.add_argument('--file_format', type=str, choices=["AIR", "ONNX", "MINDIR"], default='AIR', help='file format')
|
||||
args = parser.parse_args()
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ parser = argparse.ArgumentParser(description='yolov3_darknet53_quant export')
|
|||
parser.add_argument("--device_id", type=int, default=0, help="Device id")
|
||||
parser.add_argument("--batch_size", type=int, default=1, help="batch size")
|
||||
parser.add_argument("--ckpt_file", type=str, required=True, help="Checkpoint file path.")
|
||||
parser.add_argument("--file_name", type=str, default="yolov3_darknet53_quant.mindir", help="output file name.")
|
||||
parser.add_argument("--file_name", type=str, default="yolov3_darknet53_quant", help="output file name.")
|
||||
parser.add_argument('--file_format', type=str, choices=["AIR", "ONNX", "MINDIR"], default='MINDIR', help='file format')
|
||||
args = parser.parse_args()
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ parser = argparse.ArgumentParser(description='yolov3_resnet18 export')
|
|||
parser.add_argument("--device_id", type=int, default=0, help="Device id")
|
||||
parser.add_argument("--batch_size", type=int, default=1, help="batch size")
|
||||
parser.add_argument("--ckpt_file", type=str, required=True, help="Checkpoint file path.")
|
||||
parser.add_argument("--file_name", type=str, default="yolov3_resnet18.air", help="output file name.")
|
||||
parser.add_argument("--file_name", type=str, default="yolov3_resnet18", help="output file name.")
|
||||
parser.add_argument('--file_format', type=str, choices=["AIR", "ONNX", "MINDIR"], default='AIR', help='file format')
|
||||
args = parser.parse_args()
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ parser.add_argument("--device_id", type=int, default=0, help="Device id")
|
|||
parser.add_argument("--batch_size", type=int, default=1, help="batch size")
|
||||
parser.add_argument("--testing_shape", type=int, default=608, help="test shape")
|
||||
parser.add_argument("--ckpt_file", type=str, required=True, help="Checkpoint file path.")
|
||||
parser.add_argument("--file_name", type=str, default="yolov4.air", help="output file name.")
|
||||
parser.add_argument("--file_name", type=str, default="yolov4", help="output file name.")
|
||||
parser.add_argument('--file_format', type=str, choices=["AIR", "ONNX", "MINDIR"], default='AIR', help='file format')
|
||||
args = parser.parse_args()
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ parser.add_argument('--downstream_task', type=str, choices=["NER", "CLS", "SQUAD
|
|||
parser.add_argument('--num_class', type=int, default=41, help='The number of class, default is 41.')
|
||||
parser.add_argument('--label_file_path', type=str, default="", help='label file path, used in clue benchmark.')
|
||||
parser.add_argument('--ckpt_file', type=str, required=True, help='Bert ckpt file.')
|
||||
parser.add_argument('--output_file', type=str, default='Bert.air', help='bert output air name.')
|
||||
parser.add_argument('--output_file', type=str, default='Bert', help='bert output air name.')
|
||||
parser.add_argument('--file_format', type=str, choices=["AIR", "ONNX", "MINDIR"], default='AIR', help='file format')
|
||||
args = parser.parse_args()
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ from src.tinybert_model import BertModelCLS
|
|||
|
||||
parser = argparse.ArgumentParser(description='tinybert task distill')
|
||||
parser.add_argument('--ckpt_file', type=str, required=True, help='tinybert ckpt file.')
|
||||
parser.add_argument('--output_file', type=str, default='tinybert.air', help='tinybert output air name.')
|
||||
parser.add_argument('--output_file', type=str, default='tinybert', help='tinybert output air name.')
|
||||
parser.add_argument('--task_name', type=str, default='SST-2', choices=['SST-2', 'QNLI', 'MNLI'], help='task name')
|
||||
args = parser.parse_args()
|
||||
|
||||
|
|
|
@ -56,5 +56,5 @@ if __name__ == '__main__':
|
|||
ids = Tensor(np.ones([widedeep_config.eval_batch_size, widedeep_config.field_size]).astype(np.int32))
|
||||
wts = Tensor(np.ones([widedeep_config.eval_batch_size, widedeep_config.field_size]).astype(np.float32))
|
||||
input_tensor_list = [ids, wts]
|
||||
export(net, *input_tensor_list, file_name='wide_and_deep.onnx', file_format="ONNX")
|
||||
export(net, *input_tensor_list, file_name='wide_and_deep.air', file_format="AIR")
|
||||
export(net, *input_tensor_list, file_name='wide_and_deep', file_format="ONNX")
|
||||
export(net, *input_tensor_list, file_name='wide_and_deep', file_format="AIR")
|
||||
|
|
|
@ -35,7 +35,7 @@ def export_net():
|
|||
y = np.ones([2, 2]).astype(np.float32)
|
||||
add = Net()
|
||||
output = add(Tensor(x), Tensor(y))
|
||||
export(add, Tensor(x), Tensor(y), file_name='tensor_add.mindir', file_format='MINDIR')
|
||||
export(add, Tensor(x), Tensor(y), file_name='tensor_add', file_format='MINDIR')
|
||||
print(x)
|
||||
print(y)
|
||||
print(output.asnumpy())
|
||||
|
|
|
@ -147,7 +147,7 @@ def export_lenet():
|
|||
|
||||
# export network
|
||||
inputs = Tensor(np.ones([1, 1, cfg.image_height, cfg.image_width]), mstype.float32)
|
||||
export(network, inputs, file_name="lenet_quant.mindir", file_format='MINDIR', quant_mode='AUTO')
|
||||
export(network, inputs, file_name="lenet_quant", file_format='MINDIR', quant_mode='AUTO')
|
||||
|
||||
|
||||
@pytest.mark.level0
|
||||
|
|
|
@ -331,7 +331,7 @@ def test_export():
|
|||
def test_mindir_export():
|
||||
net = MYNET()
|
||||
input_data = Tensor(np.random.randint(0, 255, [1, 3, 224, 224]).astype(np.float32))
|
||||
export(net, input_data, file_name="./me_binary_export.mindir", file_format="MINDIR")
|
||||
export(net, input_data, file_name="./me_binary_export", file_format="MINDIR")
|
||||
|
||||
|
||||
class PrintNet(nn.Cell):
|
||||
|
|
Loading…
Reference in New Issue