#include <stdexcept>
+#include <nncc/core/ADT/kernel/NHWCLayout.h>
+
namespace
{
auto ifm = _binder->addOperand<float>(unit->ifm());
auto ker = _binder->addOperand<float>(conv->ker());
- // TODO Fill kernel data
+ // Fill kernel data
+ {
+ auto obj = conv->ker();
+ auto shape = obj->shape();
+ auto len = nncc::core::ADT::kernel::num_elements(shape);
+
+ auto ovl = _data->f32()->read(obj);
+ assert(ovl != nullptr);
+
+ // Flatten?
+ std::vector<float> values;
+ values.resize(len);
+
+ for (uint32_t n = 0; n < shape.count(); ++n)
+ {
+ for (uint32_t ch = 0; ch < shape.depth(); ++ch)
+ {
+ for (uint32_t row = 0; row < shape.height(); ++row)
+ {
+ for (uint32_t col = 0; col < shape.width(); ++col)
+ {
+ const static nncc::core::ADT::kernel::NHWCLayout l{};
+ const auto offset = static_cast<uint32_t>(l.offset(shape, n, ch, row, col));
+
+ values.at(offset) = ovl->at(n, ch, row, col);
+ }
+ }
+ }
+ }
+
+ _binder->setOperand(ker, values.begin(), values.end());
+ }
// Conv2D in coco IR has no bias, but bias is mandatory in Android NN API
auto bias =
_binder->addOperand<float>(nncc::core::ADT::tensor::Shape{conv->ker()->shape().count()});
- // TODO Fill bias data
+ // Fill bias data
+ {
+ auto length = conv->ker()->shape().count();
+
+ std::vector<float> values;
+ values.resize(length, 0.0f);
+
+ _binder->setOperand(bias, values.begin(), values.end());
+ }
auto left = _binder->addOperand<int32_t>();
_binder->setOperand(left, 0);