From c13021e335b3e395c9d1a3a9935baedb42aebf08 Mon Sep 17 00:00:00 2001 From: Gian Marco Iodice Date: Wed, 9 May 2018 14:11:34 +0100 Subject: COMPMID-1109 - Enabling Winograd in the graph when possible Change-Id: I524abd28188995ae9c7a43b189b1eb2d7546be93 Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/130576 Tested-by: Jenkins Reviewed-by: Georgios Pinitas --- examples/graph_alexnet.cpp | 7 +++---- examples/graph_googlenet.cpp | 4 ++-- examples/graph_inception_v3.cpp | 9 ++++----- examples/graph_inception_v4.cpp | 7 +++---- examples/graph_resnet50.cpp | 7 +++---- examples/graph_squeezenet.cpp | 7 +++---- examples/graph_squeezenet_v1_1.cpp | 10 +++++----- 7 files changed, 23 insertions(+), 28 deletions(-) (limited to 'examples') diff --git a/examples/graph_alexnet.cpp b/examples/graph_alexnet.cpp index d654f9ece9..291a586315 100644 --- a/examples/graph_alexnet.cpp +++ b/examples/graph_alexnet.cpp @@ -57,10 +57,9 @@ public: Target target_hint = set_target_hint(target); // TODO (geopin01) : Get GPU target somehow and set gemm also for midgard ? - const bool is_gemm_convolution5x5 = (target_hint == Target::NEON); - const bool is_winograd_convolution3x3 = target_hint == Target::CL; - ConvolutionMethod convolution_5x5_hint = is_gemm_convolution5x5 ? ConvolutionMethod::GEMM : ConvolutionMethod::DIRECT; - ConvolutionMethod convolution_3x3_hint = is_winograd_convolution3x3 ? ConvolutionMethod::WINOGRAD : ConvolutionMethod::GEMM; + const bool is_neon = (target_hint == Target::NEON); + ConvolutionMethod convolution_5x5_hint = is_neon ? ConvolutionMethod::GEMM : ConvolutionMethod::DIRECT; + ConvolutionMethod convolution_3x3_hint = is_neon ? ConvolutionMethod::GEMM : ConvolutionMethod::DEFAULT; // Parse arguments if(argc < 2) diff --git a/examples/graph_googlenet.cpp b/examples/graph_googlenet.cpp index 85384d48d3..25e9e7f0cf 100644 --- a/examples/graph_googlenet.cpp +++ b/examples/graph_googlenet.cpp @@ -54,7 +54,7 @@ public: // Set target. 0 (NEON), 1 (OpenCL), 2 (OpenCL with Tuner). By default it is NEON const int target = argc > 1 ? std::strtol(argv[1], nullptr, 10) : 0; Target target_hint = set_target_hint(target); - ConvolutionMethod convolution_hint = (target_hint == Target::CL) ? ConvolutionMethod::WINOGRAD : ConvolutionMethod::GEMM; + ConvolutionMethod convolution_hint = target_hint == Target::NEON ? ConvolutionMethod::GEMM : ConvolutionMethod::DEFAULT; // Parse arguments if(argc < 2) @@ -96,10 +96,10 @@ public: get_weights_accessor(data_path, "/cnn_data/googlenet_model/conv1/conv1_7x7_s2_w.npy"), get_weights_accessor(data_path, "/cnn_data/googlenet_model/conv1/conv1_7x7_s2_b.npy"), PadStrideInfo(2, 2, 3, 3)) + << convolution_hint << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))) << NormalizationLayer(NormalizationLayerInfo(NormType::CROSS_MAP, 5, 0.0001f, 0.75f)) - << convolution_hint << ConvolutionLayer( 1U, 1U, 64U, get_weights_accessor(data_path, "/cnn_data/googlenet_model/conv2/conv2_3x3_reduce_w.npy"), diff --git a/examples/graph_inception_v3.cpp b/examples/graph_inception_v3.cpp index ed79ba65d8..01a4d0c49c 100644 --- a/examples/graph_inception_v3.cpp +++ b/examples/graph_inception_v3.cpp @@ -51,10 +51,9 @@ public: std::unique_ptr preprocessor = arm_compute::support::cpp14::make_unique(); // Set target. 0 (NEON), 1 (OpenCL), 2 (OpenCL with Tuner). By default it is NEON - const int target = argc > 1 ? std::strtol(argv[1], nullptr, 10) : 0; - Target target_hint = set_target_hint(target); - - ConvolutionMethod convolution_hint = (target_hint == Target::CL) ? ConvolutionMethod::WINOGRAD : ConvolutionMethod::GEMM; + const int target = argc > 1 ? std::strtol(argv[1], nullptr, 10) : 0; + Target target_hint = set_target_hint(target); + ConvolutionMethod convolution_hint = target_hint == Target::NEON ? ConvolutionMethod::GEMM : ConvolutionMethod::DEFAULT; // Parse arguments if(argc < 2) @@ -100,8 +99,8 @@ public: get_random_accessor(1.f, 1.f), get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_1a_3x3_BatchNorm_beta.npy"), 0.001f) - << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) << convolution_hint + << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) << ConvolutionLayer(3U, 3U, 32U, get_weights_accessor(data_path, "/cnn_data/inceptionv3_model/Conv2d_2a_3x3_weights.npy"), std::unique_ptr(nullptr), PadStrideInfo(1, 1, 0, 0)) diff --git a/examples/graph_inception_v4.cpp b/examples/graph_inception_v4.cpp index d505133833..8f340354cd 100644 --- a/examples/graph_inception_v4.cpp +++ b/examples/graph_inception_v4.cpp @@ -54,10 +54,9 @@ public: std::unique_ptr preprocessor = arm_compute::support::cpp14::make_unique(); // Set target. 0 (NEON), 1 (OpenCL). By default it is NEON - const int target = argc > 1 ? std::strtol(argv[1], nullptr, 10) : 0; - Target target_hint = set_target_hint(target); - - ConvolutionMethod convolution_hint = (target_hint == Target::CL) ? ConvolutionMethod::WINOGRAD : ConvolutionMethod::GEMM; + const int target = argc > 1 ? std::strtol(argv[1], nullptr, 10) : 0; + Target target_hint = set_target_hint(target); + ConvolutionMethod convolution_hint = target_hint == Target::NEON ? ConvolutionMethod::GEMM : ConvolutionMethod::DEFAULT; // Parse arguments if(argc < 2) diff --git a/examples/graph_resnet50.cpp b/examples/graph_resnet50.cpp index 6fc652edbe..d0fa106bce 100644 --- a/examples/graph_resnet50.cpp +++ b/examples/graph_resnet50.cpp @@ -52,10 +52,9 @@ public: false /* Do not convert to BGR */); // Set target. 0 (NEON), 1 (OpenCL), 2 (OpenCL with Tuner). By default it is NEON - const int target = argc > 1 ? std::strtol(argv[1], nullptr, 10) : 0; - Target target_hint = set_target_hint(target); - - ConvolutionMethod convolution_hint = (target_hint == Target::CL) ? ConvolutionMethod::WINOGRAD : ConvolutionMethod::GEMM; + const int target = argc > 1 ? std::strtol(argv[1], nullptr, 10) : 0; + Target target_hint = set_target_hint(target); + ConvolutionMethod convolution_hint = target_hint == Target::NEON ? ConvolutionMethod::GEMM : ConvolutionMethod::DEFAULT; // Parse arguments if(argc < 2) diff --git a/examples/graph_squeezenet.cpp b/examples/graph_squeezenet.cpp index e9bd8a9c5f..ff2487cd65 100644 --- a/examples/graph_squeezenet.cpp +++ b/examples/graph_squeezenet.cpp @@ -53,10 +53,9 @@ public: std::unique_ptr preprocessor = arm_compute::support::cpp14::make_unique(mean_rgb); // Set target. 0 (NEON), 1 (OpenCL), 2 (OpenCL with Tuner). By default it is NEON - const int target = argc > 1 ? std::strtol(argv[1], nullptr, 10) : 0; - Target target_hint = set_target_hint(target); - - ConvolutionMethod convolution_hint = (target_hint == Target::CL) ? ConvolutionMethod::WINOGRAD : ConvolutionMethod::GEMM; + const int target = argc > 1 ? std::strtol(argv[1], nullptr, 10) : 0; + Target target_hint = set_target_hint(target); + ConvolutionMethod convolution_hint = target_hint == Target::NEON ? ConvolutionMethod::GEMM : ConvolutionMethod::DEFAULT; // Parse arguments if(argc < 2) diff --git a/examples/graph_squeezenet_v1_1.cpp b/examples/graph_squeezenet_v1_1.cpp index 1696b7df43..e1a1f661fb 100644 --- a/examples/graph_squeezenet_v1_1.cpp +++ b/examples/graph_squeezenet_v1_1.cpp @@ -56,10 +56,9 @@ public: std::unique_ptr preprocessor = arm_compute::support::cpp14::make_unique(mean_rgb); // Set target. 0 (NEON), 1 (OpenCL), 2 (OpenCL with Tuner). By default it is NEON - const int target = argc > 1 ? std::strtol(argv[1], nullptr, 10) : 0; - Target target_hint = set_target_hint(target); - - ConvolutionMethod convolution_hint = (target_hint == Target::CL) ? ConvolutionMethod::WINOGRAD : ConvolutionMethod::GEMM; + const int target = argc > 1 ? std::strtol(argv[1], nullptr, 10) : 0; + Target target_hint = set_target_hint(target); + ConvolutionMethod convolution_hint = target_hint == Target::NEON ? ConvolutionMethod::GEMM : ConvolutionMethod::DEFAULT; // Parse arguments if(argc < 2) @@ -102,9 +101,10 @@ public: get_weights_accessor(data_path, "/cnn_data/squeezenet_v1_1_model/conv1_w.npy"), get_weights_accessor(data_path, "/cnn_data/squeezenet_v1_1_model/conv1_b.npy"), PadStrideInfo(2, 2, 0, 0)) + << convolution_hint << ActivationLayer(ActivationLayerInfo(ActivationLayerInfo::ActivationFunction::RELU)) << PoolingLayer(PoolingLayerInfo(PoolingType::MAX, 3, PadStrideInfo(2, 2, 0, 0, DimensionRoundingType::CEIL))) - << convolution_hint + << ConvolutionMethod::DEFAULT << ConvolutionLayer( 1U, 1U, 16U, get_weights_accessor(data_path, "/cnn_data/squeezenet_v1_1_model/fire2_squeeze1x1_w.npy"), -- cgit v1.2.1