clDNN
eltwise.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/eltwise.h"
20 #include "primitive.hpp"
21 
22 namespace cldnn
23 {
30 
32 enum class eltwise_mode : int32_t
33 {
42 };
43 
49 struct eltwise : public primitive_base<eltwise, CLDNN_PRIMITIVE_DESC(eltwise)>
50 {
51  CLDNN_DECLATE_PRIMITIVE(eltwise)
52 
53 
54  eltwise(
61  const primitive_id& id,
62  const primitive_id& input,
63  const primitive_id& input2,
65  bool with_activation = false,
66  float activation_slp = 0.0f,
67  const padding& output_padding = padding()
68  )
69  :primitive_base(id, { input, input2 }, output_padding)
70  , mode(mode)
72  , activation_negative_slope(activation_slp)
73  {
74  }
75 
77  eltwise(const dto* dto)
79  , mode(static_cast<eltwise_mode>(dto->mode))
82  {
83  if (dto->input.size != 2)
84  throw std::invalid_argument("eltiwise dto should containt exactly two inputs");
85  }
86 
93 
94 protected:
95  void update_dto(dto& dto) const override
96  {
97  dto.mode = static_cast<cldnn_eltwise_mode>(mode);
100  }
101 };
105 }
Eltwise subtract.
cldnn_eltwise_mode
Select mode for eltwise layer ( cldnn_eltwise_desc ​).
Definition: eltwise.h:34
Represents data padding information.
Definition: layout.hpp:125
Eltwise max.
Definition: eltwise.h:41
eltwise(const dto *dto)
Constructs a copy from C API cldnn_eltwise_desc.
Definition: eltwise.hpp:77
Performs elementwise operations (sum, subtract, max or product) on two input primitives Also supports...
Definition: eltwise.h:51
Eltwise subtract.
Definition: eltwise.h:39
size_t size
Number of ids in the array.
Definition: cldnn.h:338
eltwise(const primitive_id &id, const primitive_id &input, const primitive_id &input2, eltwise_mode mode, bool with_activation=false, float activation_slp=0.0f, const padding &output_padding=padding())
Constructs eltwise primitive.
Definition: eltwise.hpp:60
uint32_t with_activation
Enables Relu activation.
Definition: eltwise.h:55
bool with_activation
Enables Relu activation.
Definition: eltwise.hpp:90
eltwise_mode
Select mode for the eltwise layer.
Definition: eltwise.hpp:32
cldnn_primitive_id_arr input
Input primitives ids.
Definition: eltwise.h:51
float activation_negative_slope
Relu activation slope.
Definition: eltwise.h:57
Eltwise sum.
Definition: eltwise.h:37
Performs elementwise operations (sum, subtract, max or product) on two input primitives Also supports...
Definition: eltwise.hpp:49
eltwise_mode mode
Definition: eltwise.hpp:88
float activation_negative_slope
Relu activation slope.
Definition: eltwise.hpp:92
std::string primitive_id
Unique id of a primitive within a topology.
Definition: primitive.hpp:42
Eltwise product (Hamarad).
Eltwise product (Hamarad).
Definition: eltwise.h:43
fixed_size_vector_ref input
List of ids of input primitives.
Definition: primitive.hpp:146
int32_t mode
Eltwise mode. See cldnn_eltwise_mode.
Definition: eltwise.h:53
base class for all primitives implementations.
Definition: primitive.hpp:190
padding output_padding
Requested output padding.
Definition: primitive.hpp:149