← Back to C-Kernel-Engine Docs Doxygen Source Documentation
Loading...
Searching...
No Matches
linear_rows_bf16_rne_checked.c File Reference
#include "checked_float_buffer.h"
#include "ckernel_engine.h"
#include <limits.h>
#include <string.h>

Go to the source code of this file.

Functions

int linear_rows_bf16_rne_checked_f32 (const float *input, size_t input_elements, const void *weight, size_t weight_bytes, float *output, size_t output_elements, size_t rows, size_t width, size_t channels, float *work, size_t work_elements)

Function Documentation

◆ linear_rows_bf16_rne_checked_f32()

int linear_rows_bf16_rne_checked_f32 ( const float * input,
size_t input_elements,
const void * weight,
size_t weight_bytes,
float * output,
size_t output_elements,
size_t rows,
size_t width,
size_t channels,
float * work,
size_t work_elements )

Definition at line 7 of file linear_rows_bf16_rne_checked.c.

12{
13 size_t in, out, weights;
14 if (rows > INT_MAX - 128 || width > INT_MAX - 128 || channels > INT_MAX - 128 ||
15 !ck_checked_span(rows, width, width, &in) ||
16 !ck_checked_span(rows, channels, channels, &out) ||
17 !ck_checked_span(channels, width, width, &weights) ||
18 in > input_elements || out > output_elements || out > work_elements ||
19 weight_bytes != weights * sizeof(uint16_t)) return -2;
20 const uintptr_t w = (uintptr_t)weight, s = (uintptr_t)work, y = (uintptr_t)output;
21 if (!weight || w % _Alignof(uint16_t) || w > UINTPTR_MAX - weight_bytes ||
22 !ck_checked_region(input, in) || !ck_checked_region(output, out) ||
23 !ck_checked_region(work, out) ||
24 ck_checked_overlap(input, in, output, out) ||
25 ck_checked_overlap(work, out, input, in) ||
26 ck_checked_overlap(work, out, output, out) ||
27 (y < w + weight_bytes && w < y + out * sizeof(float)) ||
28 (s < w + weight_bytes && w < s + out * sizeof(float))) return -1;
29 if (!ck_checked_finite_bulk(input, in)) return -3;
30
31 gemm_nt_bf16_parallel_dispatch(input, weight, NULL, work, (int)rows, (int)channels, (int)width);
32 if (!ck_checked_finite_bulk(work, out)) return -3;
33 memcpy(output, work, out * sizeof(float));
34 return 0;
35}
static int ck_checked_span(size_t rows, size_t width, size_t stride, size_t *span)
static int ck_checked_finite_bulk(const float *ptr, size_t n)
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)
void gemm_nt_bf16_parallel_dispatch(const float *A, const void *B, const float *bias, float *C, int M, int N, int K)

References ck_checked_finite_bulk(), ck_checked_overlap(), ck_checked_region(), ck_checked_span(), and gemm_nt_bf16_parallel_dispatch().