Skip to content

Commit

Permalink
Add Reshape attribute parsing.
Browse files Browse the repository at this point in the history
'allowzero' was added in ONNX-14.
Not implemented - what to do about tensors with dimensions
of size zero?
  • Loading branch information
kraiskil committed Apr 22, 2023
1 parent 1b33912 commit 66dba8e
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/nodes/reshape.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,28 @@ class Reshape : public Node {
Reshape() {
op_name = "Reshape";
data=shape=reshaped=NULL;
allowzero=0;
}
// inputs
const Tensor *data;
const Tensor *shape;
// outputs
const Tensor *reshaped;

int32_t allowzero;

void parseAttributes( onnx::NodeProto &node )
{
for( const auto& a : node.attribute() ) {
LOG(TRACE) << "Parsing attribute " << a.name() << std::endl;
if( a.name() == "allowzero" )
allowzero = parse_attribute_int(a);
else
LOG(ERROR) << "Ignoring attribute " << a.name() << " for node TEMPLATE/" << onnx_name << std::endl;
}
}


virtual void print_parameters(std::ostream &dst, bool decorate ) const override
{
data->print_tensor_as_const(dst, !decorate);
Expand Down Expand Up @@ -56,6 +71,10 @@ class Reshape : public Node {
ERROR("Reshaping to a run-time defined shape is not supported");
}

if( allowzero != 0) {
ERROR("Allowzero attribute set. What exactly are you expecting as the output here?");
}

std::vector<int> out_data_dim;
int64_t *new_shape = (int64_t*)(shape->data_buffer);
bool negative_shape_found=false;
Expand Down

0 comments on commit 66dba8e

Please sign in to comment.