Skip to content

Commit a41f5fe

Browse files
committed
add tests
1 parent 5dd04ab commit a41f5fe

File tree

1 file changed

+4
-124
lines changed

1 file changed

+4
-124
lines changed

tests/test-backend-ops.cpp

Lines changed: 4 additions & 124 deletions
Original file line numberDiff line numberDiff line change
@@ -3930,130 +3930,6 @@ struct test_clamp : public test_case {
39303930
}
39313931
};
39323932

3933-
// GGML_OP_FLOOR
3934-
struct test_floor : public test_case {
3935-
const ggml_type type;
3936-
const std::array<int64_t, 4> ne;
3937-
3938-
std::string vars() override {
3939-
return VARS_TO_STR2(type, ne);
3940-
}
3941-
3942-
test_floor(ggml_type type = GGML_TYPE_F32,
3943-
std::array<int64_t, 4> ne = {10, 2, 2, 2})
3944-
: type(type), ne(ne) {}
3945-
3946-
ggml_tensor * build_graph(ggml_context * ctx) override {
3947-
ggml_tensor * a = ggml_new_tensor(ctx, type, 4, ne.data());
3948-
ggml_set_param(a);
3949-
ggml_set_name(a, "a");
3950-
3951-
ggml_tensor * out = ggml_floor(ctx, a);
3952-
ggml_set_name(out, "out");
3953-
3954-
return out;
3955-
}
3956-
3957-
void initialize_tensors(ggml_context * ctx) override {
3958-
for (ggml_tensor * t = ggml_get_first_tensor(ctx); t != NULL; t = ggml_get_next_tensor(ctx, t)) {
3959-
init_tensor_uniform(t, -10.0f, 10.0f);
3960-
}
3961-
}
3962-
};
3963-
3964-
// GGML_OP_CEIL
3965-
struct test_ceil : public test_case {
3966-
const ggml_type type;
3967-
const std::array<int64_t, 4> ne;
3968-
3969-
std::string vars() override {
3970-
return VARS_TO_STR2(type, ne);
3971-
}
3972-
3973-
test_ceil(ggml_type type = GGML_TYPE_F32,
3974-
std::array<int64_t, 4> ne = {10, 2, 2, 2})
3975-
: type(type), ne(ne) {}
3976-
3977-
ggml_tensor * build_graph(ggml_context * ctx) override {
3978-
ggml_tensor * a = ggml_new_tensor(ctx, type, 4, ne.data());
3979-
ggml_set_param(a);
3980-
ggml_set_name(a, "a");
3981-
3982-
ggml_tensor * out = ggml_ceil(ctx, a);
3983-
ggml_set_name(out, "out");
3984-
3985-
return out;
3986-
}
3987-
3988-
void initialize_tensors(ggml_context * ctx) override {
3989-
for (ggml_tensor * t = ggml_get_first_tensor(ctx); t != NULL; t = ggml_get_next_tensor(ctx, t)) {
3990-
init_tensor_uniform(t, -10.0f, 10.0f);
3991-
}
3992-
}
3993-
};
3994-
3995-
// GGML_OP_ROUND
3996-
struct test_round : public test_case {
3997-
const ggml_type type;
3998-
const std::array<int64_t, 4> ne;
3999-
4000-
std::string vars() override {
4001-
return VARS_TO_STR2(type, ne);
4002-
}
4003-
4004-
test_round(ggml_type type = GGML_TYPE_F32,
4005-
std::array<int64_t, 4> ne = {10, 2, 2, 2})
4006-
: type(type), ne(ne) {}
4007-
4008-
ggml_tensor * build_graph(ggml_context * ctx) override {
4009-
ggml_tensor * a = ggml_new_tensor(ctx, type, 4, ne.data());
4010-
ggml_set_param(a);
4011-
ggml_set_name(a, "a");
4012-
4013-
ggml_tensor * out = ggml_round(ctx, a);
4014-
ggml_set_name(out, "out");
4015-
4016-
return out;
4017-
}
4018-
4019-
void initialize_tensors(ggml_context * ctx) override {
4020-
for (ggml_tensor * t = ggml_get_first_tensor(ctx); t != NULL; t = ggml_get_next_tensor(ctx, t)) {
4021-
init_tensor_uniform(t, -10.0f, 10.0f);
4022-
}
4023-
}
4024-
};
4025-
4026-
// GGML_OP_TRUNC
4027-
struct test_trunc : public test_case {
4028-
const ggml_type type;
4029-
const std::array<int64_t, 4> ne;
4030-
4031-
std::string vars() override {
4032-
return VARS_TO_STR2(type, ne);
4033-
}
4034-
4035-
test_trunc(ggml_type type = GGML_TYPE_F32,
4036-
std::array<int64_t, 4> ne = {10, 2, 2, 2})
4037-
: type(type), ne(ne) {}
4038-
4039-
ggml_tensor * build_graph(ggml_context * ctx) override {
4040-
ggml_tensor * a = ggml_new_tensor(ctx, type, 4, ne.data());
4041-
ggml_set_param(a);
4042-
ggml_set_name(a, "a");
4043-
4044-
ggml_tensor * out = ggml_trunc(ctx, a);
4045-
ggml_set_name(out, "out");
4046-
4047-
return out;
4048-
}
4049-
4050-
void initialize_tensors(ggml_context * ctx) override {
4051-
for (ggml_tensor * t = ggml_get_first_tensor(ctx); t != NULL; t = ggml_get_next_tensor(ctx, t)) {
4052-
init_tensor_uniform(t, -10.0f, 10.0f);
4053-
}
4054-
}
4055-
};
4056-
40573933
// GGML_OP_DIAG_MASK_INF
40583934
struct test_diag_mask_inf : public test_case {
40593935
const ggml_type type;
@@ -6895,6 +6771,10 @@ static std::vector<std::unique_ptr<test_case>> make_test_cases_eval() {
68956771
test_cases.emplace_back(new test_ceil (type, {7, 1, 5, 3}));
68966772
test_cases.emplace_back(new test_round (type, {7, 1, 5, 3}));
68976773
test_cases.emplace_back(new test_trunc (type, {7, 1, 5, 3}));
6774+
<<<<<<< HEAD
6775+
=======
6776+
6777+
>>>>>>> 9fef9eefb (add tests)
68986778
}
68996779

69006780
test_cases.emplace_back(new test_diag_mask_inf(GGML_TYPE_F32, {10, 10, 1, 1}, 5));

0 commit comments

Comments
 (0)