diff --git a/.gitmodules b/.gitmodules index 7d0ca179974..74f38eae144 100644 --- a/.gitmodules +++ b/.gitmodules @@ -2,6 +2,3 @@ path = third_party/pybind11 url = https://github.com/pybind/pybind11.git branch = master -[submodule "third_party/benchmark"] - path = third_party/benchmark - url = https://github.com/google/benchmark.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d7ca846cf1..6550fc464f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,6 @@ cmake_policy(SET CMP0074 NEW) # Project project(onnx C CXX) -option(ONNX_BUILD_BENCHMARKS "Build ONNX micro-benchmarks" OFF) option(ONNX_USE_PROTOBUF_SHARED_LIBS "Build ONNX using protobuf shared library. Sets PROTOBUF_USE_DLLS CMAKE Flag and Protobuf_USE_STATIC_LIBS. " OFF) option(BUILD_ONNX_PYTHON "Build Python binaries" OFF) @@ -619,30 +618,6 @@ if(BUILD_ONNX_PYTHON) endif() endif() -if(ONNX_BUILD_BENCHMARKS) - if(NOT TARGET benchmark) - # We will not need to test benchmark lib itself. - set(BENCHMARK_ENABLE_TESTING OFF - CACHE BOOL "Disable benchmark testing as we don't need it.") - # We will not need to install benchmark since we link it statically. - set(BENCHMARK_ENABLE_INSTALL OFF - CACHE BOOL - "Disable benchmark install to avoid overwriting vendor install.") - find_package(benchmark) - if(NOT benchmark_FOUND) - add_subdirectory(${PROJECT_SOURCE_DIR}/third_party/benchmark) - endif() - endif() - - add_executable(protobuf-bench tools/protobuf-bench.cc) - target_include_directories(protobuf-bench PUBLIC - $ - $ - $ - $) - target_link_libraries(protobuf-bench onnx_proto benchmark::benchmark) -endif() - # Export include directories set(ONNX_INCLUDE_DIRS "${ONNX_ROOT}" "${CMAKE_CURRENT_BINARY_DIR}") get_directory_property(hasParent PARENT_DIRECTORY) @@ -742,7 +717,7 @@ if(ONNX_USE_UNITY_BUILD) # If ONNX_USE_UNITY_BUILD is set to ON, set onnx target to use Unity builds. # We set Unity build to use groups, it allows us to set some specific files to be compiled individually set_target_properties(onnx - PROPERTIES + PROPERTIES UNITY_BUILD ON UNITY_BUILD_MODE GROUP ) diff --git a/cmake/summary.cmake b/cmake/summary.cmake index 39f28466e85..fbe6b28a902 100644 --- a/cmake/summary.cmake +++ b/cmake/summary.cmake @@ -26,7 +26,6 @@ function (onnx_print_configuration_summary) message(STATUS " ONNX_DISABLE_STATIC_REGISTRATION : ${ONNX_DISABLE_STATIC_REGISTRATION}") message(STATUS " ONNX_WERROR : ${ONNX_WERROR}") message(STATUS " ONNX_BUILD_TESTS : ${ONNX_BUILD_TESTS}") - message(STATUS " ONNX_BUILD_BENCHMARKS : ${ONNX_BUILD_BENCHMARKS}") message(STATUS " ONNX_BUILD_SHARED_LIBS : ${ONNX_BUILD_SHARED_LIBS}") message(STATUS " BUILD_SHARED_LIBS : ${BUILD_SHARED_LIBS}") message(STATUS "") diff --git a/third_party/benchmark b/third_party/benchmark deleted file mode 160000 index 2dd015dfef4..00000000000 --- a/third_party/benchmark +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2dd015dfef425c866d9a43f2c67d8b52d709acb6 diff --git a/tools/protobuf-bench.cc b/tools/protobuf-bench.cc deleted file mode 100644 index 543a2cf65f1..00000000000 --- a/tools/protobuf-bench.cc +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) ONNX Project Contributors -// -// SPDX-License-Identifier: Apache-2.0 - -#include - -#include - -using namespace ONNX_NAMESPACE; - -inline void -createValueInfo4D(ValueInfoProto& value_info, const std::string& name, int64_t n, int64_t c, int64_t h, int64_t w) { - value_info.set_name(name); - - TypeProto_Tensor* tensor_type = value_info.mutable_type()->mutable_tensor_type(); - tensor_type->set_elem_type(TensorProto_DataType_FLOAT); - - TensorShapeProto* shape = tensor_type->mutable_shape(); - shape->add_dim()->set_dim_value(n); - shape->add_dim()->set_dim_value(c); - shape->add_dim()->set_dim_value(h); - shape->add_dim()->set_dim_value(w); -} - -inline void createValueInfo2D(ValueInfoProto& value_info, const std::string& name, int64_t h, int64_t w) { - value_info.set_name(name); - - TypeProto* type = value_info.mutable_type(); - - TypeProto_Tensor* tensor_type = type->mutable_tensor_type(); - tensor_type->set_elem_type(TensorProto_DataType_FLOAT); - TensorShapeProto* shape = tensor_type->mutable_shape(); - shape->add_dim()->set_dim_value(h); - shape->add_dim()->set_dim_value(w); -} - -inline void createConv2D( - NodeProto& node, - const std::string& input, - const std::string& weights, - const std::string& bias, - const std::string& output, - uint32_t kernel_size) { - node.set_op_type("Conv"); - node.add_input(input); - node.add_input(weights); - node.add_input(bias); - node.add_output(output); - - { - AttributeProto* kernel = node.add_attribute(); - kernel->set_name("kernel_shape"); - kernel->set_type(AttributeProto::INTS); - kernel->add_ints(kernel_size); - kernel->add_ints(kernel_size); - } - { - AttributeProto* dilation = node.add_attribute(); - dilation->set_name("dilations"); - dilation->set_type(AttributeProto::INTS); - dilation->add_ints(1); - dilation->add_ints(1); - } - { - AttributeProto* stride = node.add_attribute(); - stride->set_name("strides"); - stride->set_type(AttributeProto::INTS); - stride->add_ints(1); - stride->add_ints(1); - } - { - AttributeProto* group = node.add_attribute(); - group->set_name("group"); - group->set_type(AttributeProto::INTS); - group->set_i(1); - } - { - AttributeProto* padding = node.add_attribute(); - padding->set_name("pads"); - padding->set_type(AttributeProto::INTS); - /* Use "same" padding */ - padding->add_ints(kernel_size / 2); - padding->add_ints(kernel_size / 2); - padding->add_ints(kernel_size - 1 - kernel_size / 2); - padding->add_ints(kernel_size - 1 - kernel_size / 2); - } -} - -static void ConvGraph(benchmark::State& state) { - while (state.KeepRunning()) { - std::string data; - GraphProto graph; - - createConv2D(*graph.add_node(), "input", "weights", "bias", "output", 3); - - createValueInfo4D(*graph.add_input(), "input", 1, 3, 224, 224); - createValueInfo4D(*graph.add_input(), "weights", 16, 16, 3, 3); - createValueInfo2D(*graph.add_input(), "bias", 1, 16); - createValueInfo4D(*graph.add_output(), "output", 16, 3, 224, 224); - - graph.SerializeToString(&data); - - GraphProto decodedGraph; - decodedGraph.ParseFromString(data); - } - - state.SetItemsProcessed(int64_t(state.iterations())); -} -BENCHMARK(ConvGraph)->Unit(benchmark::kMicrosecond); - -static void ConvModel(benchmark::State& state) { - while (state.KeepRunning()) { - std::string data; - ModelProto model; - model.set_ir_version(IR_VERSION); - OperatorSetIdProto* op_set_id = model.add_opset_import(); - op_set_id->set_domain(""); - op_set_id->set_version(4); - - GraphProto* graph = model.mutable_graph(); - - createConv2D(*graph->add_node(), "input", "weights", "bias", "output", 3); - - createValueInfo4D(*graph->add_input(), "input", 1, 3, 224, 224); - createValueInfo4D(*graph->add_input(), "weights", 16, 16, 3, 3); - createValueInfo2D(*graph->add_input(), "bias", 1, 16); - createValueInfo4D(*graph->add_output(), "output", 16, 3, 224, 224); - - model.SerializeToString(&data); - - ModelProto decodedModel; - decodedModel.ParseFromString(data); - } - - state.SetItemsProcessed(int64_t(state.iterations())); -} -BENCHMARK(ConvModel)->Unit(benchmark::kMicrosecond); - -BENCHMARK_MAIN();