Browse Source

fix GPU device_id bug

tags/v1.2.0-rc1
yuzhenhua 5 years ago
parent
commit
6b858480c8
40 changed files with 120 additions and 40 deletions
  1. +3
    -1
      model_zoo/official/cv/alexnet/export.py
  2. +3
    -1
      model_zoo/official/cv/centerface/export.py
  3. +3
    -1
      model_zoo/official/cv/cnnctc/export.py
  4. +3
    -1
      model_zoo/official/cv/deeplabv3/export.py
  5. +3
    -1
      model_zoo/official/cv/densenet121/export.py
  6. +3
    -1
      model_zoo/official/cv/efficientnet/export.py
  7. +3
    -1
      model_zoo/official/cv/faster_rcnn/export.py
  8. +3
    -1
      model_zoo/official/cv/googlenet/export.py
  9. +3
    -1
      model_zoo/official/cv/inceptionv3/export.py
  10. +3
    -1
      model_zoo/official/cv/inceptionv4/export.py
  11. +3
    -1
      model_zoo/official/cv/lenet/export.py
  12. +3
    -1
      model_zoo/official/cv/maskrcnn/export.py
  13. +3
    -1
      model_zoo/official/cv/maskrcnn_mobilenetv1/export.py
  14. +3
    -1
      model_zoo/official/cv/mobilenetv2/export.py
  15. +3
    -1
      model_zoo/official/cv/nasnet/export.py
  16. +3
    -1
      model_zoo/official/cv/psenet/export.py
  17. +3
    -1
      model_zoo/official/cv/resnet/export.py
  18. +3
    -1
      model_zoo/official/cv/resnext50/export.py
  19. +3
    -1
      model_zoo/official/cv/shufflenetv1/export.py
  20. +3
    -1
      model_zoo/official/cv/shufflenetv2/export.py
  21. +3
    -1
      model_zoo/official/cv/squeezenet/export.py
  22. +3
    -1
      model_zoo/official/cv/ssd/export.py
  23. +3
    -1
      model_zoo/official/cv/unet/export.py
  24. +3
    -1
      model_zoo/official/cv/vgg16/export.py
  25. +3
    -1
      model_zoo/official/cv/warpctc/export.py
  26. +3
    -1
      model_zoo/official/cv/xception/export.py
  27. +3
    -1
      model_zoo/official/cv/yolov3_darknet53/export.py
  28. +3
    -1
      model_zoo/official/cv/yolov3_resnet18/export.py
  29. +3
    -1
      model_zoo/official/cv/yolov4/export.py
  30. +3
    -1
      model_zoo/official/gnn/bgcf/export.py
  31. +3
    -1
      model_zoo/official/gnn/gat/export.py
  32. +3
    -1
      model_zoo/official/gnn/gcn/export.py
  33. +3
    -1
      model_zoo/official/nlp/bert/export.py
  34. +3
    -1
      model_zoo/official/nlp/mass/export.py
  35. +3
    -1
      model_zoo/official/nlp/textcnn/export.py
  36. +3
    -1
      model_zoo/official/nlp/tinybert/export.py
  37. +3
    -1
      model_zoo/official/nlp/transformer/export.py
  38. +3
    -1
      model_zoo/official/recommend/deepfm/export.py
  39. +3
    -1
      model_zoo/official/recommend/ncf/export.py
  40. +3
    -1
      model_zoo/official/recommend/wide_and_deep/export.py

+ 3
- 1
model_zoo/official/cv/alexnet/export.py View File

@@ -38,7 +38,9 @@ parser.add_argument("--file_name", type=str, default="alexnet", help="output fil
parser.add_argument("--file_format", type=str, choices=["AIR", "ONNX", "MINDIR"], default="AIR", help="file format")
args_opt = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args_opt.device_target, device_id=args_opt.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args_opt.device_target)
if args_opt.device_target == "Ascend":
context.set_context(device_id=args_opt.device_id)

if __name__ == '__main__':
if args_opt.dataset_name == 'cifar10':


+ 3
- 1
model_zoo/official/cv/centerface/export.py View File

@@ -33,7 +33,9 @@ parser.add_argument("--device_target", type=str, choices=["Ascend", "GPU", "CPU"
help="device target")
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == '__main__':
config = ConfigCenterface()


+ 3
- 1
model_zoo/official/cv/cnnctc/export.py View File

@@ -31,7 +31,9 @@ parser.add_argument("--device_target", type=str, choices=["Ascend", "GPU", "CPU"
parser.add_argument("--ckpt_file", type=str, default="./ckpts/cnn_ctc.ckpt", help="CNN&CTC ckpt file.")
args_opt = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args_opt.device_target, device_id=args_opt.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args_opt.device_target)
if args_opt.device_target == "Ascend":
context.set_context(device_id=args_opt.device_id)

if __name__ == "__main__":
cfg = Config_CNNCTC()


+ 3
- 1
model_zoo/official/cv/deeplabv3/export.py View File

@@ -34,7 +34,9 @@ parser.add_argument('--model', type=str.lower, default='deeplab_v3_s8', choices=
parser.add_argument('--num_classes', type=int, default=21, help='the number of classes (Default: 21)')
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == '__main__':
if args.model == 'deeplab_v3_s16':


+ 3
- 1
model_zoo/official/cv/densenet121/export.py View File

@@ -33,7 +33,9 @@ parser.add_argument("--device_target", type=str, choices=["Ascend", "GPU", "CPU"
help="device target")
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == "__main__":
network = DenseNet121(config.num_classes)


+ 3
- 1
model_zoo/official/cv/efficientnet/export.py View File

@@ -32,7 +32,9 @@ parser.add_argument("--device_target", type=str, choices=["Ascend", "GPU", "CPU"
help="device target")
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == "__main__":
if args.device_target != "GPU":


+ 3
- 1
model_zoo/official/cv/faster_rcnn/export.py View File

@@ -31,7 +31,9 @@ parser.add_argument("--device_target", type=str, choices=["Ascend", "GPU", "CPU"
parser.add_argument('--ckpt_file', type=str, default='', help='fasterrcnn ckpt file.')
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == '__main__':
net = FasterRcnn_Infer(config=config)


+ 3
- 1
model_zoo/official/cv/googlenet/export.py View File

@@ -37,7 +37,9 @@ parser.add_argument('--dataset_name', type=str, default='cifar10', choices=['ima
help='dataset name.')
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == '__main__':
if args.dataset_name == 'cifar10':


+ 3
- 1
model_zoo/official/cv/inceptionv3/export.py View File

@@ -33,7 +33,9 @@ parser.add_argument("--device_target", type=str, choices=["Ascend", "GPU", "CPU"
help="device target")
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == '__main__':
net = InceptionV3(num_classes=cfg.num_classes, is_training=False)


+ 3
- 1
model_zoo/official/cv/inceptionv4/export.py View File

@@ -34,7 +34,9 @@ parser.add_argument("--device_target", type=str, choices=["Ascend", "GPU", "CPU"
help="device target")
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == '__main__':
net = Inceptionv4(classes=config.num_classes)


+ 3
- 1
model_zoo/official/cv/lenet/export.py View File

@@ -33,7 +33,9 @@ parser.add_argument("--device_target", type=str, choices=["Ascend", "GPU", "CPU"
help="device target")
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == "__main__":



+ 3
- 1
model_zoo/official/cv/maskrcnn/export.py View File

@@ -31,7 +31,9 @@ parser.add_argument('--device_target', type=str, default="Ascend",
choices=['Ascend', 'GPU', 'CPU'], help='device target (default: Ascend)')
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == '__main__':
net = MaskRcnn_Infer(config=config)


+ 3
- 1
model_zoo/official/cv/maskrcnn_mobilenetv1/export.py View File

@@ -31,7 +31,9 @@ parser.add_argument("--device_target", type=str, choices=["Ascend", "GPU", "CPU"
help="device target")
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == '__main__':
config.test_batch_size = args.batch_size


+ 3
- 1
model_zoo/official/cv/mobilenetv2/export.py View File

@@ -34,7 +34,9 @@ args = parser.parse_args()
args.is_training = False
args.run_distribute = False

context.set_context(mode=context.GRAPH_MODE, device_target=args.platform, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.platform)
if args.platform == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == '__main__':
cfg = set_config(args)


+ 3
- 1
model_zoo/official/cv/nasnet/export.py View File

@@ -34,7 +34,9 @@ parser.add_argument("--device_target", type=str, choices=["Ascend", "GPU", "CPU"
help="device target")
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == '__main__':
net = NASNetAMobile(num_classes=cfg.num_classes, is_training=False)


+ 3
- 1
model_zoo/official/cv/psenet/export.py View File

@@ -34,7 +34,9 @@ parser.add_argument("--device_target", type=str, default="Ascend",
choices=["Ascend", "GPU", "CPU"], help="device target (default: Ascend)")
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == '__main__':
net = ETSNet(config)


+ 3
- 1
model_zoo/official/cv/resnet/export.py View File

@@ -38,7 +38,9 @@ parser.add_argument("--device_target", type=str, default="Ascend",
choices=["Ascend", "GPU", "CPU"], help="device target(default: Ascend)")
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == '__main__':



+ 3
- 1
model_zoo/official/cv/resnext50/export.py View File

@@ -33,7 +33,9 @@ parser.add_argument("--device_target", type=str, default="Ascend",
choices=["Ascend", "GPU", "CPU"], help="device target (default: Ascend)")
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == '__main__':
net = get_network(num_classes=config.num_classes, platform=args.device_target)


+ 3
- 1
model_zoo/official/cv/shufflenetv1/export.py View File

@@ -37,7 +37,9 @@ parser.add_argument('--model_size', type=str, default='2.0x', choices=['2.0x', '

args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == '__main__':



+ 3
- 1
model_zoo/official/cv/shufflenetv2/export.py View File

@@ -34,7 +34,9 @@ parser.add_argument("--device_target", type=str, default="GPU",
choices=["Ascend", "GPU", "CPU"], help="device where the code will be implemented (default: GPU)")
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == '__main__':
if args.device_target != 'GPU':


+ 3
- 1
model_zoo/official/cv/squeezenet/export.py View File

@@ -45,7 +45,9 @@ if args.dataset == "cifar10":
else:
num_classes = 1000

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == '__main__':
net = squeezenet(num_classes=num_classes)


+ 3
- 1
model_zoo/official/cv/ssd/export.py View File

@@ -32,7 +32,9 @@ parser.add_argument("--device_target", type=str, choices=["Ascend", "GPU", "CPU"
help="device target")
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == '__main__':
if config.model == "ssd300":


+ 3
- 1
model_zoo/official/cv/unet/export.py View File

@@ -33,7 +33,9 @@ parser.add_argument("--device_target", type=str, choices=["Ascend", "GPU", "CPU"
help="device target")
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == "__main__":
net = UNet(n_channels=cfg["num_channels"], n_classes=cfg["num_classes"])


+ 3
- 1
model_zoo/official/cv/vgg16/export.py View File

@@ -46,7 +46,9 @@ args.batch_norm = cfg.batch_norm
args.has_dropout = cfg.has_dropout
args.image_size = list(map(int, cfg.image_size.split(',')))

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == '__main__':
if args.dataset == "cifar10":


+ 3
- 1
model_zoo/official/cv/warpctc/export.py View File

@@ -30,7 +30,9 @@ parser.add_argument("--device_target", type=str, choices=["Ascend", "GPU", "CPU"
help="device target")
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == "__main__":
captcha_width = config.captcha_width


+ 3
- 1
model_zoo/official/cv/xception/export.py View File

@@ -33,7 +33,9 @@ parser.add_argument("--device_target", type=str, choices=["Ascend", "GPU", "CPU"
help="device target")
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == "__main__":
# define net


+ 3
- 1
model_zoo/official/cv/yolov3_darknet53/export.py View File

@@ -32,7 +32,9 @@ parser.add_argument("--device_target", type=str, choices=["Ascend", "GPU", "CPU"
help="device target")
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == "__main__":
network = YOLOV3DarkNet53(is_training=False)


+ 3
- 1
model_zoo/official/cv/yolov3_resnet18/export.py View File

@@ -32,7 +32,9 @@ parser.add_argument("--device_target", type=str, choices=["Ascend", "GPU", "CPU"
help="device target")
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == "__main__":
config = ConfigYOLOV3ResNet18()


+ 3
- 1
model_zoo/official/cv/yolov4/export.py View File

@@ -32,7 +32,9 @@ parser.add_argument("--device_target", type=str, choices=["Ascend", "GPU", "CPU"
help="device target")
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == "__main__":
ts_shape = args.testing_shape


+ 3
- 1
model_zoo/official/gnn/bgcf/export.py View File

@@ -36,7 +36,9 @@ parser.add_argument("--gnew_neighs", type=int, default=20, help="num of sampling
parser.add_argument("--activation", type=str, default="tanh", choices=["relu", "tanh"], help="activation function")
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == "__main__":
num_user, num_item = 7068, 3570


+ 3
- 1
model_zoo/official/gnn/gat/export.py View File

@@ -31,7 +31,9 @@ parser.add_argument("--device_target", type=str, default="Ascend",
choices=["Ascend", "GPU", "CPU"], help="device target (default: Ascend)")
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == "__main__":



+ 3
- 1
model_zoo/official/gnn/gcn/export.py View File

@@ -31,7 +31,9 @@ parser.add_argument("--device_target", type=str, default="Ascend",
choices=["Ascend", "GPU", "CPU"], help="device target (default: Ascend)")
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == "__main__":
config = ConfigGCN()


+ 3
- 1
model_zoo/official/nlp/bert/export.py View File

@@ -39,7 +39,9 @@ parser.add_argument("--device_target", type=str, default="Ascend",
choices=["Ascend", "GPU", "CPU"], help="device target (default: Ascend)")
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

label_list = []
with open(args.label_file_path) as f:


+ 3
- 1
model_zoo/official/nlp/mass/export.py View File

@@ -36,7 +36,9 @@ parser.add_argument('--gigaword_infer_config', type=str, required=True, help='gi
parser.add_argument('--vocab_file', type=str, required=True, help='vocabulary file')
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

def get_config(config_file):
tfm_config = TransformerConfig.from_json_file(config_file)


+ 3
- 1
model_zoo/official/nlp/textcnn/export.py View File

@@ -37,7 +37,9 @@ parser.add_argument('--dataset', type=str, default='MR', choices=['MR', 'SUBJ',

args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == '__main__':



+ 3
- 1
model_zoo/official/nlp/tinybert/export.py View File

@@ -34,7 +34,9 @@ parser.add_argument("--device_target", type=str, default="Ascend",
parser.add_argument('--task_name', type=str, default='SST-2', choices=['SST-2', 'QNLI', 'MNLI'], help='task name')
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

DEFAULT_NUM_LABELS = 2
DEFAULT_SEQ_LENGTH = 128


+ 3
- 1
model_zoo/official/nlp/transformer/export.py View File

@@ -33,7 +33,9 @@ parser.add_argument("--device_target", type=str, default="Ascend",
choices=["Ascend", "GPU", "CPU"], help="device target (default: Ascend)")
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == '__main__':
tfm_model = TransformerModel(config=transformer_net_cfg, is_training=False, use_one_hot_embeddings=False)


+ 3
- 1
model_zoo/official/recommend/deepfm/export.py View File

@@ -32,7 +32,9 @@ parser.add_argument("--device_target", type=str, choices=["Ascend", "GPU", "CPU"
help="device target")
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == "__main__":
data_config = DataConfig()


+ 3
- 1
model_zoo/official/recommend/ncf/export.py View File

@@ -32,7 +32,9 @@ parser.add_argument("--device_target", type=str, default="Ascend",
choices=["Ascend", "GPU", "CPU"], help="device target (default: Ascend)")
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == "__main__":
topk = rconst.TOP_K


+ 3
- 1
model_zoo/official/recommend/wide_and_deep/export.py View File

@@ -32,7 +32,9 @@ parser.add_argument("--device_target", type=str, default="Ascend",
choices=["Ascend", "GPU", "CPU"], help="device target (default: Ascend)")
args = parser.parse_args()

context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target, device_id=args.device_id)
context.set_context(mode=context.GRAPH_MODE, device_target=args.device_target)
if args.device_target == "Ascend":
context.set_context(device_id=args.device_id)

if __name__ == '__main__':
widedeep_config = WideDeepConfig()


Loading…
Cancel
Save