Skip to content

Commit

Permalink
[luci/service] Add Assert Shape Inference Condition for Range
Browse files Browse the repository at this point in the history
This commit add assert shape inference condition for Range.

ONE-DCO-1.0-Signed-off-by: bokyeong lee <[email protected]>
  • Loading branch information
kyeong8139 committed Sep 12, 2024
1 parent 5149447 commit 654b943
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions compiler/luci/service/src/Nodes/CircleRange.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ loco::TensorShape Algorithm::visit(const luci::CircleRange *node)
if (delta == 0)
INTERNAL_EXN("Delta can not be zero");

/*
* Pre-condition
* 'limit - start' and 'delta' have the same sign.
* c1. '(limit - start) >= 0' -> 'delta > 0'
* c2. '(limit - start) < 0' -> 'delta < 0'
* https://github.com/tensorflow/tensorflow/blob/da82fa9/tensorflow/lite/kernels/range.cc#L49-L50
*/
assert((start >= limit && delta < 0) || (start <= limit && delta > 0));
output_shape.dim(0) = ceil((limit - start) / delta);

return output_shape;
Expand Down

0 comments on commit 654b943

Please sign in to comment.