diff options
author | sf-wind <sf_wind@hotmail.com> | 2018-02-20 14:45:53 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-20 14:45:53 -0800 |
commit | 0074dc7fa8bcada785c26e3379369d8855ceb1e1 (patch) | |
tree | c9426dbb88ffa1c130260691f9cceeccbe222e4e | |
parent | cc7e61c88d8250c31bd5cd4897323335bc550d3a (diff) | |
download | pytorch-0074dc7fa8bcada785c26e3379369d8855ceb1e1.tar.gz pytorch-0074dc7fa8bcada785c26e3379369d8855ceb1e1.tar.bz2 pytorch-0074dc7fa8bcada785c26e3379369d8855ceb1e1.zip |
Allow more backends in caffe2_benchmark (#1979)
* Remove OpenGL code from benchmark
* Make it possible to print plot in the ipython notbook
* Create the blob if the blob is not specified in the init net
* Do not use gf library for MKL. Even after I install the entire MKL library it is still not found. After removing it, the MKL code can still run
* Support more backends in Caffe2 Benchmark
* Revert "Do not use gf library for MKL. Even after I install the entire MKL library it is still not found. After removing it, the MKL code can still run"
This reverts commit 981b6693a94cbf63ad78d51bd806c7a0d7a5a2d3.
* Build caffe2_benchmark using shared or static library depending on the flag
-rw-r--r-- | caffe2/share/contrib/binaries/caffe2_benchmark/CMakeLists.txt | 2 | ||||
-rw-r--r-- | caffe2/share/contrib/binaries/caffe2_benchmark/caffe2_benchmark.cc | 16 |
2 files changed, 10 insertions, 8 deletions
diff --git a/caffe2/share/contrib/binaries/caffe2_benchmark/CMakeLists.txt b/caffe2/share/contrib/binaries/caffe2_benchmark/CMakeLists.txt index 5cd451d741..254f07e698 100644 --- a/caffe2/share/contrib/binaries/caffe2_benchmark/CMakeLists.txt +++ b/caffe2/share/contrib/binaries/caffe2_benchmark/CMakeLists.txt @@ -1,6 +1,6 @@ set(__target "caffe2_benchmark") add_executable(${__target} "${CMAKE_CURRENT_SOURCE_DIR}/caffe2_benchmark.cc") add_dependencies(${__target} ${Caffe2_MAIN_LIBS_ORDER}) -caffe_add_whole_archive_flag(Caffe2_CPU_OBSERVER Caffe2_CPU_OBSERVER_LINK) +caffe_add_linker_flag(Caffe2_CPU_OBSERVER Caffe2_CPU_OBSERVER_LINK) target_link_libraries(${__target} ${Caffe2_CPU_OBSERVER_LINK} ${Caffe2_MAIN_LIBS} ${Caffe2_DEPENDENCY_LIBS}) install(TARGETS ${__target} DESTINATION bin) diff --git a/caffe2/share/contrib/binaries/caffe2_benchmark/caffe2_benchmark.cc b/caffe2/share/contrib/binaries/caffe2_benchmark/caffe2_benchmark.cc index eafb6b749d..c71d73499e 100644 --- a/caffe2/share/contrib/binaries/caffe2_benchmark/caffe2_benchmark.cc +++ b/caffe2/share/contrib/binaries/caffe2_benchmark/caffe2_benchmark.cc @@ -13,9 +13,9 @@ CAFFE2_DEFINE_string( backend, - "default", + "builtin", "The backend to use when running the model. The allowed " - "backend choices are: default, nnpack"); + "backend choices are: builtin, default, nnpack, eigen, mkl"); CAFFE2_DEFINE_string( init_net, "", @@ -172,14 +172,16 @@ int main(int argc, char** argv) { // Run main network. caffe2::NetDef net_def; CAFFE_ENFORCE(ReadProtoFromFile(caffe2::FLAGS_net, &net_def)); - if (caffe2::FLAGS_backend == "nnpack") { + if (caffe2::FLAGS_backend != "builtin") { + std::string engine = caffe2::FLAGS_backend == "nnpack" ? "NNPACK" : + caffe2::FLAGS_backend == "eigen" ? "EIGEN" : + caffe2::FLAGS_backend == "mkl" ? "MKLDNN" : + caffe2::FLAGS_backend == "default" ? "" : "NONE"; + CAFFE_ENFORCE(engine != "NONE", "Backend is not supported"); for (int i = 0; i < net_def.op_size(); i++) { caffe2::OperatorDef* op_def = net_def.mutable_op(i); - op_def->set_engine("NNPACK"); + op_def->set_engine(engine); } - } else { - CAFFE_ENFORCE( - caffe2::FLAGS_backend == "default", "Backend is not supported"); } caffe2::NetBase* net = workspace->CreateNet(net_def); |