const auto ker_index{node.getInputs().at(Conv2DNode::Input::KERNEL)};
const auto bias_index{node.getInputs().at(Conv2DNode::Input::BIAS)};
- const auto vstride_index{node.param().vstride_index};
- const auto hstride_index{node.param().hstride_index};
-
const auto ifm_shape = _ctx.at(ifm_index).shape().asFeature();
const auto ofm_shape = _ctx.at(ofm_index).shape().asFeature();
const auto ker_shape = _ctx.at(ker_index).shape().asKernel();
- model::Stride stride;
-
- stride.vertical = _ctx.at(vstride_index).asScalar<int32_t>();
- stride.horizontal = _ctx.at(hstride_index).asScalar<int32_t>();
-
// Construct operation parameters
struct Param
{
param.ker_index = ker_index;
param.bias_index = bias_index;
- param.stride = stride;
+ param.stride = node.param().stride;
param.padding = neurun::util::calculatePadding(node.param().padding, ifm_shape, ofm_shape,
param.stride, ker_shape.W, ker_shape.H);
param.activation = node.param().activation;
const auto ker_index{node.getInputs().at(Conv2DNode::Input::KERNEL)};
const auto bias_index{node.getInputs().at(Conv2DNode::Input::BIAS)};
- const auto vstride_index{node.param().vstride_index};
- const auto hstride_index{node.param().hstride_index};
-
const auto ofm_shape = _ctx.at(ofm_index).shape().asFeature();
const auto ifm_shape = _ctx.at(ifm_index).shape().asFeature();
const auto ker_shape = _ctx.at(ker_index).shape().asKernel();
- model::Stride stride;
-
- stride.vertical = _ctx.at(vstride_index).asScalar<int32_t>();
- stride.horizontal = _ctx.at(hstride_index).asScalar<int32_t>();
-
// Construct operation parameters
struct Param
{
param.ker_index = ker_index;
param.bias_index = bias_index;
- param.stride = stride;
+ param.stride = node.param().stride;
param.padding = neurun::util::calculatePadding(node.param().padding, ifm_shape, ofm_shape,
param.stride, ker_shape.W, ker_shape.H);
param.activation = node.param().activation;
const auto ker_index{node.getInputs().at(Conv2DNode::Input::KERNEL)};
const auto bias_index{node.getInputs().at(Conv2DNode::Input::BIAS)};
- const auto vstride_index{node.param().vstride_index};
- const auto hstride_index{node.param().hstride_index};
-
- model::Stride stride;
-
- stride.vertical = _ctx.at(vstride_index).asScalar<int32_t>();
- stride.horizontal = _ctx.at(hstride_index).asScalar<int32_t>();
+ const auto ifm_shape = _ctx.at(ifm_index).shape().asFeature();
+ const auto ofm_shape = _ctx.at(ofm_index).shape().asFeature();
+ const auto ker_shape = _ctx.at(ker_index).shape().asKernel();
// Construct operation parameters
struct Param
param.ker_shape = ::neurun::backend::cpu::kernel::getShape(_ctx.at(ker_index));
param.bias_shape = ::neurun::backend::cpu::kernel::getShape(_ctx.at(bias_index));
- param.stride = stride;
-
- const auto ifm_shape = _ctx.at(ifm_index).shape().asFeature();
- const auto ofm_shape = _ctx.at(ofm_index).shape().asFeature();
- const auto ker_shape = _ctx.at(ker_index).shape().asKernel();
+ param.stride = node.param().stride;
param.padding = neurun::util::calculatePadding(node.param().padding, ifm_shape, ofm_shape,
param.stride, ker_shape.W, ker_shape.H);
param.activation = node.param().activation;
struct Param
{
Stride stride;
- // hstride_index and vtride_index will be deprecated
- OperandIndex hstride_index;
- OperandIndex vstride_index;
-
Padding padding;
Activation activation;
};
return param;
}
+Stride setStride(Operands &operands, const OperandIndex &horizontal_index,
+ const OperandIndex &vertical_index)
+{
+ auto horizontal = operands.at(horizontal_index).asScalar<int32_t>();
+ auto vertical = operands.at(vertical_index).asScalar<int32_t>();
+
+ if (vertical < 0 || horizontal < 0)
+ {
+ throw std::runtime_error{"Cannot handle negative stride value"};
+ }
+
+ Stride stride;
+ stride.horizontal = horizontal;
+ stride.vertical = vertical;
+
+ return stride;
+}
+
} // namespace
OperationFactory &OperationFactory::instance()
// 6 -> Activation Index
const auto padding_index = OperandIndex{init_param.inputs[3]};
+ const auto hstride_index = OperandIndex{init_param.inputs[4]};
+ const auto vstride_index = OperandIndex{init_param.inputs[5]};
const auto activation_index = OperandIndex{init_param.inputs[6]};
param.padding.type =
NNAPIConvert::getPaddingType(operands.at(padding_index).asScalar<PaddingCode>());
- param.hstride_index = OperandIndex{init_param.inputs[4]};
- param.vstride_index = OperandIndex{init_param.inputs[5]};
+ param.stride = setStride(operands, hstride_index, vstride_index);
param.activation =
NNAPIConvert::getFusedActivation(operands.at(activation_index).asScalar<FuseCode>());
}
const auto padding_right_index = OperandIndex{init_param.inputs[4]};
const auto padding_top_index = OperandIndex{init_param.inputs[5]};
const auto padding_bottom_index = OperandIndex{init_param.inputs[6]};
+ const auto hstride_index = OperandIndex{init_param.inputs[7]};
+ const auto vstride_index = OperandIndex{init_param.inputs[8]};
const auto activation_index = OperandIndex{init_param.inputs[9]};
param.padding.type = PaddingType::EXPLICIT;
param.padding.param =
setExplicitPaddingParam(operands, padding_left_index, padding_right_index,
padding_top_index, padding_bottom_index);
- param.hstride_index = OperandIndex{init_param.inputs[7]};
- param.vstride_index = OperandIndex{init_param.inputs[8]};
-
+ param.stride = setStride(operands, hstride_index, vstride_index);
param.activation =
NNAPIConvert::getFusedActivation(operands.at(activation_index).asScalar<FuseCode>());
}
GraphNode::Param conv_params;
conv_params.padding.type = neurun::model::PaddingType::SAME;
- conv_params.hstride_index = model.operands.append(shape, type);
- conv_params.vstride_index = model.operands.append(shape, type);
+ conv_params.stride.horizontal = 1;
+ conv_params.stride.vertical = 1;
conv_params.activation = neurun::model::Activation::NONE;
auto output_operand = model.operands.append(shape, type).value();