Caffe2 - C++ API
A deep learning, cross platform ML framework
THTensorFill.cpp
1 #ifndef TH_GENERIC_FILE
2 #define TH_GENERIC_FILE "TH/generic/THTensorFill.cpp"
3 #else
4 
5 #include <TH/generic/THTensorApply.hpp>
6 
7 void THTensor_(fill)(THTensor *r_, scalar_t value)
8 {
9  if (THTensor_(isContiguous)(r_) || THTensor_(isTransposed)(r_)) {
10  TH_TENSOR_APPLY_CONTIG(scalar_t, r_, THVector_(fill)(r__data, value, r__len););
11  } else {
12  TH_TENSOR_APPLY(scalar_t, r_,
13  if (r__stride == 1) {
14  THVector_(fill)(r__data, value, r__size);
15  r__i = r__size;
16  r__data += r__stride * r__size;
17  break;
18  } else {
19  *r__data = value;
20  }
21  );
22  }
23 }
24 
25 void THTensor_(zero)(THTensor *r_)
26 {
27  THTensor_(fill)(r_, 0);
28 }
29 
30 #endif