Navigation
API > API/Plugins > API/Plugins/NNERuntimeBasicCpu
This class can be used to construct Models for use with the Basic CPU Runtime. Effectively it works by constructing the model in-memory and then serializing this out to create a FileData object which can then be loaded with NNE.
Note: If you pass your own views into this model builder they must out-live the builder itself as it will not create internal copies. If you want to create an internal copy use the `MakeValuesCopy_ function.
| Name | FModelBuilder |
| Type | class |
| Header File | /Engine/Plugins/Experimental/NNERuntimeBasicCpu/Source/NNERuntimeBasicCpu/Public/NNERuntimeBasicCpuBuilder.h |
| Include Path | #include "NNERuntimeBasicCpuBuilder.h" |
Syntax
class FModelBuilder
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FModelBuilder
(
int32 Seed |
Construct a new Model Builder with the given random seed. | NNERuntimeBasicCpuBuilder.h |
Structs
| Name | Remarks |
|---|---|
| FLinearLayerSettings | Linear Layer settings including the type of layer and the way the weights are initialized |
| FWeightInitializationSettings | There is a clang compiler bug that requires the following classes to declare a default constructor in the cpp file as a workaround: |
Enums
Public
| Name | Remarks |
|---|---|
| EActivationFunction | Common activation function types. |
| ELinearLayerType | Linear Layer types. |
| EPaddingMode | Padding Mode for Convolutions |
| EWeightInitializationType | Weight initialization types. |
Constants
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| RngInitialState | uint32 | Default initial state for the random number generator. | NNERuntimeBasicCpuBuilder.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| CompressedWeightsPool | TArray< TArray< uint16 > > | Pool of all compressed weights data used by the `MakeCompressedWeights_ functions. | NNERuntimeBasicCpuBuilder.h | |
| Rng | uint32 | Random Number State for generating random weights | NNERuntimeBasicCpuBuilder.h | |
| SizesPool | TArray< TArray< uint32 > > | Pool of all sizes data used by the `MakeSizes_ functions. | NNERuntimeBasicCpuBuilder.h | |
| WeightsPool | TArray< TArray< float > > | Pool of all weights data used by the MakeValues_, MakeWeights_`MakeBiases_ functions. |
NNERuntimeBasicCpuBuilder.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
uint64 GetWriteByteNum
(
const FModelBuilderElement& Element |
Get the number of bytes this builder currently wants to write for the given element. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeActivation
(
const uint32 InputOutputSize, |
Makes a new activation layer with the given activation function | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeAggregateOrExclusive
(
const uint32 OutputEncodingSize, |
Make a layer which aggregates an Exclusive Or of other observations. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeAggregateOrInclusive
(
const uint32 OutputEncodingSize, |
Make a layer which aggregates an Inclusive Or of other observations using attention. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeAggregateSet
(
const uint32 MaxElementNum, |
Make a layer which aggregates a set of other observations using attention. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeArray
(
const uint32 ElementNum, |
Make a layer which runs the given sublayer on an array of elements. | NNERuntimeBasicCpuBuilder.h | |
TArrayView< float > MakeBiasesRandomKaimingGaussian
(
const uint32 Size, |
Creates a array of biases randomly initialized using the Gaussian Kaiming method | NNERuntimeBasicCpuBuilder.h | |
TArrayView< float > MakeBiasesRandomKaimingUniform
(
const uint32 Size, |
Creates a array of biases randomly initialized using the Uniform Kaiming method# | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeClamp
(
const uint32 InputOutputSize, |
Makes a Clamp Layer | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeCompressedLinear
(
const uint32 InputSize, |
Makes a new compressed linear layer. | NNERuntimeBasicCpuBuilder.h | |
void MakeCompressedWeightsRandomKaimingGaussian
(
TArrayView< uint16 >& OutWeightsView, |
Creates a array of weights randomly initialized using the Gaussian Kaiming method and compresses them | NNERuntimeBasicCpuBuilder.h | |
void MakeCompressedWeightsRandomKaimingUniform
(
TArrayView< uint16 >& OutWeightsView, |
Creates a array of weights randomly initialized using the Uniform Kaiming method and compresses them | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeConcat
(
const TConstArrayView< FModelBuilderElement > Elements |
Makes a Concat layer, which will evaluate each of the given elements on different slices of the input vector, concatenating the result into the output vector. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeConv1d
(
const uint32 InputLength, |
Make a new 1D Convolution Layer. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeConv2d
(
const uint32 InputHeight, |
Make a new 2D Convolution Layer. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeCopy
(
const uint32 InputOutputSize |
Makes a Copy Layer | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeDenormalize
(
const uint32 InputOutputSize, |
Makes a new Denormalization layer. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeELU
(
const uint32 InputOutputSize |
Makes a ELU Activation Layer | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeFiLMNetwork
(
const FModelBuilderElement& Prefix, |
Make a new FiLM conditioned Network. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeGELU
(
const uint32 InputOutputSize |
Makes a GELU Activation Layer | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeGRUCell
(
const uint32 InputNum, |
Make a new GRU Cell layer. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeGRUCellLayer
(
const uint32 InputNum, |
Make a new GRU Cell layer with the given linear layer settings. | NNERuntimeBasicCpuBuilder.h | |
TArrayView< float > MakeInitialBiases
(
const uint32 OutputSize, |
Creates a array of biases initialized using the given settings | NNERuntimeBasicCpuBuilder.h | |
void MakeInitialCompressedWeights
(
TArrayView< uint16 >& OutWeightsView, |
Creates a array of weights randomly initialized using the given settings and compresses them | NNERuntimeBasicCpuBuilder.h | |
TArrayView< float > MakeInitialWeights
(
const uint32 InputSize, |
Creates a array of weights initialized using the given settings | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeLayerNorm
(
const uint32 InputOutputSize, |
Makes a new Layer Norm layer. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeLinear
(
const uint32 InputSize, |
Makes a new linear layer. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeLinearLayer
(
const uint32 InputSize, |
Makes a new linear layer with the given settings. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeLipschiztLinear
(
const uint32 InputSize, |
Makes a new Lipschizt linear layer. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeMemoryBackbone
(
const uint32 MemoryNum, |
Make a new Memory Backbone layer. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeMemoryCell
(
const uint32 InputNum, |
Make a new Memory Cell layer. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeMemoryCellLayer
(
const uint32 InputNum, |
Make a new Memory Cell layer with the given linear layer settings. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeMLP
(
const uint32 InputSize, |
Makes a Multi-Layer Perceptron network. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeMLPWithLayerNorm
(
const uint32 InputSize, |
Makes a Multi-Layer Perceptron network with LayerNorm before all activations. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeMultiLinear
(
const uint32 InputSize, |
Makes a new multi linear layer. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeNormalize
(
const uint32 InputOutputSize, |
Makes a new Normalization layer. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakePReLU
(
const uint32 InputOutputSize, |
Makes a PReLU Activation Layer | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeReLU
(
const uint32 InputOutputSize |
Makes a ReLU Activation Layer | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeResidual
(
const FModelBuilderElement& SubLayer |
Make a residual layer which adds the result of evaluating the given sublayer on the input, to the input. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeResidualMLP
(
const uint32 InputSize, |
Makes a Multi-Layer Perceptron network using Residual layers. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeResidualMLPWithLayerNorm
(
const uint32 InputSize, |
Makes a Multi-Layer Perceptron network using Residual layers followed by LayerNorm layers. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeSequence
(
const TConstArrayView< FModelBuilderElement > Elements |
Makes a Sequence layer, which will evaluate the given list of layers in order. | NNERuntimeBasicCpuBuilder.h | |
TArrayView< uint32 > MakeSizesLayerInputs
(
const TConstArrayView< FModelBuilderElement > Elements |
Creates an array of sizes from an array of builder elements' input sizes. | NNERuntimeBasicCpuBuilder.h | |
TArrayView< uint32 > MakeSizesLayerOutputs
(
const TConstArrayView< FModelBuilderElement > Elements |
Creates an array of sizes from an array of builder elements' output sizes. | NNERuntimeBasicCpuBuilder.h | |
TArrayView< uint32 > MakeSizesZero
(
const uint32 Size |
Creates an array of sizes, initialized to zero. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeSkipMLP
(
const uint32 InputSize, |
Makes a Multi-Layer Perceptron network using Skip layers that concatenate the input to each intermediate layer. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeSkipMLPWithLayerNorm
(
const uint32 InputSize, |
Makes a Multi-Layer Perceptron network using Skip layers that concatenate the input to each intermediate layer followed by a LayerNorm. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeSlice
(
const uint32 InputSize, |
Makes a Slice Layer | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeSparseMixtureOfExperts
(
const uint32 InputNum, |
Make a new Top-Two Sparse Mixture of Experts Layer. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeSpread
(
const TConstArrayView< FModelBuilderElement > Elements |
Makes a Spread layer, which will evaluate each of the given elements on the input vector, concatenating the result into the output vector. | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeTanH
(
const uint32 InputOutputSize |
Makes a TanH Activation Layer | NNERuntimeBasicCpuBuilder.h | |
FModelBuilderElement MakeTile
(
const uint32 InputSize, |
Makes a Tile Layer | NNERuntimeBasicCpuBuilder.h | |
TArrayView< float > MakeValuesConstant
(
const uint32 Size, |
Creates a array of values set to the provided constant value of the given size | NNERuntimeBasicCpuBuilder.h | |
TArrayView< float > MakeValuesCopy
(
const TConstArrayView< float > Values |
Creates a array of values from a copy of the given array view | NNERuntimeBasicCpuBuilder.h | |
TArrayView< float > MakeValuesOne
(
const uint32 Size |
Creates a array of values set to one of the given size | NNERuntimeBasicCpuBuilder.h | |
TArrayView< float > MakeValuesZero
(
const uint32 Size |
Creates a array of values set to zero of the given size | NNERuntimeBasicCpuBuilder.h | |
TArrayView< float > MakeWeightsRandomKaimingGaussian
(
const uint32 InputSize, |
Creates a array of weights randomly initialized using the Gaussian Kaiming method | NNERuntimeBasicCpuBuilder.h | |
TArrayView< float > MakeWeightsRandomKaimingUniform
(
const uint32 InputSize, |
Creates a array of weights randomly initialized using the Uniform Kaiming method | NNERuntimeBasicCpuBuilder.h | |
void Reset() |
Reset the builder clearing all memory. | NNERuntimeBasicCpuBuilder.h | |
void WriteFileData
(
TArrayView< uint8 > OutFileData, |
Write the Model to FileData. | NNERuntimeBasicCpuBuilder.h | |
void WriteFileData
(
TArray< uint8 >& OutFileData, |
Write the model to the FileData. | NNERuntimeBasicCpuBuilder.h | |
void WriteFileDataAndReset
(
TArrayView< uint8 > OutFileData, |
Write the model to the FileData and Reset the builder clearing all memory used. | NNERuntimeBasicCpuBuilder.h | |
void WriteFileDataAndReset
(
TArray< uint8 >& OutFileData, |
Write the model to the FileData and Reset the builder clearing all memory used. | NNERuntimeBasicCpuBuilder.h |