Go to the source code of this file.
◆ ck_indexed_scale_f32()
| int ck_indexed_scale_f32 |
( |
const float * | values, |
|
|
const int32_t * | ids, |
|
|
const float * | scales, |
|
|
float * | output, |
|
|
size_t | count, |
|
|
size_t | scale_count ) |
Definition at line 3 of file indexed_scale.c.
5 {
6 if (!
count || !scale_count ||
9 (uintptr_t)
ids % _Alignof(int32_t) != 0 ||
10 count > (UINTPTR_MAX - (uintptr_t)
ids) /
sizeof(*
ids)) {
11 return -1;
12 }
13
14 uintptr_t output_begin = (uintptr_t)output;
15 uintptr_t ids_begin = (uintptr_t)
ids;
18 (output_begin < ids_begin +
count *
sizeof(*
ids) &&
19 ids_begin < output_begin +
count *
sizeof(*output))) {
20 return -1;
21 }
22
23 for (
size_t i = 0; i <
count; ++i) {
25 if (id < 0 || (size_t)id >= scale_count) {
26 return -2;
27 }
30 return -3;
31 }
32 }
33 for (
size_t i = 0; i <
count; ++i) {
34 output[i] = values[i] * scales[
ids[i]];
35 }
36 return 0;
37}
static int product(size_t a, size_t b, size_t *out)
static int ck_checked_region(const float *ptr, size_t n)
static int ck_checked_overlap(const float *a, size_t na, const float *b, size_t nb)
const uint8_t size_t count
References ck_checked_overlap(), ck_checked_region(), count, id, ids, and product().