clDNN
fully_connected.hpp
1 /*
2 // Copyright (c) 2016 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16 
18 #pragma once
19 #include "../C/fully_connected.h"
20 #include "primitive.hpp"
21 
22 namespace cldnn
23 {
30 
36 
52 
53 struct fully_connected : public primitive_base<fully_connected, CLDNN_PRIMITIVE_DESC(fully_connected)>
54 {
55  CLDNN_DECLATE_PRIMITIVE(fully_connected)
56 
57 
65  const primitive_id& id,
66  const primitive_id& input,
67  const primitive_id& weights,
68  const primitive_id& bias = "",
69  bool with_activation = false,
70  float activation_slp = 0.0f,
71  const padding& output_padding = padding()
72  )
74  , weights(weights)
75  , bias(bias)
77  , activation_negative_slope(activation_slp)
78  {
79  }
80 
84  , weights(dto->weights)
85  , bias(dto->bias)
88  {
89  }
90 
99 
100 protected:
101  std::vector<std::reference_wrapper<const primitive_id>> get_dependencies() const override
102  {
103  if (bias.empty())
104  return{ weights };
105  else
106  return{ weights, bias };
107  }
108 
109  void update_dto(dto& dto) const override
110  {
111  dto.weights = weights.c_str();
112  dto.bias = bias.c_str();
113  dto.with_activation = with_activation;
114  dto.activation_negative_slope = activation_negative_slope;
115  }
116 };
120 }
fully_connected(const dto *dto)
Constructs a copy from basic C API cldnn_fully_connected_desc.
Represents data padding information.
Definition: layout.hpp:125
primitive_id bias
Primitive id containing bias data.
Performs forward fully connected layer (inner product). Also supports built-in Relu cldnn_activation_...
bool with_activation
Enable Relu activation.
primitive_id weights
Primitive id containing weights data.
std::string primitive_id
Unique id of a primitive within a topology.
Definition: primitive.hpp:42
fully_connected(const primitive_id &id, const primitive_id &input, const primitive_id &weights, const primitive_id &bias="", bool with_activation=false, float activation_slp=0.0f, const padding &output_padding=padding())
Constructs fully connected layer.
float activation_negative_slope
Relu activation slope.
fixed_size_vector_ref input
List of ids of input primitives.
Definition: primitive.hpp:146
base class for all primitives implementations.
Definition: primitive.hpp:190
padding output_padding
Requested output padding.
Definition: primitive.hpp:149
Performs forward fully connected layer (inner product). Also supports built-in Relu cldnn_activation_...