-
Notifications
You must be signed in to change notification settings - Fork 13.4k
CPU: Add support for FLOOR,CEIL,ROUND and TRUNC unary operators #16083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 5 commits
51040ed
20aa499
95b3127
4866260
f340abc
2bd2a5a
bcb1c8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1144,9 +1144,13 @@ static const char * GGML_UNARY_OP_NAME[GGML_UNARY_OP_COUNT] = { | |
"EXP", | ||
"GELU_ERF", | ||
"XIELU", | ||
"FLOOR", | ||
"CEIL", | ||
"ROUND", | ||
"TRUNC", | ||
}; | ||
|
||
static_assert(GGML_UNARY_OP_COUNT == 16, "GGML_UNARY_OP_COUNT != 16"); | ||
static_assert(GGML_UNARY_OP_COUNT == 20, "GGML_UNARY_OP_COUNT != 20"); | ||
|
||
static const char * GGML_GLU_OP_NAME[GGML_GLU_OP_COUNT] = { | ||
"REGLU", | ||
|
@@ -2749,6 +2753,62 @@ static struct ggml_tensor * ggml_glu_impl( | |
return result; | ||
} | ||
|
||
// ggml_floor | ||
|
||
struct ggml_tensor * ggml_floor( | ||
struct ggml_context * ctx, | ||
struct ggml_tensor * a) { | ||
return ggml_unary(ctx, a, GGML_UNARY_OP_FLOOR); | ||
} | ||
|
||
struct ggml_tensor * ggml_floor_inplace( | ||
struct ggml_context * ctx, | ||
struct ggml_tensor * a) { | ||
return ggml_unary_inplace(ctx, a, GGML_UNARY_OP_FLOOR); | ||
} | ||
|
||
// ggml_ceil | ||
|
||
struct ggml_tensor * ggml_ceil( | ||
struct ggml_context * ctx, | ||
struct ggml_tensor * a) { | ||
return ggml_unary(ctx, a, GGML_UNARY_OP_CEIL); | ||
} | ||
|
||
struct ggml_tensor * ggml_ceil_inplace( | ||
struct ggml_context * ctx, | ||
struct ggml_tensor * a) { | ||
return ggml_unary_inplace(ctx, a, GGML_UNARY_OP_CEIL); | ||
} | ||
|
||
//ggml_round | ||
|
||
struct ggml_tensor * ggml_round( | ||
struct ggml_context * ctx, | ||
struct ggml_tensor * a) { | ||
return ggml_unary(ctx, a, GGML_UNARY_OP_ROUND); | ||
} | ||
|
||
struct ggml_tensor * ggml_round_inplace( | ||
struct ggml_context * ctx, | ||
struct ggml_tensor * a) { | ||
return ggml_unary_inplace(ctx, a, GGML_UNARY_OP_ROUND); | ||
} | ||
|
||
//ggml_trunc | ||
|
||
struct ggml_tensor * ggml_trunc( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. IMO the naming There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thank you for your feedback! |
||
struct ggml_context * ctx, | ||
struct ggml_tensor * a) { | ||
return ggml_unary(ctx, a, GGML_UNARY_OP_TRUNC); | ||
} | ||
|
||
struct ggml_tensor * ggml_trunc_inplace( | ||
struct ggml_context * ctx, | ||
struct ggml_tensor * a) { | ||
return ggml_unary_inplace(ctx, a, GGML_UNARY_OP_TRUNC); | ||
} | ||
|
||
struct ggml_tensor * ggml_glu( | ||
struct ggml_context * ctx, | ||
struct ggml_tensor * a, | ||
|
Uh oh!
There was an error while loading. Please reload this page.