Fix onnx slice by clipping ends to int32 domain (#603)

This commit is contained in:
Maxim Vafin 2020-06-09 17:50:38 +03:00 committed by GitHub
parent 0bf1f53356
commit 074266bf73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,7 +71,7 @@ class ConvertSlice(MiddleReplacementPattern):
# in ONNX the value for 'ends' is usually -1 which is translated to maximum possible value of int64. This
# value must be converted to maximum of int32 because such big values do not fit into the int32 which is
# supported by the StridedSlice layer
ends = int64_array([np.iinfo(np.int32).max if item > np.iinfo(np.int32).max else item for item in ends])
ends = np.clip(ends, np.iinfo(np.int32).min, np.iinfo(np.int32).max)
if node.is_in_port_connected(3):
axes = node.in_port(3).data.get_value()
if axes is None: