diff options
author | Isabella Gottardi <isabella.gottardi@arm.com> | 2017-11-09 17:05:07 +0000 |
---|---|---|
committer | Anthony Barbier <anthony.barbier@arm.com> | 2018-11-02 16:35:24 +0000 |
commit | b28f29d5f5657b606921faf4c6dcc2ced1465cc7 (patch) | |
tree | 34560537d03f9766af55b470cd4344b8339c7817 | |
parent | a3b1b469276b10484cd45901ae3a4b48b506caa9 (diff) | |
download | ComputeLibrary-b28f29d5f5657b606921faf4c6dcc2ced1465cc7.tar.gz |
COMPMID-652 - Graph examples shouldn't need to link against OpenCL
- Added --no-allow-shlib-undefined to library builds to make sure we
don't leave any unresolved symbol
- Added --allow-shlib-undefined to the graph examples build lines so that
it doesn't matter whether or not OpenCL is supported by the Graph
librarylibrary
- Don't link tests statically anymore on Android (This was probably
required in the past because we were duplicating symbols in the
core and runtime libraries, but it doesn't seem to be an issue
anymore)
- Updated Doxygen accordingly
Change-Id: I9905f388e0838bc8e3369de52838bf980b992ead
Reviewed-on: http://mpd-gerrit.cambridge.arm.com/95172
Tested-by: Kaizen <jeremy.johnson+kaizengerrit@arm.com>
Reviewed-by: Georgios Pinitas <georgios.pinitas@arm.com>
-rw-r--r-- | SConscript | 13 | ||||
-rw-r--r-- | SConstruct | 3 | ||||
-rw-r--r-- | arm_compute/graph/Graph.h | 3 | ||||
-rw-r--r-- | docs/00_introduction.dox | 21 | ||||
-rw-r--r-- | examples/SConscript | 20 | ||||
-rw-r--r-- | examples/graph_alexnet.cpp | 10 | ||||
-rw-r--r-- | examples/graph_googlenet.cpp | 14 | ||||
-rw-r--r-- | examples/graph_lenet.cpp | 11 | ||||
-rw-r--r-- | examples/graph_squeezenet.cpp | 14 | ||||
-rw-r--r-- | examples/graph_vgg16.cpp | 8 | ||||
-rw-r--r-- | examples/graph_vgg19.cpp | 9 | ||||
-rwxr-xr-x | scripts/check_bad_style.sh | 2 | ||||
-rw-r--r-- | src/graph/Graph.cpp | 10 | ||||
-rw-r--r-- | tests/SConscript | 2 |
14 files changed, 55 insertions, 85 deletions
diff --git a/SConscript b/SConscript index 17220e4c29..b40b66caab 100644 --- a/SConscript +++ b/SConscript @@ -125,6 +125,8 @@ def create_version_file(target, source, env): arm_compute_env = env.Clone() +# Don't allow undefined references in the libraries: +arm_compute_env.Append(LINKFLAGS=['-Wl,--no-undefined','-Wl,--no-allow-shlib-undefined']) generate_embed = [ arm_compute_env.Command("src/core/arm_compute_version.embed", "", action=create_version_file) ] arm_compute_env.Append(CPPPATH =[Dir("./src/core/").path] ) @@ -232,16 +234,17 @@ if env['neon'] and env['opencl']: shared_graph_objects = [arm_compute_env.SharedObject(f) for f in graph_files] static_graph_objects = [arm_compute_env.StaticObject(f) for f in graph_files] - arm_compute_graph_a = build_library('arm_compute_graph-static', static_graph_objects, static=True, libs = [ arm_compute_a ]) - Export('arm_compute_graph_a') + #FIXME OpenCL can't be linked statically: revisit when we can have a NEON only build of the graph library + #arm_compute_graph_a = build_library('arm_compute_graph-static', static_graph_objects, static=True, libs = [ arm_compute_a ]) + #Export('arm_compute_graph_a') arm_compute_env.Append(LIBPATH = ["#build/%s/opencl-1.2-stubs" % env['build_dir']]) arm_compute_graph_so = build_library('arm_compute_graph', shared_graph_objects, static=False, libs = [ "arm_compute", "arm_compute_core", "OpenCL" ]) - Depends(arm_compute_graph_so, arm_compute_so) - Depends(arm_compute_graph_so, opencl) + Depends(arm_compute_graph_so, [ arm_compute_so, opencl]) Export('arm_compute_graph_so') - graph_alias = arm_compute_env.Alias("arm_compute_graph", [arm_compute_graph_a, arm_compute_graph_so]) + #graph_alias = arm_compute_env.Alias("arm_compute_graph", [arm_compute_graph_a, arm_compute_graph_so]) + graph_alias = arm_compute_env.Alias("arm_compute_graph", [arm_compute_graph_so]) Default(graph_alias) if env['standalone']: diff --git a/SConstruct b/SConstruct index dffe4975b3..6f4835828a 100644 --- a/SConstruct +++ b/SConstruct @@ -85,6 +85,7 @@ env.Append(CXXFLAGS = ['-Wno-deprecated-declarations','-Wall','-DARCH_ARM', '-Winit-self','-Wstrict-overflow=2','-Wswitch-default', '-fpermissive','-std=gnu++11','-Wno-vla','-Woverloaded-virtual', '-Wctor-dtor-privacy','-Wsign-promo','-Weffc++','-Wno-format-nonliteral','-Wno-overlength-strings','-Wno-strict-overflow']) + env.Append(CPPDEFINES = ['_GLIBCXX_USE_NANOSLEEP']) if os.environ.get('CXX', 'g++') == 'clang++': @@ -185,7 +186,7 @@ if env['Werror']: if env['os'] == 'android': env.Append(CPPDEFINES = ['ANDROID']) - env.Append(LINKFLAGS = ['-pie', '-static-libstdc++']) + env.Append(LINKFLAGS = ['-pie']) elif env['os'] == 'bare_metal': env.Append(LINKFLAGS = ['-static']) env.Append(LINKFLAGS = ['-specs=rdimon.specs']) diff --git a/arm_compute/graph/Graph.h b/arm_compute/graph/Graph.h index 4afe96b40b..ab1d8b8866 100644 --- a/arm_compute/graph/Graph.h +++ b/arm_compute/graph/Graph.h @@ -67,6 +67,9 @@ public: * @param[in] tensor Tensor to add */ void add_tensor_object(std::unique_ptr<ITensorObject> tensor); + /** Finalizes the current node's configuration + */ + static bool opencl_is_available(); /** Manually sets the output of the current node * * @param[in] tmp Output info to set diff --git a/docs/00_introduction.dox b/docs/00_introduction.dox index 696364373d..b5a1d59f6a 100644 --- a/docs/00_introduction.dox +++ b/docs/00_introduction.dox @@ -514,11 +514,12 @@ To cross compile the examples with the Graph API, such as graph_lenet.cpp, you n i.e. to cross compile the "graph_lenet" example for Linux 32bit: - arm-linux-gnueabihf-g++ examples/graph_lenet.cpp utils/Utils.cpp utils/GraphUtils.cpp -I. -Iinclude -std=c++11 -mfpu=neon -L. -larm_compute_graph -larm_compute -larm_compute_core -lOpenCL -o graph_lenet -DARM_COMPUTE_CL + arm-linux-gnueabihf-g++ examples/graph_lenet.cpp utils/Utils.cpp utils/GraphUtils.cpp -I. -Iinclude -std=c++11 -mfpu=neon -L. -larm_compute_graph -larm_compute -larm_compute_core -Wl,--allow-shlib-undefined + -o graph_lenet i.e. to cross compile the "graph_lenet" example for Linux 64bit: - aarch64-linux-gnu-g++ examples/graph_lenet.cpp utils/Utils.cpp utils/GraphUtils.cpp -I. -Iinclude -std=c++11 -L. -larm_compute_graph -larm_compute -larm_compute_core -lOpenCL -o graph_lenet -DARM_COMPUTE_CL + aarch64-linux-gnu-g++ examples/graph_lenet.cpp utils/Utils.cpp utils/GraphUtils.cpp -I. -Iinclude -std=c++11 -L. -larm_compute_graph -larm_compute -larm_compute_core -Wl,--allow-shlib-undefined -o graph_lenet (notice the only difference with the 32 bit command is that we don't need the -mfpu option and the compiler's name is different) @@ -543,11 +544,11 @@ To compile natively (i.e directly on an ARM device) the examples with the Graph i.e. to cross compile the "graph_lenet" example for Linux 32bit: - g++ examples/graph_lenet.cpp utils/Utils.cpp utils/GraphUtils.cpp -I. -Iinclude -std=c++11 -mfpu=neon -L. -larm_compute_graph -larm_compute -larm_compute_core -lOpenCL -o graph_lenet -DARM_COMPUTE_CL + g++ examples/graph_lenet.cpp utils/Utils.cpp utils/GraphUtils.cpp -I. -Iinclude -std=c++11 -mfpu=neon -L. -larm_compute_graph -larm_compute -larm_compute_core -Wl,--allow-shlib-undefined -o graph_lenet i.e. to cross compile the "graph_lenet" example for Linux 64bit: - g++ examples/graph_lenet.cpp utils/Utils.cpp utils/GraphUtils.cpp -I. -Iinclude -std=c++11 L. -larm_compute_graph -larm_compute -larm_compute_core -lOpenCL -o graph_lenet -DARM_COMPUTE_CL + g++ examples/graph_lenet.cpp utils/Utils.cpp utils/GraphUtils.cpp -I. -Iinclude -std=c++11 L. -larm_compute_graph -larm_compute -larm_compute_core -Wl,--allow-shlib-undefined -o graph_lenet (notice the only difference with the 32 bit command is that we don't need the -mfpu option) @@ -608,24 +609,24 @@ Once you've got your Android standalone toolchain built and added to your path y To cross compile a NEON example: #32 bit: - arm-linux-androideabi-clang++ examples/neon_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -larm_compute-static -larm_compute_core-static -L. -o neon_convolution_arm -static-libstdc++ -pie + arm-linux-androideabi-clang++ examples/neon_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -larm_compute -larm_compute_core -L. -o neon_convolution_arm -pie #64 bit: - aarch64-linux-android-g++ examples/neon_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -larm_compute-static -larm_compute_core-static -L. -o neon_convolution_aarch64 -static-libstdc++ -pie + aarch64-linux-android-g++ examples/neon_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -larm_compute -larm_compute_core -L. -o neon_convolution_aarch64 -pie To cross compile an OpenCL example: #32 bit: - arm-linux-androideabi-clang++ examples/cl_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -larm_compute-static -larm_compute_core-static -L. -o cl_convolution_arm -static-libstdc++ -pie -lOpenCL -DARM_COMPUTE_CL + arm-linux-androideabi-clang++ examples/cl_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -larm_compute -larm_compute_core -L. -o cl_convolution_arm -pie -lOpenCL -DARM_COMPUTE_CL #64 bit: - aarch64-linux-android-g++ examples/cl_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -larm_compute-static -larm_compute_core-static -L. -o cl_convolution_aarch64 -static-libstdc++ -pie -lOpenCL -DARM_COMPUTE_CL + aarch64-linux-android-g++ examples/cl_convolution.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -larm_compute -larm_compute_core -L. -o cl_convolution_aarch64 -pie -lOpenCL -DARM_COMPUTE_CL To cross compile the examples with the Graph API, such as graph_lenet.cpp, you need to link the library arm_compute_graph also. (notice the compute library has to be built with both neon and opencl enabled - neon=1 and opencl=1) #32 bit: - arm-linux-androideabi-clang++ examples/graph_lenet.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -larm_compute_graph-static -larm_compute-static -larm_compute_core-static -L. -o graph_lenet_arm -static-libstdc++ -pie -lOpenCL -DARM_COMPUTE_CL + arm-linux-androideabi-clang++ examples/graph_lenet.cpp utils/Utils.cpp utils/GraphUtils.cpp -I. -Iinclude -std=c++11 -larm_compute_graph -larm_compute -larm_compute_core -L. -o graph_lenet_arm -pie -Wl,--allow-shlib-undefined #64 bit: - aarch64-linux-android-g++ examples/graph_lenet.cpp utils/Utils.cpp -I. -Iinclude -std=c++11 -larm_compute_graph-static -larm_compute-static -larm_compute_core-static -L. -o graph_lenet_aarch64 -static-libstdc++ -pie -lOpenCL -DARM_COMPUTE_CL + aarch64-linux-android-g++ examples/graph_lenet.cpp utils/Utils.cpp utils/GraphUtils.cpp -I. -Iinclude -std=c++11 -larm_compute_graph -larm_compute -larm_compute_core -L. -o graph_lenet_aarch64 -pie -Wl,--allow-shlib-undefined @note Due to some issues in older versions of the Mali OpenCL DDK (<= r13p0), we recommend to link arm_compute statically on Android. diff --git a/examples/SConscript b/examples/SConscript index 90b271d473..e002d11edd 100644 --- a/examples/SConscript +++ b/examples/SConscript @@ -42,7 +42,7 @@ if env['gles_compute'] and env['os'] != 'android': # Build examples utils = examples_env.Object("../utils/Utils.cpp") -if env['os'] in ['android', 'bare_metal'] or env['standalone']: +if env['os'] in ['bare_metal'] or env['standalone']: Import('arm_compute_a') Import('arm_compute_core_a') arm_compute_libs = [ arm_compute_a, arm_compute_core_a ] @@ -59,22 +59,16 @@ if env['opencl'] and env['neon']: Depends(prog, [arm_compute_dependency, opencl]) alias = examples_env.Alias(example, prog) Default(alias) - if env['os'] == 'android': - Import('arm_compute_graph_a') - Import('arm_compute_core_a') - Import('arm_compute_a') - arm_compute_graph_libs = [ arm_compute_graph_a, arm_compute_a, arm_compute_core_a] - graph_dependency = arm_compute_graph_a - else: - Import('arm_compute_graph_so') - arm_compute_graph_libs = ["arm_compute_graph", "arm_compute", "arm_compute_core"] - graph_dependency = arm_compute_graph_so + Import('arm_compute_graph_so') + arm_compute_graph_libs = ["arm_compute_graph", "arm_compute", "arm_compute_core"] + graph_dependency = arm_compute_graph_so 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 = examples_env.Program(example, ["{}.cpp".format(example), utils, graph_utils], CPPDEFINES=['ARM_COMPUTE_CL'], LIBS = arm_compute_graph_libs + ["OpenCL"]) - Depends(prog, [graph_dependency, opencl]) + #-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) diff --git a/examples/graph_alexnet.cpp b/examples/graph_alexnet.cpp index b2a5be647f..2d2ba6bb11 100644 --- a/examples/graph_alexnet.cpp +++ b/examples/graph_alexnet.cpp @@ -21,15 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef ARM_COMPUTE_CL /* Needed by Utils.cpp to handle OpenCL exceptions properly */ -#error "This example needs to be built with -DARM_COMPUTE_CL" -#endif /* ARM_COMPUTE_CL */ #include "arm_compute/graph/Graph.h" #include "arm_compute/graph/Nodes.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "arm_compute/runtime/CPP/CPPScheduler.h" -#include "arm_compute/runtime/Scheduler.h" #include "support/ToolchainSupport.h" #include "utils/GraphUtils.h" #include "utils/Utils.h" @@ -40,7 +34,6 @@ using namespace arm_compute::graph; using namespace arm_compute::graph_utils; -using namespace arm_compute::logging; /** Example demonstrating how to implement AlexNet's network using the Compute Library's graph API * @@ -86,9 +79,8 @@ void main_graph_alexnet(int argc, const char **argv) // Check if OpenCL is available and initialize the scheduler TargetHint hint = TargetHint::NEON; - if(arm_compute::opencl_is_available()) + if(Graph::opencl_is_available()) { - arm_compute::CLScheduler::get().default_init(); hint = TargetHint::OPENCL; } diff --git a/examples/graph_googlenet.cpp b/examples/graph_googlenet.cpp index 354a2a39e4..e116633a02 100644 --- a/examples/graph_googlenet.cpp +++ b/examples/graph_googlenet.cpp @@ -21,22 +21,15 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef ARM_COMPUTE_CL /* Needed by Utils.cpp to handle OpenCL exceptions properly */ -#error "This example needs to be built with -DARM_COMPUTE_CL" -#endif /* ARM_COMPUTE_CL */ #include "arm_compute/graph/Graph.h" #include "arm_compute/graph/Nodes.h" #include "arm_compute/graph/SubGraph.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "arm_compute/runtime/Scheduler.h" #include "support/ToolchainSupport.h" #include "utils/GraphUtils.h" #include "utils/Utils.h" #include <cstdlib> -#include <iostream> -#include <memory> #include <tuple> using namespace arm_compute::graph; @@ -141,14 +134,15 @@ void main_graph_googlenet(int argc, const char **argv) } // Check if OpenCL is available and initialize the scheduler - if(arm_compute::opencl_is_available()) + TargetHint hint = TargetHint::NEON; + if(Graph::opencl_is_available()) { - arm_compute::CLScheduler::get().default_init(); + hint = TargetHint::OPENCL; } Graph graph; - graph << TargetHint::OPENCL + graph << hint << Tensor(TensorInfo(TensorShape(224U, 224U, 3U, 1U), 1, DataType::F32), get_input_accessor(image, mean_r, mean_g, mean_b)) << ConvolutionLayer( diff --git a/examples/graph_lenet.cpp b/examples/graph_lenet.cpp index 53b32d9ab4..f6af14c4cf 100644 --- a/examples/graph_lenet.cpp +++ b/examples/graph_lenet.cpp @@ -21,25 +21,17 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef ARM_COMPUTE_CL /* Needed by Utils.cpp to handle OpenCL exceptions properly */ -#error "This example needs to be built with -DARM_COMPUTE_CL" -#endif /* ARM_COMPUTE_CL */ #include "arm_compute/graph/Graph.h" #include "arm_compute/graph/Nodes.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "arm_compute/runtime/Scheduler.h" #include "support/ToolchainSupport.h" #include "utils/GraphUtils.h" #include "utils/Utils.h" #include <cstdlib> -#include <iostream> -#include <memory> using namespace arm_compute::graph; using namespace arm_compute::graph_utils; -using namespace arm_compute::logging; /** Generates appropriate accessor according to the specified path * @@ -95,9 +87,8 @@ void main_graph_lenet(int argc, const char **argv) // Check if OpenCL is available and initialize the scheduler TargetHint hint = TargetHint::NEON; - if(arm_compute::opencl_is_available()) + if(Graph::opencl_is_available()) { - arm_compute::CLScheduler::get().default_init(); hint = TargetHint::OPENCL; } diff --git a/examples/graph_squeezenet.cpp b/examples/graph_squeezenet.cpp index d38cec28c4..51c4de0ec1 100644 --- a/examples/graph_squeezenet.cpp +++ b/examples/graph_squeezenet.cpp @@ -21,22 +21,15 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef ARM_COMPUTE_CL /* Needed by Utils.cpp to handle OpenCL exceptions properly */ -#error "This example needs to be built with -DARM_COMPUTE_CL" -#endif /* ARM_COMPUTE_CL */ #include "arm_compute/graph/Graph.h" #include "arm_compute/graph/Nodes.h" #include "arm_compute/graph/SubGraph.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "arm_compute/runtime/Scheduler.h" #include "support/ToolchainSupport.h" #include "utils/GraphUtils.h" #include "utils/Utils.h" #include <cstdlib> -#include <iostream> -#include <memory> #include <tuple> using namespace arm_compute::graph; @@ -109,14 +102,15 @@ void main_graph_squeezenet(int argc, const char **argv) } // Check if OpenCL is available and initialize the scheduler - if(arm_compute::opencl_is_available()) + TargetHint hint = TargetHint::NEON; + if(Graph::opencl_is_available()) { - arm_compute::CLScheduler::get().default_init(); + hint = TargetHint::OPENCL; } Graph graph; - graph << TargetHint::OPENCL + graph << hint << Tensor(TensorInfo(TensorShape(224U, 224U, 3U, 1U), 1, DataType::F32), get_input_accessor(image, mean_r, mean_g, mean_b)) << ConvolutionLayer( diff --git a/examples/graph_vgg16.cpp b/examples/graph_vgg16.cpp index ba59503161..44dd1f63e4 100644 --- a/examples/graph_vgg16.cpp +++ b/examples/graph_vgg16.cpp @@ -21,13 +21,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef ARM_COMPUTE_CL /* Needed by Utils.cpp to handle OpenCL exceptions properly */ -#error "This example needs to be built with -DARM_COMPUTE_CL" -#endif /* ARM_COMPUTE_CL */ - #include "arm_compute/graph/Graph.h" #include "arm_compute/graph/Nodes.h" -#include "arm_compute/runtime/CL/CLScheduler.h" #include "support/ToolchainSupport.h" #include "utils/GraphUtils.h" #include "utils/Utils.h" @@ -81,9 +76,8 @@ void main_graph_vgg16(int argc, const char **argv) // Check if OpenCL is available and initialize the scheduler TargetHint hint = TargetHint::NEON; - if(arm_compute::opencl_is_available()) + if(Graph::opencl_is_available()) { - arm_compute::CLScheduler::get().default_init(); hint = TargetHint::OPENCL; } diff --git a/examples/graph_vgg19.cpp b/examples/graph_vgg19.cpp index 74cb65ab69..61bb9a5190 100644 --- a/examples/graph_vgg19.cpp +++ b/examples/graph_vgg19.cpp @@ -21,14 +21,9 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#ifndef ARM_COMPUTE_CL /* Needed by Utils.cpp to handle OpenCL exceptions properly */ -#error "This example needs to be built with -DARM_COMPUTE_CL" -#endif /* ARM_COMPUTE_CL */ #include "arm_compute/graph/Graph.h" #include "arm_compute/graph/Nodes.h" -#include "arm_compute/runtime/CL/CLScheduler.h" -#include "arm_compute/runtime/Scheduler.h" #include "support/ToolchainSupport.h" #include "utils/GraphUtils.h" #include "utils/Utils.h" @@ -37,7 +32,6 @@ using namespace arm_compute::graph; using namespace arm_compute::graph_utils; -using namespace arm_compute::logging; /** Example demonstrating how to implement VGG19's network using the Compute Library's graph API * @@ -83,9 +77,8 @@ void main_graph_vgg19(int argc, const char **argv) // Check if OpenCL is available and initialize the scheduler TargetHint hint = TargetHint::NEON; - if(arm_compute::opencl_is_available()) + if(Graph::opencl_is_available()) { - arm_compute::CLScheduler::get().default_init(); hint = TargetHint::OPENCL; } diff --git a/scripts/check_bad_style.sh b/scripts/check_bad_style.sh index cd6e9042c0..e7f6f1af54 100755 --- a/scripts/check_bad_style.sh +++ b/scripts/check_bad_style.sh @@ -45,7 +45,7 @@ then exit -1 fi -grep -Hnir --exclude-dir=assembly "#.*defined[^(]" $DIRECTORIES | tee bad_style.log +grep -Hnir --exclude-dir=assembly "#.*if.*defined[^(]" $DIRECTORIES | tee bad_style.log if [[ $(cat bad_style.log | wc -l) > 0 ]] then echo "" diff --git a/src/graph/Graph.cpp b/src/graph/Graph.cpp index b86330b658..ac5316f55e 100644 --- a/src/graph/Graph.cpp +++ b/src/graph/Graph.cpp @@ -28,6 +28,7 @@ #include "arm_compute/graph/INode.h" #include "arm_compute/graph/ITensorObject.h" #include "arm_compute/graph/Tensor.h" +#include "arm_compute/runtime/CL/CLScheduler.h" #include "arm_compute/runtime/CL/CLTensor.h" #include "arm_compute/runtime/Tensor.h" #include "support/ToolchainSupport.h" @@ -75,6 +76,11 @@ Graph::~Graph() //NOLINT Graph::Graph() : _pimpl{ new Private() } { + // Check if OpenCL is available and initialize the scheduler + if(opencl_is_available()) + { + arm_compute::CLScheduler::get().default_init(); + } } void Graph::run() @@ -209,6 +215,10 @@ void Graph::add_tensor_object(std::unique_ptr<ITensorObject> tensor) _pimpl->_graph_output->allocate(); } } +bool Graph::opencl_is_available() +{ + return arm_compute::opencl_is_available(); +} void Graph::set_temp(TensorInfo &&tmp) { diff --git a/tests/SConscript b/tests/SConscript index 567ac4328e..3a6422d87b 100644 --- a/tests/SConscript +++ b/tests/SConscript @@ -50,7 +50,7 @@ vars.Update(test_env) Help(new_options.GenerateHelpText(test_env)) -if env['os'] in ['android', 'bare_metal'] or env['standalone']: +if env['os'] in ['bare_metal'] or env['standalone']: Import("arm_compute_a") Import("arm_compute_core_a") test_env.Append(LIBS = [arm_compute_a, arm_compute_core_a]) |