← Back to C-Kernel-Engine Docs Doxygen Source Documentation
 
Loading...
Searching...
No Matches
ckernel_feature_concat_checked.h File Reference
#include <stddef.h>

Go to the source code of this file.

Functions

int feature_concat_broadcast_rows_f32 (const float *input, size_t input_elements, size_t input_stride, const float *feature, size_t feature_elements, float *output, size_t output_elements, size_t output_stride, size_t rows, size_t input_channels, size_t feature_channels, size_t output_channels)
 

Function Documentation

◆ feature_concat_broadcast_rows_f32()

int feature_concat_broadcast_rows_f32 ( const float *  input,
size_t  input_elements,
size_t  input_stride,
const float *  feature,
size_t  feature_elements,
float *  output,
size_t  output_elements,
size_t  output_stride,
size_t  rows,
size_t  input_channels,
size_t  feature_channels,
size_t  output_channels 
)

Definition at line 6 of file feature_concat_broadcast_rows.c.

11 {
12 size_t ni, no, width;
13 if (!rows || !input_channels || !feature_channels ||
14 input_channels > (size_t)INT_MAX ||
15 feature_channels > (size_t)INT_MAX - input_channels) return -2;
16 width = input_channels + feature_channels;
17 if (output_channels != width) return -2;
18 if (!ck_checked_span(rows, input_channels, input_stride, &ni) ||
19 !ck_checked_span(rows, width, output_stride, &no) ||
20 input_elements < ni || feature_elements < feature_channels ||
21 output_elements < no) return -2;
22 if (!ck_checked_region(input, ni) ||
23 !ck_checked_region(feature, feature_channels) ||
24 !ck_checked_region(output, no) ||
25 ck_checked_overlap(output, no, input, ni) ||
26 ck_checked_overlap(output, no, feature, feature_channels)) return -1;
27 if (!ck_checked_finite(feature, feature_channels)) return -3;
28 for (size_t r = 0; r < rows; ++r)
29 if (!ck_checked_finite(input + r * input_stride, input_channels)) return -3;
30 for (size_t r = 0; r < rows; ++r)
31 /* The existing provider owns the exact copy semantics. A one-row
32 * call broadcasts the same feature vector without staging memory. */
33 feature_concat(input + r * input_stride, feature,
34 output + r * output_stride,
35 1, (int)input_channels, (int)feature_channels, 1);
36 return 0;
37}
static int ck_checked_finite(const float *ptr, size_t n)
static int ck_checked_span(size_t rows, size_t width, size_t stride, size_t *span)
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 feature_concat(const float *main_input, const float *branch_input, float *output, int rows, int main_dim, int branch_slice_dim, int num_branch_slices)

References ck_checked_finite(), ck_checked_overlap(), ck_checked_region(), ck_checked_span(), and feature_concat().