Skip to content

Commit 042e42e

Browse files
committed
Fix CI: add CUDA EP external data guard, fix TreeEnsemble test dims
- Add HasExternalData check to CUDA EP non-plugin LabelEncoder path (GetAttrOrTensor and TryGetScalarTensorAttribute) so error messages are consistent across all EPs. - Remove CUDA EP exclusion from LabelEncoder tests since all EPs now reject external data uniformly. - Fix TreeEnsemble opset 5 test: nodes_splits dims must match the number of elements in nodes_featureids and other node attributes (changed from 3 to 1).
1 parent 7418072 commit 042e42e

3 files changed

Lines changed: 11 additions & 13 deletions

File tree

onnxruntime/core/providers/cuda/ml/label_encoder.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ static bool TryGetScalarTensorAttribute(const OpKernelInfo& info, const std::str
7171
auto* attr_tensor_proto = GetTensorProto(attr_tensor_holder);
7272
auto result = info.GetAttr(tensor_name, attr_tensor_proto);
7373
if (result.IsOK() && utils::HasDataType(*attr_tensor_proto)) {
74+
ORT_ENFORCE(!utils::HasExternalData(*attr_tensor_proto),
75+
"Tensor attribute ", tensor_name, " with external data is not supported.");
7476
const auto [raw_data, raw_data_len] = GetRawData(*attr_tensor_proto);
7577
result = utils::UnpackTensor<T>(*attr_tensor_proto, raw_data, raw_data_len, &value, 1);
7678
ORT_ENFORCE(result.IsOK(), "LabelEncoder could not unpack tensor attribute ", attr_name);
@@ -117,6 +119,8 @@ static std::vector<T> GetAttrOrTensor(const OpKernelInfo& info, const std::strin
117119
} else {
118120
ORT_ENFORCE(result.IsOK(), "LabelEncoder is missing attribute ", tensor_name, " or ", name);
119121
}
122+
ORT_ENFORCE(!utils::HasExternalData(*attr_tensor_proto),
123+
"Tensor attribute ", tensor_name, " with external data is not supported.");
120124
SafeInt<int64_t> element_count(1);
121125
for (auto dim : attr_tensor_proto->dims()) {
122126
element_count *= dim;

onnxruntime/test/providers/cpu/ml/label_encoder_test.cc

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -819,9 +819,7 @@ TEST(LabelEncoder, RejectsExternalDataInKeysTensorOpset4) {
819819
test.AddInput<int64_t>("X", {1, 2}, {1, 2});
820820
test.AddOutput<int64_t>("Y", {1, 2}, {10, 20});
821821

822-
// CUDA EP uses a different code path that doesn't hit this issue, exclude it.
823-
test.Run(OpTester::ExpectResult::kExpectFailure, "external data is not supported",
824-
{kCudaExecutionProvider});
822+
test.Run(OpTester::ExpectResult::kExpectFailure, "external data is not supported");
825823
}
826824

827825
TEST(LabelEncoder, RejectsExternalDataInDefaultTensorOpset4) {
@@ -837,9 +835,7 @@ TEST(LabelEncoder, RejectsExternalDataInDefaultTensorOpset4) {
837835
test.AddInput<int64_t>("X", {1, 2}, {1, 3});
838836
test.AddOutput<int64_t>("Y", {1, 2}, {10, 0});
839837

840-
// CUDA EP uses a different code path that doesn't hit this issue, exclude it.
841-
test.Run(OpTester::ExpectResult::kExpectFailure, "external data is not supported",
842-
{kCudaExecutionProvider});
838+
test.Run(OpTester::ExpectResult::kExpectFailure, "external data is not supported");
843839
}
844840

845841
TEST(LabelEncoder, RejectsExternalDataInValuesTensorOpset4) {
@@ -868,9 +864,7 @@ TEST(LabelEncoder, RejectsExternalDataInValuesTensorOpset4) {
868864
test.AddInput<int64_t>("X", {1, 2}, {1, 2});
869865
test.AddOutput<int64_t>("Y", {1, 2}, {10, 20});
870866

871-
// CUDA EP uses a different code path that doesn't hit this issue, exclude it.
872-
test.Run(OpTester::ExpectResult::kExpectFailure, "external data is not supported",
873-
{kCudaExecutionProvider});
867+
test.Run(OpTester::ExpectResult::kExpectFailure, "external data is not supported");
874868
}
875869

876870
#endif // !defined(ORT_NO_EXCEPTIONS)

onnxruntime/test/providers/cpu/ml/tree_ensembler_test.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -462,19 +462,19 @@ TEST(MLOpTest, TreeEnsembleRejectsExternalDataInTensorAttribute) {
462462
PathString filename(ORT_TSTR("ext_data_XXXXXX"));
463463
FILE* fp = nullptr;
464464
CreateTestFile(fp, filename);
465-
std::vector<char> data(12, 0); // 3 x float
465+
std::vector<char> data(4, 0); // 1 x float
466466
fwrite(data.data(), 1, data.size(), fp);
467467
fclose(fp);
468468
ScopedFileDeleter ext_deleter(filename);
469469
std::string ext_path = ToUTF8String(filename);
470470

471471
OpTester test("TreeEnsemble", 5, onnxruntime::kMLDomain);
472472

473-
// nodes_splits with external data location
473+
// nodes_splits with external data location (1 node)
474474
ONNX_NAMESPACE::TensorProto splits_proto;
475475
splits_proto.set_name("nodes_splits");
476476
splits_proto.set_data_type(ONNX_NAMESPACE::TensorProto_DataType_FLOAT);
477-
splits_proto.add_dims(3);
477+
splits_proto.add_dims(1);
478478
splits_proto.set_data_location(ONNX_NAMESPACE::TensorProto_DataLocation_EXTERNAL);
479479
auto* loc = splits_proto.add_external_data();
480480
loc->set_key("location");
@@ -484,7 +484,7 @@ TEST(MLOpTest, TreeEnsembleRejectsExternalDataInTensorAttribute) {
484484
offset->set_value("0");
485485
auto* length = splits_proto.add_external_data();
486486
length->set_key("length");
487-
length->set_value("12");
487+
length->set_value("4");
488488
test.AddAttribute("nodes_splits", splits_proto);
489489

490490
// Minimal valid structure for remaining attributes

0 commit comments

Comments
 (0)