Skip to content

Commit

Permalink
Fix tensor loop iteration in examples (fixes #57)
Browse files Browse the repository at this point in the history
  • Loading branch information
wjakob committed Aug 23, 2022
1 parent 7842f2b commit b90a6c5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/tensor.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ stored contiguously in CPU memory using a C-style array ordering convention.
m.def("process", [](nb::tensor<uint8_t, nb::shape<nb::any, nb::any, 3>, nb::c_contig, nb::device::cpu> tensor) {
// Double brightness of the MxNx3 RGB image
for (size_t y = 0; y < tensor.shape(0); ++y)
for (size_t x = 0; y < tensor.shape(1); ++x)
for (size_t x = 0; x < tensor.shape(1); ++x)
for (size_t ch = 0; ch < 3; ++ch)
tensor(y, x, ch) = (uint8_t) std::min(255, tensor(y, x, ch) * 2);

Expand Down
2 changes: 1 addition & 1 deletion tests/test_tensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ NB_MODULE(test_tensor_ext, m) {
nb::c_contig, nb::device::cpu> tensor) {
// Double brightness of the MxNx3 RGB image
for (size_t y = 0; y < tensor.shape(0); ++y)
for (size_t x = 0; y < tensor.shape(1); ++x)
for (size_t x = 0; x < tensor.shape(1); ++x)
for (size_t ch = 0; ch < 3; ++ch)
tensor(y, x, ch) = (uint8_t) std::min(255, tensor(y, x, ch) * 2);

Expand Down

0 comments on commit b90a6c5

Please sign in to comment.