diff --git a/ethosu/regor/tosa/tosa_reader.cpp b/ethosu/regor/tosa/tosa_reader.cpp index 328e698f13234230a8ff9e271124cc29e029d703..458955f73f36194080fa7e26a032b6aa970b5335 100644 --- a/ethosu/regor/tosa/tosa_reader.cpp +++ b/ethosu/regor/tosa/tosa_reader.cpp @@ -416,29 +416,32 @@ void TosaReader::LoadGraphs(const tosaFb::TosaGraph *model, std::listshapes()) ) + if ( tosa_basicblock->shapes() ) { - GraphApi::GraphBuffer *buffer = nullptr; + for ( const auto &tosa_shape : SafeDeref(tosa_basicblock->shapes()) ) + { + GraphApi::GraphBuffer *buffer = nullptr; - const char *name = SafeDeref(tosa_shape->name(), "No shape name").c_str(); - tosa_assert(name, "Shape needs a valid name"); - const auto type = GraphApi::GraphDataType::Int64; + const char *name = SafeDeref(tosa_shape->name(), "No shape name").c_str(); + tosa_assert(name, "Shape needs a valid name"); + const auto type = GraphApi::GraphDataType::Int64; - const auto &shapeData = tosa_shape->data(); - if ( shapeData && shapeData->size() ) - { - buffer = builder->CreateBuffer(shapeData->size(), GraphApi::BufferMapping::Alias, shapeData->Data()); - builder_assert(buffer, "Failed to create buffer"); - } + const auto &shapeData = tosa_shape->data(); + if ( shapeData && shapeData->size() ) + { + buffer = builder->CreateBuffer(shapeData->size(), GraphApi::BufferMapping::Alias, shapeData->Data()); + builder_assert(buffer, "Failed to create buffer"); + } - GraphApi::GraphShape tosaShape; - tosaShape.count = 1; - tosaShape.axisNHWC[0] = tosa_shape->rank(); - auto tensor = builder->CreateTensor(name, tosaShape, GraphApi::GraphTensorLayout::Linear, type, buffer); - builder_assert(tensor, "Failed to create tensor"); + GraphApi::GraphShape tosaShape; + tosaShape.count = 1; + tosaShape.axisNHWC[0] = tosa_shape->rank(); + auto tensor = builder->CreateTensor(name, tosaShape, GraphApi::GraphTensorLayout::Linear, type, buffer); + builder_assert(tensor, "Failed to create tensor"); - tosa_assert(tensors.count(name) == 0, "Shape and Tensor name collision"); - tensors[name] = tensor; + tosa_assert(tensors.count(name) == 0, "Shape and Tensor name collision"); + tensors[name] = tensor; + } } const auto &tosa_operators = SafeDeref(tosa_basicblock->operators(), "No operators");