Skip to content

Commit

Permalink
[res/tfl_recipes] Add REGRESS_Issue_13863 (#14064)
Browse files Browse the repository at this point in the history
This commit adds REGRESS_Issue_13863 tflite recipe.

ONE-DCO-1.0-Signed-off-by: HanJin Choi [email protected]
  • Loading branch information
Hanjin-Choi authored and seanshpark committed Sep 30, 2024
1 parent c59ddc6 commit 9b7c9e8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
Empty file.
19 changes: 15 additions & 4 deletions compiler/luci/import/src/ImporterEx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@
namespace luci
{

namespace
{

// limitation of current flatbuffers file size
inline constexpr uint64_t FLATBUFFERS_SIZE_MAX = 2147483648UL; // 2GB

} // namespace

std::unique_ptr<Module> ImporterEx::importVerifyModule(const std::string &input_path) const
{
foder::FileLoader file_loader{input_path};
Expand All @@ -43,11 +51,14 @@ std::unique_ptr<Module> ImporterEx::importVerifyModule(const std::string &input_
auto data_data = reinterpret_cast<uint8_t *>(model_data.data());
auto data_size = model_data.size();

flatbuffers::Verifier verifier{data_data, data_size};
if (!circle::VerifyModelBuffer(verifier))
if (data_size < FLATBUFFERS_SIZE_MAX)
{
std::cerr << "ERROR: Invalid input file '" << input_path << "'" << std::endl;
return nullptr;
flatbuffers::Verifier verifier{data_data, data_size};
if (!circle::VerifyModelBuffer(verifier))
{
std::cerr << "ERROR: Invalid input file '" << input_path << "'" << std::endl;
return nullptr;
}
}

Importer importer(_source);
Expand Down
9 changes: 8 additions & 1 deletion compiler/luci/service/src/Nodes/CircleReshape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ loco::TensorShape Algorithm::visit(const luci::CircleReshape *node)
{
shape_by_input.dim(axis).unset();
}
else if (const_shape_node->at<S32>(axis) == 0)
{
// Assume 0 as 1
shape_by_input.dim(axis).set(1);
}
}
}
else
Expand Down Expand Up @@ -148,14 +153,16 @@ loco::TensorShape Algorithm::visit(const luci::CircleReshape *node)
}
for (uint32_t dim_index = 0; dim_index < output_shape.rank(); ++dim_index)
{
const uint32_t dim_value = output_shape.dim(dim_index).value();
uint32_t dim_value = output_shape.dim(dim_index).value();
if (not output_shape.dim(dim_index).known())
{
LUCI_ASSERT(unknown_dim_index == UINT32_MAX, "More than one unknown dimension");
unknown_dim_index = dim_index;
}
else
{
if (!dim_value)
dim_value = 1;
output_element_count *= dim_value;
}
}
Expand Down

0 comments on commit 9b7c9e8

Please sign in to comment.