From bb5f3ae33ac1eaea91606fcace6c20e23bfb09b9 Mon Sep 17 00:00:00 2001 From: Ryan Leary Date: Fri, 1 Nov 2019 13:19:11 -0400 Subject: [PATCH 1/5] WIP cpuaff change --- .bazelrc | 4 +--- bazel/repositories.bzl | 21 +++++++++++++++++++++ tensorrt-laboratory/core/BUILD.bazel | 1 + 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.bazelrc b/.bazelrc index baec95b..3752b72 100644 --- a/.bazelrc +++ b/.bazelrc @@ -1,3 +1 @@ -build --cxxopt=-std=c++1z -build --incompatible_remove_native_http_archive=false -build --incompatible_package_name_is_a_function=false +build --cxxopt=-std=c++1z \ No newline at end of file diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 973299c..787958c 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -54,6 +54,27 @@ def repositories(): ], ) + _maybe( + http_archive, + name = "com_github_dcdillon_cpuaff", + sha256 = "3be034ef633b1785c47fe21458e3577875abd24b520a7d8dd69b33183202d5fd", + strip_prefix = "cpuaff-a0ca467d6eaad865862b95d16279787b5d24493f", + urls = [ + "https://github.com/dcdillon/cpuaff/archive/a0ca467.zip", + ], + build_file_content = """ +cc_library( + name = "cpuaff", + srcs = glob([ + "include/**/*.hpp", + ]), + hdrs = ["cpuaff/cpuaff.hpp"], + strip_include_prefix = "include", + visibility = ["//visibility:public"], +) + """ + ) + def load_trtis(): http_archive( name = "com_github_nvidia_trtis", diff --git a/tensorrt-laboratory/core/BUILD.bazel b/tensorrt-laboratory/core/BUILD.bazel index 7756500..5fda7d2 100644 --- a/tensorrt-laboratory/core/BUILD.bazel +++ b/tensorrt-laboratory/core/BUILD.bazel @@ -9,6 +9,7 @@ cc_library( ), deps = [ "@com_google_glog//:glog", + "@com_github_dcdillon_cpuaff//:cpuaff" ], strip_include_prefix = "include", visibility = ["//visibility:public"], From 51325a1b4f9bf3219fb706d714b29c8be4f6f7a4 Mon Sep 17 00:00:00 2001 From: Ryan Leary Date: Fri, 1 Nov 2019 13:50:44 -0400 Subject: [PATCH 2/5] More wip --- bazel/repositories.bzl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bazel/repositories.bzl b/bazel/repositories.bzl index 787958c..1aac2dd 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -66,9 +66,12 @@ def repositories(): cc_library( name = "cpuaff", srcs = glob([ - "include/**/*.hpp", + "include/**/*.hpp","include/**/*.h", ]), - hdrs = ["cpuaff/cpuaff.hpp"], + hdrs = glob([ + "include/**/*.hpp","include/**/*.h", + ]), + #hdrs = ["include/cpuaff/cpuaff.hpp"], strip_include_prefix = "include", visibility = ["//visibility:public"], ) From 9268ee43c8f90e91f28f51bd3c55c197280738cc Mon Sep 17 00:00:00 2001 From: Ryan Leary Date: Fri, 1 Nov 2019 13:54:51 -0400 Subject: [PATCH 3/5] Add cmath --- tensorrt-laboratory/core/src/utils.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/tensorrt-laboratory/core/src/utils.cc b/tensorrt-laboratory/core/src/utils.cc index 4cbf063..4ce3269 100644 --- a/tensorrt-laboratory/core/src/utils.cc +++ b/tensorrt-laboratory/core/src/utils.cc @@ -28,6 +28,7 @@ #include #include +#include #include From 4b38e25bb88bb2ed923ec8f6e34a701e061fd8e9 Mon Sep 17 00:00:00 2001 From: Ryan Leary Date: Fri, 1 Nov 2019 13:58:26 -0400 Subject: [PATCH 4/5] Add std:: --- tensorrt-laboratory/core/src/utils.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tensorrt-laboratory/core/src/utils.cc b/tensorrt-laboratory/core/src/utils.cc index 4ce3269..193ceb2 100644 --- a/tensorrt-laboratory/core/src/utils.cc +++ b/tensorrt-laboratory/core/src/utils.cc @@ -50,8 +50,8 @@ std::string BytesToString(size_t bytes) sprintf(buffer, "%ld B", bytes); return std::string(buffer); } - int exp = (int)(log(bytes) / log(unit)); - sprintf(buffer, "%.1f %ciB", bytes / pow(unit, exp), prefixes[exp - 1]); + int exp = (int)(std::log(bytes) / std::log(unit)); + sprintf(buffer, "%.1f %ciB", bytes / std::pow(unit, exp), prefixes[exp - 1]); return std::string(buffer); } @@ -71,7 +71,7 @@ std::uint64_t StringToBytes(const std::string str) const std::uint64_t base = m.empty() || (m.size() > 3 && m[3] == "") ? 1000 : 1024; auto exponent = prefix[m[2].str()[0]]; auto scalar = std::stod(m[1]); - return (std::uint64_t)(scalar * pow(base, exponent)); + return (std::uint64_t)(scalar * std::pow(base, exponent)); } } // namespace trtlab \ No newline at end of file From 619b6038586b61a82eb8d65de02ecc3e60321f9b Mon Sep 17 00:00:00 2001 From: Ryan Leary Date: Fri, 1 Nov 2019 14:02:20 -0400 Subject: [PATCH 5/5] Add size_t cast --- tensorrt-laboratory/core/src/utils.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tensorrt-laboratory/core/src/utils.cc b/tensorrt-laboratory/core/src/utils.cc index 193ceb2..c5cabf4 100644 --- a/tensorrt-laboratory/core/src/utils.cc +++ b/tensorrt-laboratory/core/src/utils.cc @@ -45,7 +45,7 @@ std::string BytesToString(size_t bytes) char buffer[50]; int unit = 1024; const char prefixes[] = "KMGTPE"; - if(bytes < unit) + if(bytes < (size_t) unit) { sprintf(buffer, "%ld B", bytes); return std::string(buffer);