oneDNN Wrapper
layers_fwd.h
1 #include "oneapi/dnnl/dnnl.hpp"
2 #include "intel_utils.h"
3 #include "util.h"
4 #include <iostream>
5 #include <stdexcept>
6 #include <cmath>
7 #include <random>
8 #include <time.h>
9 
10 #ifndef _LAYERS_FWD
11 #define _LAYERS_FWD
12 
13 using tag = dnnl::memory::format_tag;
14 using dt = dnnl::memory::data_type;
15 
16 
22 class Dense{
23  public:
24  dnnl::memory arg_src;
25  dnnl::memory arg_dst;
26  dnnl::memory arg_bias;
27  dnnl::memory arg_weights;
37  Dense(int fc_output_size,
38  dnnl::memory input,
39  std::vector<dnnl::primitive> &net,
40  std::vector<std::unordered_map<int, dnnl::memory>> &net_args,
41  dnnl::engine eng);
42  private:
43 
44 
45 };
50 class Conv2D{
51  public:
52  dnnl::memory arg_src;
53  dnnl::memory arg_dst;
54  dnnl::memory arg_bias;
55  dnnl::memory arg_weights;
71  Conv2D(int batch_size, int patch_length,
72  int n_kernels, int kernel_size,
73  int stride_length, int padding_length,
74  int dilation,
75  dnnl::memory input,
76  std::vector<dnnl::primitive> &net,
77  std::vector<std::unordered_map<int, dnnl::memory>> &net_args,
78  dnnl::engine eng);
79  private:
80 
81 };
82 
88 class MaxPool2D{
89  public:
90  dnnl::memory arg_src, arg_dst, arg_workspace;
91  dnnl::pooling_v2_forward::primitive_desc *pooling_fwd_pd;
102  MaxPool2D(int kernel_size, int stride_length,
103  dnnl::memory input,
104  std::vector<dnnl::primitive> &net,
105  std::vector<std::unordered_map<int, dnnl::memory>> &net_args,
106  dnnl::engine eng);
107  private:
108 
109 };
110 
111 #endif
112 
113 
Conv2D allows to create a forward convolution primitive.
Definition: layers_fwd.h:50
dnnl::memory arg_dst
Destination memory handler.
Definition: layers_fwd.h:53
dnnl::memory arg_weights
Weights memory handler.
Definition: layers_fwd.h:55
dnnl::memory arg_src
Source memory handler.
Definition: layers_fwd.h:52
Conv2D(int batch_size, int patch_length, int n_kernels, int kernel_size, int stride_length, int padding_length, int dilation, dnnl::memory input, std::vector< dnnl::primitive > &net, std::vector< std::unordered_map< int, dnnl::memory >> &net_args, dnnl::engine eng)
Construct a new Conv 2 D object.
dnnl::memory arg_bias
Bias memory handler.
Definition: layers_fwd.h:54
Dense allows to create a fully connected layer forward primitive.
Definition: layers_fwd.h:22
dnnl::memory arg_weights
Weights memory handler.
Definition: layers_fwd.h:27
dnnl::memory arg_src
Source memory handler.
Definition: layers_fwd.h:24
Dense(int fc_output_size, dnnl::memory input, std::vector< dnnl::primitive > &net, std::vector< std::unordered_map< int, dnnl::memory >> &net_args, dnnl::engine eng)
Construct a new Dense object.
dnnl::memory arg_dst
Destination memory handler.
Definition: layers_fwd.h:25
dnnl::memory arg_bias
Bias memory handler.
Definition: layers_fwd.h:26
Primitive which provides max pooling.
Definition: layers_fwd.h:88
MaxPool2D(int kernel_size, int stride_length, dnnl::memory input, std::vector< dnnl::primitive > &net, std::vector< std::unordered_map< int, dnnl::memory >> &net_args, dnnl::engine eng)
Construct a new Max Pool 2 D object.