From d9eb27597eabe5b7c17520f4f9b3f8a282d72573 Mon Sep 17 00:00:00 2001 From: Georgios Pinitas Date: Tue, 3 Apr 2018 13:44:29 +0100 Subject: COMPMID-797: Switch to new graph. - Cleaned up build system Change-Id: If2faa27ee5b31fa8b972836960ab3ef671059c8d Reviewed-on: https://eu-gerrit-1.euhpc.arm.com/126435 Tested-by: Jenkins Reviewed-by: Pablo Tello --- examples/SConscript | 71 +++++++++++++++--------------------- examples/graph_alexnet.cpp | 6 +-- examples/graph_googlenet.cpp | 6 +-- examples/graph_inception_v3.cpp | 6 +-- examples/graph_inception_v4.cpp | 7 ++-- examples/graph_lenet.cpp | 6 +-- examples/graph_mobilenet.cpp | 6 +-- examples/graph_mobilenet_qasymm8.cpp | 17 ++++++--- examples/graph_resnet50.cpp | 6 +-- examples/graph_squeezenet.cpp | 6 +-- examples/graph_squeezenet_v1_1.cpp | 6 +-- examples/graph_vgg16.cpp | 6 +-- examples/graph_vgg19.cpp | 6 +-- 13 files changed, 73 insertions(+), 82 deletions(-) (limited to 'examples') diff --git a/examples/SConscript b/examples/SConscript index 80bce57316..7f7df3e9aa 100644 --- a/examples/SConscript +++ b/examples/SConscript @@ -24,70 +24,57 @@ import os.path Import('env') -if env['opencl']: - Import('opencl') - -if env['gles_compute'] and env['os'] != 'android': - Import('egl') - Import('glesv2') - examples_env = env.Clone() examples_env.Append(CPPPATH = ["#"]) -examples_env.Append(LIBPATH = ["#build/%s/opencl-1.2-stubs" % env['build_dir']]) # Build examples utils = examples_env.Object("../utils/Utils.cpp") if env['os'] in ['android', 'bare_metal'] or env['standalone']: + Import('arm_compute_graph_a') Import('arm_compute_a') Import('arm_compute_core_a') arm_compute_libs = [ arm_compute_a, arm_compute_core_a ] arm_compute_dependency = arm_compute_a + graph_dependency = [arm_compute_graph_a] else: + Import('arm_compute_graph_so') Import('arm_compute_so') - arm_compute_libs = ["arm_compute", "arm_compute_core"] + arm_compute_libs = ["arm_compute_graph", "arm_compute", "arm_compute_core"] arm_compute_dependency = arm_compute_so + graph_dependency = [arm_compute_graph_so] + +# Build graph examples +graph_utils = examples_env.Object("../utils/GraphUtils.cpp") +for file in Glob("./graph_*.cpp"): + example = os.path.basename(os.path.splitext(str(file))[0]) + prog = None + arm_compute_graph_libs = arm_compute_libs -if env['opencl'] and env['neon']: - for file in Glob("./neoncl_*.cpp"): - example = os.path.basename(os.path.splitext(str(file))[0]) - prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_CL'], LIBS = arm_compute_libs +["OpenCL"]) - Depends(prog, [arm_compute_dependency, opencl]) - alias = examples_env.Alias(example, prog) - Default(alias) if env['os'] == 'android': - Import('arm_compute_graph2_a') - Import('arm_compute_graph_a') - Import('arm_compute_core_a') - Import('arm_compute_a') - arm_compute_graph_libs = [ arm_compute_a, arm_compute_core_a, "OpenCL"] - graph_dependency = [arm_compute_graph_a, arm_compute_graph2_a] + prog = examples_env.Program(example, ["{}.cpp".format(example), utils, graph_utils], LIBS = arm_compute_graph_libs, LINKFLAGS=examples_env["LINKFLAGS"]+['-Wl,--whole-archive',graph_dependency,'-Wl,--no-whole-archive']) + Depends(prog, graph_dependency) else: - Import('arm_compute_graph2_so') - Import('arm_compute_graph_so') - arm_compute_graph_libs = ["arm_compute_graph2", "arm_compute_graph", "arm_compute", "arm_compute_core"] - graph_dependency = [arm_compute_graph_so, arm_compute_graph2_so] + #-Wl,--allow-shlib-undefined: Ignore dependencies of dependencies + prog = examples_env.Program(example, ["{}.cpp".format(example), utils, graph_utils], LIBS = arm_compute_graph_libs, LINKFLAGS=examples_env["LINKFLAGS"]+['-Wl,--allow-shlib-undefined'] ) + Depends(prog, graph_dependency) + alias = examples_env.Alias(example, prog) + Default(alias) - graph_utils = examples_env.Object("../utils/GraphUtils.cpp") - for file in Glob("./graph_*.cpp"): +if env['opencl'] and env['neon']: + for file in Glob("./neoncl_*.cpp"): example = os.path.basename(os.path.splitext(str(file))[0]) - prog = None - if env['os'] == 'android': - prog = examples_env.Program(example, ["{}.cpp".format(example), utils, graph_utils], LIBS = arm_compute_graph_libs + ["OpenCL"], LINKFLAGS=examples_env["LINKFLAGS"]+['-Wl,--whole-archive',graph_dependency,'-Wl,--no-whole-archive']) - Depends(prog, [graph_dependency, opencl]) - else: - #-Wl,--allow-shlib-undefined: Ignore dependencies of dependencies - prog = examples_env.Program(example, ["{}.cpp".format(example), utils, graph_utils], LIBS = arm_compute_graph_libs, LINKFLAGS=examples_env["LINKFLAGS"]+['-Wl,--allow-shlib-undefined'] ) - Depends(prog, graph_dependency) + prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_CL'], LIBS = arm_compute_libs) + Depends(prog, arm_compute_dependency) alias = examples_env.Alias(example, prog) Default(alias) if env['opencl']: for file in Glob("./cl_*.cpp"): example = os.path.basename(os.path.splitext(str(file))[0]) - prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_CL'], LIBS = arm_compute_libs +["OpenCL"]) - Depends(prog, [arm_compute_dependency, opencl]) + prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_CL'], LIBS = arm_compute_libs) + Depends(prog, arm_compute_dependency) alias = examples_env.Alias(example, prog) Default(alias) @@ -103,13 +90,13 @@ if env['gles_compute']: for file in Glob("./gc_*.cpp"): example = os.path.basename(os.path.splitext(str(file))[0]) if env['os'] != 'android': - prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_GC'], LIBS = [arm_compute_libs, "EGL", "GLESv2"]) - Depends(prog, [arm_compute_dependency, egl, glesv2]) + prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_GC'], LIBS = arm_compute_libs) + Depends(prog, arm_compute_dependency) else: if env['arch'] != 'armv7a': - prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_GC'], LIBS = [arm_compute_libs, "EGL", "GLESv3"]) + prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_GC'], LIBS = arm_compute_libs) else: - prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_GC'], LIBS = [arm_compute_libs, "EGL", "GLESv2"]) + prog = examples_env.Program(example, ["{}.cpp".format(example), utils], CPPDEFINES=['ARM_COMPUTE_GC'], LIBS = arm_compute_libs) Depends(prog, [arm_compute_dependency]) alias = examples_env.Alias(example, prog) Default(alias) diff --git a/examples/graph_alexnet.cpp b/examples/graph_alexnet.cpp index 418d1ea071..6a3c14b7bb 100644 --- a/examples/graph_alexnet.cpp +++ b/examples/graph_alexnet.cpp @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "arm_compute/graph2.h" +#include "arm_compute/graph.h" #include "support/ToolchainSupport.h" #include "utils/GraphUtils.h" #include "utils/Utils.h" @@ -31,7 +31,7 @@ #include using namespace arm_compute::utils; -using namespace arm_compute::graph2::frontend; +using namespace arm_compute::graph::frontend; using namespace arm_compute::graph_utils; /** Example demonstrating how to implement AlexNet's network using the Compute Library's graph API @@ -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_hint2(target); + 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); diff --git a/examples/graph_googlenet.cpp b/examples/graph_googlenet.cpp index d6e76fdced..6c3fac4af2 100644 --- a/examples/graph_googlenet.cpp +++ b/examples/graph_googlenet.cpp @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "arm_compute/graph2.h" +#include "arm_compute/graph.h" #include "support/ToolchainSupport.h" #include "utils/GraphUtils.h" #include "utils/Utils.h" @@ -30,7 +30,7 @@ #include using namespace arm_compute::utils; -using namespace arm_compute::graph2::frontend; +using namespace arm_compute::graph::frontend; using namespace arm_compute::graph_utils; /** Example demonstrating how to implement Googlenet's network using the Compute Library's graph API @@ -53,7 +53,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_hint2(target); + Target target_hint = set_target_hint(target); ConvolutionMethod convolution_hint = (target_hint == Target::CL) ? ConvolutionMethod::WINOGRAD : ConvolutionMethod::GEMM; // Parse arguments diff --git a/examples/graph_inception_v3.cpp b/examples/graph_inception_v3.cpp index 5f049d0f4a..22e6f6e489 100644 --- a/examples/graph_inception_v3.cpp +++ b/examples/graph_inception_v3.cpp @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "arm_compute/graph2.h" +#include "arm_compute/graph.h" #include "support/ToolchainSupport.h" #include "utils/GraphUtils.h" #include "utils/Utils.h" @@ -30,7 +30,7 @@ #include using namespace arm_compute::utils; -using namespace arm_compute::graph2::frontend; +using namespace arm_compute::graph::frontend; using namespace arm_compute::graph_utils; /** Example demonstrating how to implement InceptionV3's network using the Compute Library's graph API @@ -52,7 +52,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_hint2(target); + Target target_hint = set_target_hint(target); ConvolutionMethod convolution_hint = (target_hint == Target::CL) ? ConvolutionMethod::WINOGRAD : ConvolutionMethod::GEMM; diff --git a/examples/graph_inception_v4.cpp b/examples/graph_inception_v4.cpp index 847c5b8250..1f7875176f 100644 --- a/examples/graph_inception_v4.cpp +++ b/examples/graph_inception_v4.cpp @@ -21,8 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "arm_compute/core/Error.h" -#include "arm_compute/graph2.h" +#include "arm_compute/graph.h" #include "support/ToolchainSupport.h" #include "utils/GraphUtils.h" #include "utils/Utils.h" @@ -31,7 +30,7 @@ #include using namespace arm_compute::utils; -using namespace arm_compute::graph2::frontend; +using namespace arm_compute::graph::frontend; using namespace arm_compute::graph_utils; /** Example demonstrating how to implement InceptionV4's network using the Compute Library's graph API @@ -56,7 +55,7 @@ public: // 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_hint2(target); + Target target_hint = set_target_hint(target); ConvolutionMethod convolution_hint = (target_hint == Target::CL) ? ConvolutionMethod::WINOGRAD : ConvolutionMethod::GEMM; diff --git a/examples/graph_lenet.cpp b/examples/graph_lenet.cpp index 3803da9b83..8aca0fa45b 100644 --- a/examples/graph_lenet.cpp +++ b/examples/graph_lenet.cpp @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "arm_compute/graph2.h" +#include "arm_compute/graph.h" #include "support/ToolchainSupport.h" #include "utils/GraphUtils.h" @@ -30,7 +30,7 @@ #include using namespace arm_compute::utils; -using namespace arm_compute::graph2::frontend; +using namespace arm_compute::graph::frontend; using namespace arm_compute::graph_utils; /** Example demonstrating how to implement LeNet's network using the Compute Library's graph API @@ -48,7 +48,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_hint2(target); + Target target_hint = set_target_hint(target); // Parse arguments if(argc < 2) diff --git a/examples/graph_mobilenet.cpp b/examples/graph_mobilenet.cpp index bd25b927fe..055f289f52 100644 --- a/examples/graph_mobilenet.cpp +++ b/examples/graph_mobilenet.cpp @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "arm_compute/graph2.h" +#include "arm_compute/graph.h" #include "support/ToolchainSupport.h" #include "utils/GraphUtils.h" #include "utils/Utils.h" @@ -29,7 +29,7 @@ #include using namespace arm_compute::utils; -using namespace arm_compute::graph2::frontend; +using namespace arm_compute::graph::frontend; using namespace arm_compute::graph_utils; /** Example demonstrating how to implement MobileNet's network using the Compute Library's graph API @@ -51,7 +51,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_hint2(target); + Target target_hint = set_target_hint(target); ConvolutionMethod convolution_hint = ConvolutionMethod::GEMM; DepthwiseConvolutionMethod depthwise_convolution_hint = DepthwiseConvolutionMethod::OPTIMIZED_3x3; diff --git a/examples/graph_mobilenet_qasymm8.cpp b/examples/graph_mobilenet_qasymm8.cpp index 76b13dd851..cb49ffdfb4 100644 --- a/examples/graph_mobilenet_qasymm8.cpp +++ b/examples/graph_mobilenet_qasymm8.cpp @@ -21,14 +21,15 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "arm_compute/graph/Graph.h" -#include "arm_compute/graph/Nodes.h" +#include "arm_compute/graph.h" #include "support/ToolchainSupport.h" #include "utils/GraphUtils.h" #include "utils/Utils.h" -using namespace arm_compute; -using namespace arm_compute::graph; +#include + +using namespace arm_compute::utils; +using namespace arm_compute::graph::frontend; using namespace arm_compute::graph_utils; /** Example demonstrating how to implement QASYMM8 MobileNet's network using the Compute Library's graph API @@ -36,9 +37,11 @@ using namespace arm_compute::graph_utils; * @param[in] argc Number of arguments * @param[in] argv Arguments ( [optional] Target (0 = NEON, 1 = OpenCL, 2 = OpenCL with Tuner), [optional] Path to the weights folder, [optional] npy_input, [optional] labels ) */ -class GraphMobileNetQASYMM8Example : public utils::Example +class GraphMobileNetQASYMM8Example : public Example { public: + //FIXME: Missing quantization info to the tensor descriptor (Giorgio is working on it) +#if 0 void do_setup(int argc, char **argv) override { std::string data_path; /* Path to the trainable data */ @@ -217,6 +220,8 @@ private: return BranchLayer(std::move(sg)); } +#endif /* if 0 */ + Stream graph { 0, "MobileNetV1_QASYMM8" }; }; /** Main program for MobileNetQASYMM8 * @@ -225,5 +230,5 @@ private: */ int main(int argc, char **argv) { - return utils::run_example(argc, argv); + return arm_compute::utils::run_example(argc, argv); } diff --git a/examples/graph_resnet50.cpp b/examples/graph_resnet50.cpp index ec447de66f..eb74a1aa11 100644 --- a/examples/graph_resnet50.cpp +++ b/examples/graph_resnet50.cpp @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "arm_compute/graph2.h" +#include "arm_compute/graph.h" #include "support/ToolchainSupport.h" #include "utils/GraphUtils.h" #include "utils/Utils.h" @@ -29,7 +29,7 @@ #include using namespace arm_compute::utils; -using namespace arm_compute::graph2::frontend; +using namespace arm_compute::graph::frontend; using namespace arm_compute::graph_utils; /** Example demonstrating how to implement Microsoft's ResNet50 network using the Compute Library's graph API @@ -53,7 +53,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_hint2(target); + Target target_hint = set_target_hint(target); ConvolutionMethod convolution_hint = (target_hint == Target::CL) ? ConvolutionMethod::WINOGRAD : ConvolutionMethod::GEMM; diff --git a/examples/graph_squeezenet.cpp b/examples/graph_squeezenet.cpp index ddbe6b43ce..32be14305f 100644 --- a/examples/graph_squeezenet.cpp +++ b/examples/graph_squeezenet.cpp @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "arm_compute/graph2.h" +#include "arm_compute/graph.h" #include "support/ToolchainSupport.h" #include "utils/GraphUtils.h" #include "utils/Utils.h" @@ -30,7 +30,7 @@ #include using namespace arm_compute::utils; -using namespace arm_compute::graph2::frontend; +using namespace arm_compute::graph::frontend; using namespace arm_compute::graph_utils; using namespace arm_compute::logging; @@ -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_hint2(target); + Target target_hint = set_target_hint(target); ConvolutionMethod convolution_hint = (target_hint == Target::CL) ? ConvolutionMethod::WINOGRAD : ConvolutionMethod::GEMM; diff --git a/examples/graph_squeezenet_v1_1.cpp b/examples/graph_squeezenet_v1_1.cpp index faab79fcf1..2bdb00d7c2 100644 --- a/examples/graph_squeezenet_v1_1.cpp +++ b/examples/graph_squeezenet_v1_1.cpp @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "arm_compute/graph2.h" +#include "arm_compute/graph.h" #include "support/ToolchainSupport.h" #include "utils/GraphUtils.h" #include "utils/Utils.h" @@ -30,7 +30,7 @@ #include using namespace arm_compute::utils; -using namespace arm_compute::graph2::frontend; +using namespace arm_compute::graph::frontend; using namespace arm_compute::graph_utils; namespace @@ -57,7 +57,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_hint2(target); + Target target_hint = set_target_hint(target); ConvolutionMethod convolution_hint = (target_hint == Target::CL) ? ConvolutionMethod::WINOGRAD : ConvolutionMethod::GEMM; diff --git a/examples/graph_vgg16.cpp b/examples/graph_vgg16.cpp index 23742ed771..82be97c316 100644 --- a/examples/graph_vgg16.cpp +++ b/examples/graph_vgg16.cpp @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "arm_compute/graph2.h" +#include "arm_compute/graph.h" #include "support/ToolchainSupport.h" #include "utils/GraphUtils.h" #include "utils/Utils.h" @@ -29,7 +29,7 @@ #include using namespace arm_compute::utils; -using namespace arm_compute::graph2::frontend; +using namespace arm_compute::graph::frontend; using namespace arm_compute::graph_utils; namespace @@ -66,7 +66,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_hint2(target); + Target target_hint = set_target_hint(target); // Check if we can use GEMM-based convolutions evaluating if the platform has at least 1.8 GB of available memory const size_t memory_required = 1932735283L; diff --git a/examples/graph_vgg19.cpp b/examples/graph_vgg19.cpp index f282b90630..606b0e0142 100644 --- a/examples/graph_vgg19.cpp +++ b/examples/graph_vgg19.cpp @@ -21,7 +21,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include "arm_compute/graph2.h" +#include "arm_compute/graph.h" #include "support/ToolchainSupport.h" #include "utils/GraphUtils.h" #include "utils/Utils.h" @@ -29,7 +29,7 @@ #include using namespace arm_compute::utils; -using namespace arm_compute::graph2::frontend; +using namespace arm_compute::graph::frontend; using namespace arm_compute::graph_utils; /** Example demonstrating how to implement VGG19's network using the Compute Library's graph API @@ -52,7 +52,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_hint2(target); + Target target_hint = set_target_hint(target); ConvolutionMethod convolution_hint = ConvolutionMethod::DIRECT; // Parse arguments -- cgit v1.2.1