Skip to content
This repository was archived by the owner on Sep 1, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .bazelrc
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions bazel/repositories.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions tensorrt-laboratory/core/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ cc_library(
),
deps = [
"@com_google_glog//:glog",
"@com_github_dcdillon_cpuaff//:cpuaff"
],
strip_include_prefix = "include",
visibility = ["//visibility:public"],
Expand Down
9 changes: 5 additions & 4 deletions tensorrt-laboratory/core/src/utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include <regex>
#include <stdio.h>
#include <cmath>

#include <glog/logging.h>

Expand All @@ -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);
}

Expand All @@ -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