GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — serial_size_t -> size_t in Tensor class (#422) · tiny-dnn/tiny-dnn@34305b6

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test
    • test_tensor.h
  • tiny_dnn/core/framework
    • tensor.h
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/test_tensor.h‎

Copy file name to clipboardExpand all lines: test/test_tensor.h
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ TEST(tensor, check_bounds) {
130130
TEST(tensor, access_data1) {
131131
Tensor<float_t> tensor(1,2,2,1);
132132

133-
const std::array<serial_size_t, 4>& shape = tensor.shape();
133+
const std::array<size_t, 4>& shape = tensor.shape();
134134

135135
for (serial_size_t n = 0; n < shape[0]; ++n) {
136136
for (serial_size_t w = 0; w < shape[1]; ++w) {
Collapse file

‎tiny_dnn/core/framework/tensor.h‎

Copy file name to clipboardExpand all lines: tiny_dnn/core/framework/tensor.h
+29-30Lines changed: 29 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -83,18 +83,18 @@ class Tensor {
8383
*
8484
* Data will be hold by a std::vector with 64bytes alignment.
8585
*/
86-
explicit Tensor(const serial_size_t d0,
87-
const serial_size_t d1,
88-
const serial_size_t d2,
89-
const serial_size_t d3) {
86+
explicit Tensor(const size_t d0,
87+
const size_t d1,
88+
const size_t d2,
89+
const size_t d3) {
9090
reshape(d0, d1, d2, d3);
9191
}
9292

93-
explicit Tensor(const std::array<serial_size_t, 4>& shape) {
93+
explicit Tensor(const std::array<size_t, 4>& shape) {
9494
reshape(shape[0], shape[1], shape[2], shape[3]);
9595
}
9696

97-
explicit Tensor(const std::vector<serial_size_t>& shape) {
97+
explicit Tensor(const std::vector<size_t>& shape) {
9898
assert(shape.size() == 4);
9999
reshape(shape[0], shape[1], shape[2], shape[3]);
100100
}
@@ -148,30 +148,30 @@ class Tensor {
148148
#endif
149149

150150
// Returns the tensor shape
151-
const std::array<serial_size_t, 4>& shape() const { return shape_; }
151+
const std::array<size_t, 4>& shape() const { return shape_; }
152152

153153
// Returns the value of a specified index in the tensor.
154154
// Checked version (throw exceptions for out-of-range error)
155-
U& host_at(const serial_size_t d0,
156-
const serial_size_t d1,
157-
const serial_size_t d2,
158-
const serial_size_t d3) {
155+
U& host_at(const size_t d0,
156+
const size_t d1,
157+
const size_t d2,
158+
const size_t d3) {
159159
return *host_ptr(d0, d1, d2, d3);
160160
}
161161

162-
U host_at(const serial_size_t d0,
163-
const serial_size_t d1,
164-
const serial_size_t d2,
165-
const serial_size_t d3) const {
162+
U host_at(const size_t d0,
163+
const size_t d1,
164+
const size_t d2,
165+
const size_t d3) const {
166166
return *host_ptr(d0, d1, d2, d3);
167167
}
168168

169169
// Returns the pointer to a specified index in the tensor
170170
// Checked version (throw exceptions for out-of-range error)
171-
const U* host_ptr(const serial_size_t d0,
172-
const serial_size_t d1,
173-
const serial_size_t d2,
174-
const serial_size_t d3) const {
171+
const U* host_ptr(const size_t d0,
172+
const size_t d1,
173+
const size_t d2,
174+
const size_t d3) const {
175175
if (d0 >= shape_[0] || d1 >= shape_[1] ||
176176
d2 >= shape_[2] || d3 >= shape_[3]) {
177177
throw nn_error("Access tensor out of range.");
@@ -185,10 +185,10 @@ class Tensor {
185185
);
186186
}
187187

188-
U* host_ptr(const serial_size_t d0,
189-
const serial_size_t d1,
190-
const serial_size_t d2,
191-
const serial_size_t d3) {
188+
U* host_ptr(const size_t d0,
189+
const size_t d1,
190+
const size_t d2,
191+
const size_t d3) {
192192
if (d0 >= shape_[0] || d1 >= shape_[1] ||
193193
d2 >= shape_[2] || d3 >= shape_[3]) {
194194
throw nn_error("Access tensor out of range.");
@@ -236,19 +236,18 @@ class Tensor {
236236
std::fill(std::begin(host_data_), std::end(host_data_), value);
237237
}
238238

239-
void reshape(const serial_size_t d0,
240-
const serial_size_t d1,
241-
const serial_size_t d2,
242-
const serial_size_t d3) {
239+
void reshape(const size_t d0,
240+
const size_t d1,
241+
const size_t d2,
242+
const size_t d3) {
243243
shape_[0] = d0;
244244
shape_[1] = d1;
245245
shape_[2] = d2;
246246
shape_[3] = d3;
247247
host_data_.resize(calcSize(), U(0));
248248
}
249249

250-
void reshape(const std::array<serial_size_t, 4> &sz)
251-
{
250+
void reshape(const std::array<size_t, 4> &sz) {
252251
shape_ = sz;
253252
host_data_.resize(calcSize(), U(0));
254253
}
@@ -295,7 +294,7 @@ class Tensor {
295294
* shape_[2]: height
296295
* shape_[3]: depth
297296
*/
298-
std::array<serial_size_t, 4> shape_;
297+
std::array<size_t, 4> shape_;
299298

300299
/* Pointer to the Tensor data in pure in the host device */
301300
std::vector<U, aligned_allocator<U, 64> > host_data_;

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.