diff --git a/akg b/akg index 83df651adb4..32af460cac1 160000 --- a/akg +++ b/akg @@ -1 +1 @@ -Subproject commit 83df651adb471ec229fc1732b894dd2142946233 +Subproject commit 32af460cac1bb7d76bc1fd41f5866107cfffe1b9 diff --git a/mindspore/_extends/graph_kernel/expanders/conv2d.py b/mindspore/_extends/graph_kernel/expanders/conv2d.py index 24908d25d6c..eb711c71adc 100644 --- a/mindspore/_extends/graph_kernel/expanders/conv2d.py +++ b/mindspore/_extends/graph_kernel/expanders/conv2d.py @@ -100,12 +100,14 @@ class Conv2D(Expander): check_nd(stride, 4) n0, h0, w0, c0 = shape_0 n1, h1, w1, c1 = shape_1 - if n0 < N0_CHANNEL_ALIGN: - raise GKException("N({}) channel of first input should >= {}".format(n0, N0_CHANNEL_ALIGN)) + if n0 <= N0_CHANNEL_ALIGN: + raise GKException("N({}) channel of first input should > {}".format(n0, N0_CHANNEL_ALIGN)) if n1 < N1_CHANNEL_ALIGN: raise GKException("N({}) channel of second input should >= {}".format(n1, N1_CHANNEL_ALIGN)) if c0 != c1 or c0 < C_CHANNEL_ALIGN: raise GKException("C channel of inputs({}, {}) should be same and >= {}".format(c0, c1, C_CHANNEL_ALIGN)) + if stride != [1, 1, 2, 2]: + raise GKException("Stride H and W should be [2, 2] but got [{}, {}]".format(stride[2], stride[3])) # n0 pad n0 = ((n0 + N0_CHANNEL_ALIGN - 1) // N0_CHANNEL_ALIGN) * N0_CHANNEL_ALIGN # h0, w0 pad diff --git a/model_zoo/official/cv/resnet/train.py b/model_zoo/official/cv/resnet/train.py index 642a7426392..858acb1d400 100755 --- a/model_zoo/official/cv/resnet/train.py +++ b/model_zoo/official/cv/resnet/train.py @@ -121,7 +121,8 @@ def apply_eval(eval_param): def set_graph_kernel_context(run_platform, net_name): if run_platform == "GPU" and net_name == "resnet101": - context.set_context(enable_graph_kernel=True, graph_kernel_flags="--enable_parallel_fusion") + context.set_context(enable_graph_kernel=True) + context.set_context(graph_kernel_flags="--enable_parallel_fusion --enable_expand_ops=Conv2D") if __name__ == '__main__': target = args_opt.device_target diff --git a/model_zoo/official/cv/resnext50/eval.py b/model_zoo/official/cv/resnext50/eval.py index 9f36c215fbe..e29bcd1d14d 100644 --- a/model_zoo/official/cv/resnext50/eval.py +++ b/model_zoo/official/cv/resnext50/eval.py @@ -123,6 +123,10 @@ def get_result(model, top1_correct, top5_correct, img_tot): config.logger.info('after results=%s', results) return results +def set_graph_kernel_context(device_target): + if device_target == "GPU": + context.set_context(enable_graph_kernel=True) + @moxing_wrapper() def test(cloud_args=None): """test""" @@ -131,6 +135,7 @@ def test(cloud_args=None): device_target=config.device_target, save_graphs=False) if os.getenv('DEVICE_ID', "not_set").isdigit(): context.set_context(device_id=int(os.getenv('DEVICE_ID'))) + set_graph_kernel_context(config.device_target) # init distributed if config.run_distribute: diff --git a/model_zoo/official/cv/resnext50/train.py b/model_zoo/official/cv/resnext50/train.py index 4bd2048d605..50a9306d3df 100644 --- a/model_zoo/official/cv/resnext50/train.py +++ b/model_zoo/official/cv/resnext50/train.py @@ -134,12 +134,17 @@ def set_parameters(): config.logger = get_logger(config.outputs_dir, config.rank) return config +def set_graph_kernel_context(device_target): + if device_target == "GPU": + context.set_context(enable_graph_kernel=True) + @moxing_wrapper() def train(): """training process""" set_parameters() if os.getenv('DEVICE_ID', "not_set").isdigit(): context.set_context(device_id=int(os.getenv('DEVICE_ID'))) + set_graph_kernel_context(config.device_target) # init distributed if config.run_distribute: diff --git a/model_zoo/official/cv/yolov3_darknet53/train.py b/model_zoo/official/cv/yolov3_darknet53/train.py index 8825efed6a2..6b11a9e4f40 100644 --- a/model_zoo/official/cv/yolov3_darknet53/train.py +++ b/model_zoo/official/cv/yolov3_darknet53/train.py @@ -64,7 +64,8 @@ def set_graph_kernel_context(): context.set_context(enable_graph_kernel=True) context.set_context(graph_kernel_flags="--enable_parallel_fusion " "--disable_expand_ops=BatchNorm,BatchNormGrad " - "--disable_cluster_ops=ReduceMax,Reshape") + "--disable_cluster_ops=ReduceMax,Reshape " + "--enable_expand_ops=Conv2D") def network_init(args): devid = int(os.getenv('DEVICE_ID', '0')) diff --git a/model_zoo/official/recommend/wide_and_deep/train_and_eval_auto_parallel.py b/model_zoo/official/recommend/wide_and_deep/train_and_eval_auto_parallel.py index 1c80aef25f1..6eb56a4c57e 100644 --- a/model_zoo/official/recommend/wide_and_deep/train_and_eval_auto_parallel.py +++ b/model_zoo/official/recommend/wide_and_deep/train_and_eval_auto_parallel.py @@ -145,6 +145,8 @@ def train_and_eval(config): if __name__ == "__main__": context.set_context(mode=context.GRAPH_MODE, device_target=cfg.device_target) + if cfg.device_target == "GPU": + context.set_context(enable_graph_kernel=True) context.set_context(variable_memory_max_size="24GB") context.set_context(enable_sparse=True) init()