summaryrefslogtreecommitdiff
path: root/src/utils/TorchUtils.h
blob: 6c8b6c4f6a61982b6d7d694808126c9d475e398f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#pragma once

#include <string>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>

namespace Torch {
template< typename T >
std::string to_hex(T number, const bool append0x = true) {
    std::stringstream stream;
    if(append0x) {
        stream << "0x";
    }
    stream << std::setfill ('0') << std::setw(sizeof(T)*2)
           << std::hex << number;

    auto format = stream.str();
    std::transform(format.begin(), format.end(), format.begin(), ::toupper);
    return format;
}

uint32_t translate(uint32_t offset);
};