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..1aac2dd 100644 --- a/bazel/repositories.bzl +++ b/bazel/repositories.bzl @@ -54,6 +54,30 @@ 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","include/**/*.h", + ]), + hdrs = glob([ + "include/**/*.hpp","include/**/*.h", + ]), + #hdrs = ["include/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"], diff --git a/tensorrt-laboratory/core/src/utils.cc b/tensorrt-laboratory/core/src/utils.cc index 4cbf063..c5cabf4 100644 --- a/tensorrt-laboratory/core/src/utils.cc +++ b/tensorrt-laboratory/core/src/utils.cc @@ -28,6 +28,7 @@ #include #include +#include #include @@ -44,13 +45,13 @@ 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); } - 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); } @@ -70,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