-
Notifications
You must be signed in to change notification settings - Fork 115
/
dl_layer_model.hpp
52 lines (46 loc) · 1.43 KB
/
dl_layer_model.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#pragma once
#include "dl_constant.hpp"
#include "dl_variable.hpp"
namespace dl
{
namespace layer
{
/**
* @brief Neural Network Model.
*
* @tparam feature_t supports int16_t and int8_t,
* - int16_t: stands for operation in int16_t quantize
* - int8_t: stands for operation in int8_t quantize
*/
template <typename feature_t>
class Model
{
private:
std::vector<int> input_shape; /*<! input shape in [height, width, channel] >*/
public:
/**
* @brief Destroy the Model object.
*
*/
virtual ~Model() {}
/**
* @brief Build a model including update output shape and input padding of each layer.
*
* @param input as an input
*/
virtual void build(Tensor<feature_t> &input) = 0;
/**
* @brief Call the model layer by layer.
*
* @param input as an input.
*/
virtual void call(Tensor<feature_t> &input) = 0;
/**
* @brief If input.shape changes, call Model.build(), otherwise, do not. Then call Model.call().
*
* @param input as an input
*/
void forward(Tensor<feature_t> &input);
};
} // namespace layer
} // namespace dl