@@ -3512,6 +3512,45 @@ struct test_log : public test_case {
35123512 }
35133513};
35143514
3515+ // GGML_OP_FLOOR
3516+ struct test_floor : public test_case {
3517+ const ggml_type type;
3518+ const std::array<int64_t , 4 > ne;
3519+
3520+ std::string vars () override {
3521+ return VARS_TO_STR2 (type, ne);
3522+ }
3523+
3524+ test_floor (ggml_type type = GGML_TYPE_F32,
3525+ std::array<int64_t , 4 > ne = {10 , 5 , 4 , 3 })
3526+ : type(type), ne(ne) {}
3527+
3528+ ggml_tensor * build_graph (ggml_context * ctx) override {
3529+ ggml_tensor * a = ggml_new_tensor (ctx, type, 4 , ne.data ());
3530+ ggml_set_param (a);
3531+ ggml_set_name (a, " a" );
3532+
3533+ ggml_tensor * out = ggml_floor (ctx, a);
3534+ ggml_set_name (out, " out" );
3535+
3536+ return out;
3537+ }
3538+
3539+ void initialize_tensors (ggml_context * ctx) override {
3540+ for (ggml_tensor * t = ggml_get_first_tensor (ctx); t != NULL ; t = ggml_get_next_tensor (ctx, t)) {
3541+ init_tensor_uniform (t, -10 .0f , 10 .0f );
3542+ }
3543+ }
3544+
3545+ float grad_eps () override {
3546+ return 1 .0f ;
3547+ }
3548+
3549+ bool grad_precise () override {
3550+ return true ;
3551+ }
3552+ };
3553+
35153554// GGML_OP_SIN
35163555struct test_sin : public test_case {
35173556 const ggml_type type;
@@ -6176,6 +6215,7 @@ static std::vector<std::unique_ptr<test_case>> make_test_cases_eval() {
61766215 test_cases.emplace_back (new test_sqr (type));
61776216 test_cases.emplace_back (new test_sqrt (type));
61786217 test_cases.emplace_back (new test_log (type));
6218+ test_cases.emplace_back (new test_floor (type));
61796219 test_cases.emplace_back (new test_sin (type));
61806220 test_cases.emplace_back (new test_cos (type));
61816221 test_cases.emplace_back (new test_clamp (type));
0 commit comments