MyCaffe  1.12.2.41
Deep learning software for Windows C# programmers.
LayerFactory.cs
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.Threading.Tasks;
6using MyCaffe.basecode;
7using MyCaffe.common;
8using MyCaffe.db.image;
9using MyCaffe.param;
10
15{
20 {
31 {
32 switch (p.type)
33 {
34 case LayerParameter.LayerType.CAUSAL_SELF_ATTENTION:
35 return new CausalSelfAttentionLayer<double>(cuda, log, p);
36
37 case LayerParameter.LayerType.MULTIHEAD_ATTENTION:
38 return new MultiheadAttentionLayer<double>(cuda, log, p);
39
40 case LayerParameter.LayerType.POSITIONAL_ENCODER:
41 return new PositionalEncodingLayer<double>(cuda, log, p);
42
43 case LayerParameter.LayerType.GELU:
44 return new GeluLayer<double>(cuda, log, p);
45
46 case LayerParameter.LayerType.LAYERNORM:
47 return new LayerNormLayer<double>(cuda, log, p);
48
49 case LayerParameter.LayerType.TRANSFORMER_BLOCK:
50 return new TransformerBlockLayer<double>(cuda, log, p);
51
52 case LayerParameter.LayerType.TOKENIZED_DATA:
53 return new TokenizedDataLayer<double>(cuda, log, p, db, evtCancel);
54
55 case LayerParameter.LayerType.TOKENIZED_DATA_PAIRS:
56 return new TokenizedDataPairsLayer<double>(cuda, log, p, db, evtCancel);
57
58 case LayerParameter.LayerType.NLL_LOSS:
59 return new NLLLossLayer<double>(cuda, log, p);
60
61 default:
62 return null;
63 }
64 }
65
76 {
77 switch (p.type)
78 {
79 case LayerParameter.LayerType.CAUSAL_SELF_ATTENTION:
80 return new CausalSelfAttentionLayer<float>(cuda, log, p);
81
82 case LayerParameter.LayerType.MULTIHEAD_ATTENTION:
83 return new MultiheadAttentionLayer<float>(cuda, log, p);
84
85 case LayerParameter.LayerType.POSITIONAL_ENCODER:
86 return new PositionalEncodingLayer<float>(cuda, log, p);
87
88 case LayerParameter.LayerType.GELU:
89 return new GeluLayer<float>(cuda, log, p);
90
91 case LayerParameter.LayerType.LAYERNORM:
92 return new LayerNormLayer<float>(cuda, log, p);
93
94 case LayerParameter.LayerType.TRANSFORMER_BLOCK:
95 return new TransformerBlockLayer<float>(cuda, log, p);
96
97 case LayerParameter.LayerType.TOKENIZED_DATA:
98 return new TokenizedDataLayer<float>(cuda, log, p, db, evtCancel);
99
100 case LayerParameter.LayerType.TOKENIZED_DATA_PAIRS:
101 return new TokenizedDataPairsLayer<float>(cuda, log, p, db, evtCancel);
102
103 case LayerParameter.LayerType.NLL_LOSS:
104 return new NLLLossLayer<float>(cuda, log, p);
105
106 default:
107 return null;
108 }
109 }
110 }
111}
The CancelEvent provides an extension to the manual cancel event that allows for overriding the manua...
Definition: CancelEvent.cs:17
The Log class provides general output in text form.
Definition: Log.cs:13
The CudaDnn object is the main interface to the Low-Level Cuda C++ DLL.
Definition: CudaDnn.cs:969
An interface for the units of computation which can be composed into a Net.
Definition: Layer.cs:31
The CausalSelfAttention provides a vanilla multi-head self-attention layer with projection at the end...
The GeluLayer implements the New GELU activation function currently in Google BERT repo (same as Open...
Definition: GeluLayer.cs:24
The LayerFactor is responsible for creating all layers implemented in the MyCaffe....
Definition: LayerFactory.cs:20
Layer< float > CreateSingle(CudaDnn< float > cuda, Log log, LayerParameter p, CancelEvent evtCancel, IXDatabaseBase db)
Create the layers when using the float base type.
Definition: LayerFactory.cs:75
Layer< double > CreateDouble(CudaDnn< double > cuda, Log log, LayerParameter p, CancelEvent evtCancel, IXDatabaseBase db)
Create the layers when using the double base type.
Definition: LayerFactory.cs:30
The LayerNormalizationLayer performs layer normalization similar to the PyTorch LayerNorm layer.
The MultiheadAttention provides a vanilla multi-head layer.
Computes the nll loss for a one-of-many classification task, passing real-valued predictions (from a ...
Definition: NLLLossLayer.cs:23
The PositionalEncodingLayer is a neuron layer that adds positional encoding to the input.
The TokenizedDataLayer loads and tokenizes data for a transformer model where data is loaded in the f...
The TokenizedDataPairsLayer loads and tokenizes data for a transformer model where data is loaded in ...
The TransformerBlock provides a generic transformer block
Specifies the base parameter for all layers.
LayerType type
Specifies the type of this LayerParameter.
LayerType
Specifies the layer type.
The ILayerCreator interface is implemented by each MyCaffe.layers.x layer extension dll and is used t...
Definition: Interfaces.cs:19
The IXDatabaseBase interface defines the general interface to the in-memory database.
Definition: Interfaces.cs:444
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
Definition: Annotation.cs:12
The MyCaffe.common namespace contains common MyCaffe classes.
Definition: BatchInput.cs:8
The MyCaffe.db.image namespace contains all image database related classes.
Definition: Database.cs:18
The MyCaffe.layers.gpt namespace contains all GPT related layers.
Definition: LayerFactory.cs:15
The MyCaffe.param namespace contains parameters used to create models.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...
Definition: Annotation.cs:12