FlexNN 1
Fully connected neural network built from scratch with flexible n-layer design and multiple activations.
Loading...
Searching...
No Matches
LayerTypes.hpp
Go to the documentation of this file.
1
10#pragma once
11
12#include <cstdint>
13#include <type_traits>
14
15namespace FlexNN::Layers {
16
22enum class LayerType : uint8_t {
23 Dense = 0,
24 Conv1D = 1,
25 BatchNorm1D = 2,
26 MaxPool1D = 3,
27 AvgPool1D = 4
28};
29static_assert(sizeof(LayerType) == 1, "LayerType must be 1 byte for model.bin");
30static_assert(std::is_same_v<std::underlying_type_t<LayerType>, uint8_t>,
31 "LayerType underlying type must be uint8_t");
32
39enum class DType : uint16_t {
40 F32 = 0
41};
42static_assert(sizeof(DType) == 2, "DType must be 2 bytes for model.bin");
43static_assert(std::is_same_v<std::underlying_type_t<DType>, uint16_t>,
44 "DType underlying type must be uint16_t");
45
50 int inputSize = 0;
51 int outputSize = 0;
52};
53
65 int inChannels = 0;
66 int outChannels = 0;
67 int kernelSize = 0;
68 int stride = 1;
69 int padding = 0;
70 int dilation = 1;
71};
72
79 int channels = 0;
80 int kernelSize = 0;
81 int stride = 1;
82 int padding = 0;
83};
84
93 int numFeatures = 0;
94 float epsilon = 1e-5f;
95 float momentum = 0.1f;
96};
97
98} // namespace FlexNN::Layers
Definition Pool1D.hpp:58
Definition BatchNorm1D.hpp:26
Definition Conv1D.hpp:28
Fully-connected layer: Z = W*X + b, A = act(Z).
Definition Dense.hpp:31
Definition Pool1D.hpp:22
Definition BatchNorm1D.hpp:24
DType
Data type for blobs in model.bin.
Definition LayerTypes.hpp:39
@ F32
float32 little-endian
LayerType
Layer kind, stable on-wire (uint8_t).
Definition LayerTypes.hpp:22
Parameters for BatchNorm1D.
Definition LayerTypes.hpp:92
int numFeatures
Definition LayerTypes.hpp:93
float momentum
Definition LayerTypes.hpp:95
float epsilon
Definition LayerTypes.hpp:94
Parameters for a Conv1D layer.
Definition LayerTypes.hpp:64
int outChannels
Definition LayerTypes.hpp:66
int kernelSize
Definition LayerTypes.hpp:67
int stride
Definition LayerTypes.hpp:68
int dilation
Must be 1 in v0.1 (export error otherwise)
Definition LayerTypes.hpp:70
int inChannels
Definition LayerTypes.hpp:65
int padding
Definition LayerTypes.hpp:69
Parameters for a Dense layer.
Definition LayerTypes.hpp:49
int outputSize
Number of output neurons (rows of Z/A)
Definition LayerTypes.hpp:51
int inputSize
Number of input features (rows of X)
Definition LayerTypes.hpp:50
Parameters for pooling layers (Max and Avg share this POD).
Definition LayerTypes.hpp:78
int stride
Default 1 to avoid div-by-zero in L_out.
Definition LayerTypes.hpp:81
int padding
Definition LayerTypes.hpp:82
int channels
Definition LayerTypes.hpp:79
int kernelSize
Definition LayerTypes.hpp:80