#include "env.h"
-#include "util/vector/Object.h"
#include "util/feature/IndexIterator.h"
#include "util/feature/Object.h"
#include "util/feature/Reader.h"
-#include "util/kernel/RandomObject.h"
#include "util/fp32.h"
#include "util/environment.h"
};
const nnfw::util::feature::Shape ifm_shape{IFM_C, IFM_H, IFM_W};
const nnfw::util::feature::Object<float> ifm{ifm_shape, ifm_gen};
- const nnfw::util::kernel::RandomObject<float> kernel{nnfw::util::kernel::Shape{KER_N, KER_C, KER_H, KER_W}};
- const nnfw::util::vector::Object<float> bias{KER_N, [] (uint32_t, uint32_t) { return 0.0f; }};
std::cout << "Configurations:" << std::endl;
#define PRINT_NEWLINE() { std::cout << std::endl; }
const uint32_t kernel_size = KER_N * KER_C * KER_H * KER_W;
float kernel_data[kernel_size] = { 0.0f, };
- // Fill kernel data in NHWC order
+ // Fill kernel data with random data
{
- uint32_t off = 0;
+ std::normal_distribution<float> kernel_dist(-1.0f, +1.0f);
- for (uint32_t nth = 0; nth < KER_N; ++nth)
+ for (uint32_t off = 0; off < kernel_size; ++off)
{
- for (uint32_t row = 0; row < KER_H; ++row)
- {
- for (uint32_t col = 0; col < KER_W; ++col)
- {
- for (uint32_t ch = 0; ch < KER_C; ++ch)
- {
- const auto value = kernel.at(nth, ch, row, col);
- kernel_data[off++] = value;
- }
- }
- }
+ kernel_data[off++] = kernel_dist(random);
}
-
- assert(kernel_size == off);
}
// Configure Bias Data
- const uint32_t bias_size = bias.size();
+ const auto bias_size = KER_N;
float bias_data[bias_size] = { 0.0f, };
- // Fill bias data
- for (uint32_t off = 0; off < bias.size(); ++off)
+ // Fill bias data with random data
{
- bias_data[off] = bias.at(off);
+ std::normal_distribution<float> bias_dist(-1.0f, +1.0f);
+
+ for (uint32_t off = 0; off < bias_size; ++off)
+ {
+ bias_data[off] = bias_dist(random);
+ }
}
// Assumption on this example
assert(IFM_C == KER_C);
- assert(KER_N == bias.size());
auto setup = [&](Interpreter &interp)
{
interp.SetTensorParametersReadOnly(3,
kTfLiteFloat32 /* type */,
"bias" /* name */,
- { bias.size() } /* dims */,
+ { bias_size } /* dims */,
quantization,
reinterpret_cast<const char *>(bias_data), bias_size * sizeof(float));