Skip to content

Commit 95260a8

Browse files
committed
StridedSlice handles negative strided_begin_ before shrink_axis for models not from onnx
Previous strided_slcie change is reverted because it fails onnx yolov3 models
1 parent 2a87640 commit 95260a8

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/caffe/layers/strided_slice_layer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ void StridedSliceLayer<Dtype>::LayerSetUp(const vector<Blob<Dtype> *> &bottom,
6767
if (ellipsis_mask_ & 1 << i) {
6868
ellipsis_axis = i;
6969
}
70+
if (strided_begin_[i] >= 0) {
71+
strided_begin_[i] = std::min(strided_begin_[i], b_shape[i] - 1);
72+
} else {
73+
strided_begin_[i] = std::max(strided_begin_[i] + b_shape[i], 0);
74+
}
7075
if (shrink_axis_mask_ & 1 << i && i != ellipsis_axis) {
7176
strided_end_[i] = strided_begin_[i] + strides_[i] / abs(strides_[i]);
7277
strides_[i] = strides_[i] / abs(strides_[i]);

0 commit comments

Comments
 (0)