forked from dmlc/mshadow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dbstr.h
35 lines (32 loc) · 838 Bytes
/
dbstr.h
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
26
27
28
29
30
31
32
33
34
35
#pragma once
#include <mshadow/tensor.h>
#include <sstream>
template<typename DType>
std::string dbstr(mshadow::Tensor<mshadow::cpu, 1, DType> ts) {
std::stringstream ss;
for (mshadow::index_t i = 0; i < ts.size(0); ++i)
ss << ts[i] << " ";
ss << "\n";
return ss.str();
}
template<typename DType>
std::string dbstr(mshadow::Tensor<mshadow::cpu, 2, DType> ts) {
std::stringstream ss;
for (mshadow::index_t i = 0; i < ts.size(0); ++i) {
for (mshadow::index_t j = 0; j < ts.size(1); ++j) {
ss << ts[i][j] << " ";
}
ss << "\n";
}
ss << "\n";
return ss.str();
}
template<typename DType>
std::string dbstr(mshadow::Tensor<mshadow::cpu, 3, DType> ts) {
std::stringstream ss;
for (mshadow::index_t i = 0; i < ts.size(0); ++i) {
ss << dbstr(ts[i]) << "\n";
}
ss << "\n";
return ss.str();
}