#include <nnkit/Action.h>
-#include <nncc/core/ADT/tensor/IndexRange.h>
+#include <nncc/core/ADT/tensor/IndexEnumerator.h>
#include <nncc/core/ADT/tensor/LexicalLayout.h>
#include <H5Cpp.h>
float *data = new float[nncc::core::ADT::tensor::num_elements(shape)];
- using nncc::core::ADT::tensor::range;
using nncc::core::ADT::tensor::Index;
+ using nncc::core::ADT::tensor::IndexEnumerator;
using nncc::core::ADT::tensor::LexicalLayout;
LexicalLayout layout{};
- range(shape).iterate() << [data, &t, &shape, &layout](const Index &i) {
+ for (IndexEnumerator e{shape}; e.valid(); e.advance())
+ {
+ auto i = e.current();
data[layout.offset(shape, i)] = t.at(i);
- };
+ }
dataset.write(data, H5::PredType::NATIVE_FLOAT);
#include <nnkit/Action.h>
-#include <nncc/core/ADT/tensor/IndexRange.h>
+#include <nncc/core/ADT/tensor/IndexEnumerator.h>
#include <nncc/core/ADT/tensor/LexicalLayout.h>
#include <H5Cpp.h>
dataset.read(buffer.data(), H5::PredType::NATIVE_FLOAT);
- using nncc::core::ADT::tensor::range;
using nncc::core::ADT::tensor::Index;
+ using nncc::core::ADT::tensor::IndexEnumerator;
using nncc::core::ADT::tensor::LexicalLayout;
LexicalLayout layout{};
- range(shape).iterate() << [&buffer, &t, &shape, &layout](const Index &i) {
+ for (IndexEnumerator e{shape}; e.valid(); e.advance())
+ {
+ auto i = e.current();
t.at(i) = buffer[layout.offset(shape, i)];
- };
+ }
};
try
#include <nnkit/Action.h>
-#include <nncc/core/ADT/tensor/IndexRange.h>
+#include <nncc/core/ADT/tensor/IndexEnumerator.h>
#include <chrono>
#include <random>
using nncc::core::ADT::tensor::Accessor;
auto fn = [&dist, &rand](const TensorContext &ctx, uint32_t n, Accessor<float> &t) {
- using nncc::core::ADT::tensor::range;
using nncc::core::ADT::tensor::Index;
+ using nncc::core::ADT::tensor::IndexEnumerator;
- range(ctx.shape(n)).iterate()
- << [&t, &dist, &rand](const Index &i) { t.at(i) = dist(rand); };
+ for (IndexEnumerator e{ctx.shape(n)}; e.valid(); e.advance())
+ {
+ t.at(e.current()) = dist(rand);
+ }
};
ctx.getMutableFloatTensor(n, fn);