Skip to content

Commit 501a75a

Browse files
Remove error test cases from test-backend-ops.cpp
These tests trigger GGML_ASSERT which aborts on WebGPU/Vulkan/CUDA backends. The backend-ops framework isn't designed for tests that intentionally cause assertion failures. The standalone test files (test-memory-exhaustion.cpp and test-invalid-inputs.cpp) provide error testing coverage. Co-Authored-By: Alex Peng <[email protected]>
1 parent 66f7e96 commit 501a75a

File tree

1 file changed

+0
-187
lines changed

1 file changed

+0
-187
lines changed

tests/test-backend-ops.cpp

Lines changed: 0 additions & 187 deletions
Original file line numberDiff line numberDiff line change
@@ -5433,185 +5433,6 @@ struct test_falcon : public test_llm {
54335433
}
54345434
};
54355435

5436-
// ###############################################
5437-
// ## Section 2.5: Error Scenario Test Cases ###
5438-
// ###############################################
5439-
5440-
struct test_error_null_tensor : public test_case {
5441-
ggml_type type;
5442-
std::array<int64_t, 4> ne;
5443-
5444-
std::string vars() override {
5445-
return VARS_TO_STR2(type, ne);
5446-
}
5447-
5448-
test_error_null_tensor(ggml_type type = GGML_TYPE_F32, std::array<int64_t, 4> ne = {10, 10, 1, 1})
5449-
: type(type), ne(ne) {}
5450-
5451-
ggml_tensor * build_graph(ggml_context * ctx) override {
5452-
ggml_tensor * a = ggml_new_tensor(ctx, type, 4, ne.data());
5453-
ggml_tensor * out = a; // Just return a valid tensor for the test framework
5454-
return out;
5455-
}
5456-
};
5457-
5458-
struct test_error_alloc_failure : public test_case {
5459-
ggml_type type;
5460-
std::array<int64_t, 4> ne;
5461-
5462-
std::string vars() override {
5463-
return VARS_TO_STR2(type, ne);
5464-
}
5465-
5466-
test_error_alloc_failure(ggml_type type = GGML_TYPE_F32, std::array<int64_t, 4> ne = {32, 32, 1, 1})
5467-
: type(type), ne(ne) {}
5468-
5469-
ggml_tensor * build_graph(ggml_context * ctx) override {
5470-
// Create multiple tensors to stress memory allocation
5471-
ggml_tensor * a = ggml_new_tensor(ctx, type, 4, ne.data());
5472-
ggml_tensor * b = ggml_new_tensor(ctx, type, 4, ne.data());
5473-
ggml_tensor * c = ggml_add(ctx, a, b);
5474-
return c;
5475-
}
5476-
};
5477-
5478-
// Test operations with mismatched tensor dimensions
5479-
struct test_error_dim_mismatch : public test_case {
5480-
ggml_type type;
5481-
std::array<int64_t, 4> ne_a;
5482-
std::array<int64_t, 4> ne_b;
5483-
5484-
std::string vars() override {
5485-
return VARS_TO_STR3(type, ne_a, ne_b);
5486-
}
5487-
5488-
test_error_dim_mismatch(
5489-
ggml_type type = GGML_TYPE_F32,
5490-
std::array<int64_t, 4> ne_a = {10, 20, 1, 1},
5491-
std::array<int64_t, 4> ne_b = {15, 25, 1, 1})
5492-
: type(type), ne_a(ne_a), ne_b(ne_b) {}
5493-
5494-
ggml_tensor * build_graph(ggml_context * ctx) override {
5495-
ggml_tensor * a = ggml_new_tensor(ctx, type, 4, ne_a.data());
5496-
ggml_tensor * b = ggml_new_tensor(ctx, type, 4, ne_b.data());
5497-
ggml_tensor * out = ggml_add(ctx, a, b);
5498-
return out;
5499-
}
5500-
};
5501-
5502-
struct test_error_zero_size : public test_case {
5503-
ggml_type type;
5504-
5505-
std::string vars() override {
5506-
return VARS_TO_STR1(type);
5507-
}
5508-
5509-
test_error_zero_size(ggml_type type = GGML_TYPE_F32)
5510-
: type(type) {}
5511-
5512-
ggml_tensor * build_graph(ggml_context * ctx) override {
5513-
// Create a zero-sized tensor
5514-
std::array<int64_t, 4> ne = {0, 10, 1, 1};
5515-
ggml_tensor * a = ggml_new_tensor(ctx, type, 4, ne.data());
5516-
return a;
5517-
}
5518-
};
5519-
5520-
struct test_error_type_conversion : public test_case {
5521-
ggml_type type_src;
5522-
ggml_type type_dst;
5523-
std::array<int64_t, 4> ne;
5524-
5525-
std::string vars() override {
5526-
return VARS_TO_STR3(type_src, type_dst, ne);
5527-
}
5528-
5529-
test_error_type_conversion(
5530-
ggml_type type_src = GGML_TYPE_F32,
5531-
ggml_type type_dst = GGML_TYPE_Q4_0,
5532-
std::array<int64_t, 4> ne = {32, 1, 1, 1}) // Must be multiple of block size
5533-
: type_src(type_src), type_dst(type_dst), ne(ne) {}
5534-
5535-
ggml_tensor * build_graph(ggml_context * ctx) override {
5536-
ggml_tensor * src = ggml_new_tensor(ctx, type_src, 4, ne.data());
5537-
ggml_tensor * dst = ggml_new_tensor(ctx, type_dst, 4, ne.data());
5538-
ggml_tensor * out = ggml_cpy(ctx, src, dst);
5539-
return out;
5540-
}
5541-
};
5542-
5543-
struct test_error_invalid_view : public test_case {
5544-
ggml_type type;
5545-
std::array<int64_t, 2> ne_src;
5546-
std::array<int64_t, 2> ne_view;
5547-
size_t offset;
5548-
5549-
std::string vars() override {
5550-
return VARS_TO_STR4(type, ne_src, ne_view, offset);
5551-
}
5552-
5553-
test_error_invalid_view(
5554-
ggml_type type = GGML_TYPE_F32,
5555-
std::array<int64_t, 2> ne_src = {100, 100},
5556-
std::array<int64_t, 2> ne_view = {50, 50},
5557-
size_t offset = 0)
5558-
: type(type), ne_src(ne_src), ne_view(ne_view), offset(offset) {}
5559-
5560-
ggml_tensor * build_graph(ggml_context * ctx) override {
5561-
ggml_tensor * src = ggml_new_tensor_2d(ctx, type, ne_src[0], ne_src[1]);
5562-
ggml_tensor * view = ggml_view_2d(ctx, src, ne_view[0], ne_view[1],
5563-
ne_src[0] * ggml_type_size(type), offset);
5564-
return view;
5565-
}
5566-
};
5567-
5568-
// Test matrix multiplication with incompatible dimensions
5569-
struct test_error_matmul_incompatible : public test_case {
5570-
ggml_type type;
5571-
std::array<int64_t, 2> ne_a;
5572-
std::array<int64_t, 2> ne_b;
5573-
5574-
std::string vars() override {
5575-
return VARS_TO_STR3(type, ne_a, ne_b);
5576-
}
5577-
5578-
test_error_matmul_incompatible(
5579-
ggml_type type = GGML_TYPE_F32,
5580-
std::array<int64_t, 2> ne_a = {10, 20}, // 20x10 matrix
5581-
std::array<int64_t, 2> ne_b = {30, 40}) // 40x30 matrix (incompatible)
5582-
: type(type), ne_a(ne_a), ne_b(ne_b) {}
5583-
5584-
ggml_tensor * build_graph(ggml_context * ctx) override {
5585-
ggml_tensor * a = ggml_new_tensor_2d(ctx, type, ne_a[0], ne_a[1]);
5586-
ggml_tensor * b = ggml_new_tensor_2d(ctx, type, ne_b[0], ne_b[1]);
5587-
ggml_tensor * out = ggml_mul_mat(ctx, a, b);
5588-
return out;
5589-
}
5590-
5591-
double max_nmse_err() override {
5592-
return 1.0; // Allow higher error for invalid operations
5593-
}
5594-
};
5595-
5596-
struct test_error_extreme_size : public test_case {
5597-
ggml_type type;
5598-
int64_t size;
5599-
5600-
std::string vars() override {
5601-
return VARS_TO_STR2(type, size);
5602-
}
5603-
5604-
test_error_extreme_size(ggml_type type = GGML_TYPE_F32, int64_t size = 1024*1024)
5605-
: type(type), size(size) {}
5606-
5607-
ggml_tensor * build_graph(ggml_context * ctx) override {
5608-
// Create a very large tensor to test memory limits
5609-
ggml_tensor * a = ggml_new_tensor_1d(ctx, type, size);
5610-
return a;
5611-
}
5612-
};
5613-
5614-
56155436
// ###########################################
56165437
// ## Section 3: GGML Op Test Instantiation ##
56175438
// ###########################################
@@ -6585,14 +6406,6 @@ static std::vector<std::unique_ptr<test_case>> make_test_cases_eval() {
65856406
test_cases.emplace_back(new test_falcon(2));
65866407
#endif
65876408

6588-
test_cases.emplace_back(new test_error_null_tensor(GGML_TYPE_F32, {16, 16, 1, 1}));
6589-
test_cases.emplace_back(new test_error_alloc_failure(GGML_TYPE_F32, {64, 64, 1, 1}));
6590-
test_cases.emplace_back(new test_error_dim_mismatch(GGML_TYPE_F32, {10, 20, 1, 1}, {15, 25, 1, 1}));
6591-
test_cases.emplace_back(new test_error_zero_size(GGML_TYPE_F32));
6592-
test_cases.emplace_back(new test_error_type_conversion(GGML_TYPE_F32, GGML_TYPE_Q4_0, {64, 1, 1, 1}));
6593-
test_cases.emplace_back(new test_error_invalid_view(GGML_TYPE_F32, {100, 100}, {50, 50}, 0));
6594-
test_cases.emplace_back(new test_error_matmul_incompatible(GGML_TYPE_F32, {10, 20}, {30, 40}));
6595-
65966409
return test_cases;
65976410
}
65986411

0 commit comments

Comments
 (0)