Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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: 2 additions & 2 deletions onnxruntime/core/providers/cpu/ml/array_feature_extractor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ common::Status ArrayFeatureExtractorOp<T>::Compute(OpKernelContext* context) con
}

for (int64_t i = 0; i < num_indices; ++i) {
if (y_data[i] >= stride) {
if (y_data[i] < 0 || y_data[i] >= stride) {
return ORT_MAKE_STATUS(
ONNXRUNTIME, INVALID_ARGUMENT,
"Invalid Y argument: index is out of range: Y[", i, "] (", y_data[i], ") >=", stride);
"Invalid Y argument: index is out of range: Y[", i, "] (", y_data[i], ") must be in [0,", stride, ")");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,12 @@ TEST_F(ArrayFeatureExtractorTest, InvalidInputOutOfBoundsY) {
test_.Run(OpTester::ExpectResult::kExpectFailure);
}

TEST_F(ArrayFeatureExtractorTest, InvalidInputNegativeY) {
test_.AddInput<int64_t>("X", {10, 1}, {0, 1, 2, 3, 4, 5, 6, 7, 8, 9});
test_.AddInput<int64_t>("Y", {1}, {-10});
test_.AddOutput<int64_t>("Z", {0}, {});
test_.Run(OpTester::ExpectResult::kExpectFailure);
}

} // namespace test
} // namespace onnxruntime
Loading