Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion clean/converter/src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1327,8 +1327,10 @@ class Loader {
for (const Axis& ax : t.axes) {
const std::int64_t n = ax.limit >= 0 ? std::min(ax.limit, ax.length) : ax.length;
if (n == 0) {
// The tensor reads nothing, but the axes after this one are still checked: the map is validated
// completely before any input is read (an empty axis adds no span).
any = false;
break;
continue;
}
std::int64_t span;
if (!checked_mul(ax.stride, n - 1, span) || !checked_add(hi, span, hi))
Expand Down
4 changes: 4 additions & 0 deletions clean/converter/tests/run_tests5.py
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,10 @@ def t(m, gname, tname):
add("negative base", lambda m: t(m, "G1", "D").update(base=-1))
add("negative stride", lambda m: t(m, "G1", "b")["axes"][1].update(stride=-1))
add("negative limit", lambda m: t(m, "G1", "fe")["axes"][0].update(limit=-1))
# Issue #54: every axis is checked, also the ones after an empty axis (limit 0): the stride times the index of the
# second axis does not fit 64 bits.
add("huge stride after an empty axis",
lambda m: (t(m, "G1", "b")["axes"][0].update(limit=0), t(m, "G1", "b")["axes"][1].update(stride=9223372036854775807)))
add("negative site index", lambda m: t(m, "constants", "SUB")["sites"][0].update(elements=[-1]))
add("zero shape dimension", lambda m: t(m, "G1", "D").update(shape=[0]))
add("empty shape", lambda m: t(m, "constants", "SUB").update(shape=[]))
Expand Down
Loading