提交 4b96f5d5 编写于 作者: L liuqi

Fix scalar output shape bug in operator.jinja2

上级 230eb39e
...@@ -83,30 +83,35 @@ void CreateOperator{{i}}(mace::OperatorDef *op) { ...@@ -83,30 +83,35 @@ void CreateOperator{{i}}(mace::OperatorDef *op) {
arg->set_s({{ arg.s.decode('utf-8')|tojson }}); arg->set_s({{ arg.s.decode('utf-8')|tojson }});
{%- endif %} {%- endif %}
arg->mutable_floats()->Reserve({{ arg.floats|length }}); {% if arg.floats|length > 0 %}
{% for float_value in arg.floats %} arg->mutable_floats()->Reserve({{ arg.floats|length }});
arg->add_floats({{ float_value }}); {% for float_value in arg.floats %}
{% endfor %} arg->add_floats({{ float_value }});
arg->mutable_ints()->Reserve({{ arg.ints|length }}); {% endfor %}
{% for int_value in arg.ints %} {% endif %}
arg->add_ints({{ int_value }});
{% endfor %} {% if arg.ints|length > 0 %}
arg->mutable_ints()->Reserve({{ arg.ints|length }});
{% for int_value in arg.ints %}
arg->add_ints({{ int_value }});
{% endfor %}
{% endif %}
{% endfor %} {% endfor %}
{% if net.op[i].output_shape|length > 0 %} {% if net.op[i].output_shape|length > 0 %}
op->mutable_output_shape()->Reserve({{ net.op[i].output_shape|length }}); op->mutable_output_shape()->Reserve({{ net.op[i].output_shape|length }});
mace::OutputShape * output_shape = nullptr;
{% for shape in net.op[i].output_shape %} {% for shape in net.op[i].output_shape %}
{% if shape.dims|length > 0 %} {% if shape.dims|length > 0 %}
output_shape = op->add_output_shape(); {
mace::OutputShape *output_shape = op->add_output_shape();
output_shape->mutable_dims()->Reserve({{ shape.dims|length }}); output_shape->mutable_dims()->Reserve({{ shape.dims|length }});
{% for dim in shape.dims %} {% for dim in shape.dims %}
output_shape->add_dims({{ dim }}); output_shape->add_dims({{ dim }});
{% endfor %} {% endfor %}
}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册