void ifm(coco::FeatureObject *ifm) { _ifm = ifm; }
void ker(coco::KernelObject *ker) { _ker = ker; }
+ // Q: Should we take a bias as a feature object?
+ // NOTE This interface is subject to change
+ void bias(coco::FeatureObject *bias) { _bias = bias; }
void ofm(coco::FeatureObject *ofm) { _ofm = ofm; }
public:
auto bias = binder->addOperand<float>(nncc::core::ADT::tensor::Shape{_ker->shape().count()});
// Fill bias data
+ if (_bias == nullptr)
{
+ // Use a fresh empty bias if "bias" is not specified
auto length = _ker->shape().count();
std::vector<float> values;
binder->setOperand(bias, values.begin(), values.end());
}
+ else
+ {
+ // Use specified "bias"
+ auto bias_bag = _bias->bag();
+ auto bias_weight = data->f32()->weight(bias_bag);
+
+ assert(bias_weight.data() != nullptr);
+ assert(bias_weight.size() == _ker->shape().count());
+
+ binder->setOperand(bias, bias_weight.data(), bias_weight.data() + bias_weight.size());
+ }
auto left = binder->addOperand<int32_t>();
binder->setOperand(left, _pad.left());
private:
coco::FeatureObject *_ifm = nullptr;
coco::KernelObject *_ker = nullptr;
+ coco::FeatureObject *_bias = nullptr;
coco::FeatureObject *_ofm = nullptr;
};