Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
N
ngraph
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
ngraph
Commits
61926759
Commit
61926759
authored
Sep 11, 2018
by
Tomasz Socha
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ONNX] Unary ops
parent
309bfdf0
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
964 additions
and
0 deletions
+964
-0
CMakeLists.txt
src/ngraph/frontend/onnx_import/CMakeLists.txt
+20
-0
abs.hpp
src/ngraph/frontend/onnx_import/op/abs.hpp
+41
-0
cast.cpp
src/ngraph/frontend/onnx_import/op/cast.cpp
+64
-0
cast.hpp
src/ngraph/frontend/onnx_import/op/cast.hpp
+34
-0
ceil.hpp
src/ngraph/frontend/onnx_import/op/ceil.hpp
+41
-0
clip.cpp
src/ngraph/frontend/onnx_import/op/clip.cpp
+64
-0
clip.hpp
src/ngraph/frontend/onnx_import/op/clip.hpp
+34
-0
exp.hpp
src/ngraph/frontend/onnx_import/op/exp.hpp
+41
-0
floor.hpp
src/ngraph/frontend/onnx_import/op/floor.hpp
+41
-0
hard_sigmoid.cpp
src/ngraph/frontend/onnx_import/op/hard_sigmoid.cpp
+71
-0
hard_sigmoid.hpp
src/ngraph/frontend/onnx_import/op/hard_sigmoid.hpp
+34
-0
identity.hpp
src/ngraph/frontend/onnx_import/op/identity.hpp
+34
-0
log.hpp
src/ngraph/frontend/onnx_import/op/log.hpp
+41
-0
log_softmax.hpp
src/ngraph/frontend/onnx_import/op/log_softmax.hpp
+43
-0
neg.hpp
src/ngraph/frontend/onnx_import/op/neg.hpp
+35
-0
reciprocal.cpp
src/ngraph/frontend/onnx_import/op/reciprocal.cpp
+49
-0
reciprocal.hpp
src/ngraph/frontend/onnx_import/op/reciprocal.hpp
+34
-0
softplus.cpp
src/ngraph/frontend/onnx_import/op/softplus.cpp
+52
-0
softplus.hpp
src/ngraph/frontend/onnx_import/op/softplus.hpp
+34
-0
softsign.cpp
src/ngraph/frontend/onnx_import/op/softsign.cpp
+51
-0
softsign.hpp
src/ngraph/frontend/onnx_import/op/softsign.hpp
+34
-0
sqrt.hpp
src/ngraph/frontend/onnx_import/op/sqrt.hpp
+41
-0
ops_bridge.cpp
src/ngraph/frontend/onnx_import/ops_bridge.cpp
+31
-0
No files found.
src/ngraph/frontend/onnx_import/CMakeLists.txt
View file @
61926759
...
...
@@ -37,6 +37,11 @@ add_library(onnx_import STATIC
op/average_pool.hpp
op/batch_norm.cpp
op/batch_norm.hpp
op/cast.cpp
op/cast.hpp
op/ceil.hpp
op/clip.cpp
op/clip.hpp
op/concat.cpp
op/concat.hpp
op/constant.cpp
...
...
@@ -45,12 +50,19 @@ add_library(onnx_import STATIC
op/conv.hpp
op/div.hpp
op/equal.hpp
op/exp.hpp
op/flatten.cpp
op/flatten.hpp
op/floor.hpp
op/gemm.cpp
op/gemm.hpp
op/greater.hpp
op/hard_sigmoid.cpp
op/hard_sigmoid.hpp
op/identity.hpp
op/less.hpp
op/log.hpp
op/log_softmax.hpp
op/matmul.hpp
op/max_pool.cpp
op/max_pool.hpp
...
...
@@ -59,9 +71,12 @@ add_library(onnx_import STATIC
op/mean.hpp
op/min.hpp
op/mul.hpp
op/neg.hpp
op/not.hpp
op/or.hpp
op/pow.hpp
op/reciprocal.cpp
op/reciprocal.hpp
op/reduce.cpp
op/reduce.hpp
op/relu.hpp
...
...
@@ -71,8 +86,13 @@ add_library(onnx_import STATIC
op/shape.hpp
op/softmax.cpp
op/softmax.hpp
op/softplus.cpp
op/softplus.hpp
op/softsign.cpp
op/softsign.hpp
op/split.cpp
op/split.hpp
op/sqrt.hpp
op/sub.hpp
op/sum.hpp
op/unsqueeze.cpp
...
...
src/ngraph/frontend/onnx_import/op/abs.hpp
0 → 100644
View file @
61926759
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#pragma once
#include <memory>
#include "ngraph/node_vector.hpp"
#include "ngraph/op/abs.hpp"
#include "core/node.hpp"
namespace
ngraph
{
namespace
onnx_import
{
namespace
op
{
inline
NodeVector
abs
(
const
Node
&
node
)
{
return
{
std
::
make_shared
<
ngraph
::
op
::
Abs
>
(
node
.
get_ng_inputs
().
at
(
0
))};
}
}
// namespace op
}
// namespace onnx_import
}
// namespace ngraph
src/ngraph/frontend/onnx_import/op/cast.cpp
0 → 100644
View file @
61926759
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#include <memory>
#include <onnx.pb.h>
#include "ngraph/op/convert.hpp"
#include "ngraph/type/element_type.hpp"
#include "exceptions.hpp"
#include "cast.hpp"
namespace
ngraph
{
namespace
onnx_import
{
namespace
op
{
NodeVector
cast
(
const
Node
&
node
)
{
auto
data
=
node
.
get_ng_inputs
().
at
(
0
);
int64_t
target_type
=
node
.
get_attribute_value
<
int64_t
>
(
"to"
);
element
::
Type
elem_type
;
switch
(
target_type
)
{
case
onnx
:
:
TensorProto_DataType_BOOL
:
elem_type
=
element
::
boolean
;
break
;
case
onnx
:
:
TensorProto_DataType_DOUBLE
:
elem_type
=
element
::
f64
;
break
;
case
onnx
:
:
TensorProto_DataType_FLOAT16
:
case
onnx
:
:
TensorProto_DataType_FLOAT
:
elem_type
=
element
::
f32
;
break
;
case
onnx
:
:
TensorProto_DataType_INT8
:
elem_type
=
element
::
i8
;
break
;
case
onnx
:
:
TensorProto_DataType_INT16
:
elem_type
=
element
::
i16
;
break
;
case
onnx
:
:
TensorProto_DataType_INT32
:
elem_type
=
element
::
i32
;
break
;
case
onnx
:
:
TensorProto_DataType_INT64
:
elem_type
=
element
::
i64
;
break
;
case
onnx
:
:
TensorProto_DataType_UINT8
:
elem_type
=
element
::
u8
;
break
;
case
onnx
:
:
TensorProto_DataType_UINT16
:
elem_type
=
element
::
u16
;
break
;
case
onnx
:
:
TensorProto_DataType_UINT32
:
elem_type
=
element
::
u32
;
break
;
case
onnx
:
:
TensorProto_DataType_UINT64
:
elem_type
=
element
::
u64
;
break
;
case
onnx
:
:
TensorProto_DataType_UNDEFINED
:
elem_type
=
element
::
unspecified
;
break
;
default
:
ASSERT_IS_SUPPORTED
(
node
,
false
)
<<
"unsupported type"
;
}
return
{
std
::
make_shared
<
ngraph
::
op
::
Convert
>
(
data
,
elem_type
)};
}
}
// namespace op
}
// namespace onnx_import
}
// namespace ngraph
src/ngraph/frontend/onnx_import/op/cast.hpp
0 → 100644
View file @
61926759
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#pragma once
#include "ngraph/node_vector.hpp"
#include "core/node.hpp"
namespace
ngraph
{
namespace
onnx_import
{
namespace
op
{
NodeVector
cast
(
const
Node
&
node
);
}
// namespace op
}
// namespace onnx_import
}
// namespace ngraph
src/ngraph/frontend/onnx_import/op/ceil.hpp
0 → 100644
View file @
61926759
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#pragma once
#include <memory>
#include "ngraph/node_vector.hpp"
#include "ngraph/op/ceiling.hpp"
#include "core/node.hpp"
namespace
ngraph
{
namespace
onnx_import
{
namespace
op
{
inline
NodeVector
ceil
(
const
Node
&
node
)
{
return
{
std
::
make_shared
<
ngraph
::
op
::
Ceiling
>
(
node
.
get_ng_inputs
().
at
(
0
))};
}
}
// namespace op
}
// namespace onnx_import
}
// namespace ngraph
src/ngraph/frontend/onnx_import/op/clip.cpp
0 → 100644
View file @
61926759
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#include <limits>
#include <memory>
#include "ngraph/node.hpp"
#include "ngraph/op/constant.hpp"
#include "ngraph/op/maximum.hpp"
#include "ngraph/op/minimum.hpp"
#include "core/node.hpp"
#include "utils/broadcasting.hpp"
#include "clip.hpp"
namespace
ngraph
{
namespace
onnx_import
{
namespace
op
{
NodeVector
clip
(
const
Node
&
node
)
{
auto
data
=
node
.
get_ng_inputs
().
at
(
0
);
double
max_value
=
node
.
get_attribute_value
<
double
>
(
"max"
,
std
::
numeric_limits
<
double
>::
max
());
double
min_value
=
node
.
get_attribute_value
<
double
>
(
"min"
,
std
::
numeric_limits
<
double
>::
lowest
());
std
::
shared_ptr
<
ngraph
::
Node
>
max_value_node
=
std
::
make_shared
<
ngraph
::
op
::
Constant
>
(
data
->
get_element_type
(),
ngraph
::
Shape
{},
std
::
vector
<
double
>
{
max_value
});
max_value_node
=
make_broadcast_node
(
max_value_node
,
data
->
get_shape
());
std
::
shared_ptr
<
ngraph
::
Node
>
min_value_node
=
std
::
make_shared
<
ngraph
::
op
::
Constant
>
(
data
->
get_element_type
(),
ngraph
::
Shape
{},
std
::
vector
<
double
>
{
min_value
});
min_value_node
=
make_broadcast_node
(
min_value_node
,
data
->
get_shape
());
return
{
std
::
make_shared
<
ngraph
::
op
::
Minimum
>
(
max_value_node
,
std
::
make_shared
<
ngraph
::
op
::
Maximum
>
(
data
,
min_value_node
))};
}
}
// namespace op
}
// namespace onnx_import
}
// namespace ngraph
src/ngraph/frontend/onnx_import/op/clip.hpp
0 → 100644
View file @
61926759
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#pragma once
#include "ngraph/node_vector.hpp"
#include "core/node.hpp"
namespace
ngraph
{
namespace
onnx_import
{
namespace
op
{
NodeVector
clip
(
const
Node
&
node
);
}
// namespace op
}
// namespace onnx_import
}
// namespace ngraph
src/ngraph/frontend/onnx_import/op/exp.hpp
0 → 100644
View file @
61926759
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#pragma once
#include <memory>
#include "ngraph/node_vector.hpp"
#include "ngraph/op/exp.hpp"
#include "core/node.hpp"
namespace
ngraph
{
namespace
onnx_import
{
namespace
op
{
inline
NodeVector
exp
(
const
Node
&
node
)
{
return
{
std
::
make_shared
<
ngraph
::
op
::
Exp
>
(
node
.
get_ng_inputs
().
at
(
0
))};
}
}
// namespace op
}
// namespace onnx_import
}
// namespace ngraph
src/ngraph/frontend/onnx_import/op/floor.hpp
0 → 100644
View file @
61926759
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#pragma once
#include <memory>
#include "ngraph/node_vector.hpp"
#include "ngraph/op/floor.hpp"
#include "core/node.hpp"
namespace
ngraph
{
namespace
onnx_import
{
namespace
op
{
inline
NodeVector
floor
(
const
Node
&
node
)
{
return
{
std
::
make_shared
<
ngraph
::
op
::
Floor
>
(
node
.
get_ng_inputs
().
at
(
0
))};
}
}
// namespace op
}
// namespace onnx_import
}
// namespace ngraph
src/ngraph/frontend/onnx_import/op/hard_sigmoid.cpp
0 → 100644
View file @
61926759
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#include <memory>
#include "ngraph/node.hpp"
#include "ngraph/op/add.hpp"
#include "ngraph/op/constant.hpp"
#include "ngraph/op/maximum.hpp"
#include "ngraph/op/minimum.hpp"
#include "ngraph/op/multiply.hpp"
#include "core/node.hpp"
#include "utils/broadcasting.hpp"
#include "hard_sigmoid.hpp"
namespace
ngraph
{
namespace
onnx_import
{
namespace
op
{
NodeVector
hard_sigmoid
(
const
Node
&
node
)
{
auto
data
=
node
.
get_ng_inputs
().
at
(
0
);
double
alpha
=
node
.
get_attribute_value
<
double
>
(
"alpha"
,
0.2
);
double
beta
=
node
.
get_attribute_value
<
double
>
(
"beta"
,
0.5
);
std
::
shared_ptr
<
ngraph
::
Node
>
alpha_node
=
std
::
make_shared
<
ngraph
::
op
::
Constant
>
(
data
->
get_element_type
(),
ngraph
::
Shape
{},
std
::
vector
<
double
>
{
alpha
});
alpha_node
=
make_broadcast_node
(
alpha_node
,
data
->
get_shape
());
std
::
shared_ptr
<
ngraph
::
Node
>
beta_node
=
std
::
make_shared
<
ngraph
::
op
::
Constant
>
(
data
->
get_element_type
(),
ngraph
::
Shape
{},
std
::
vector
<
double
>
{
beta
});
beta_node
=
make_broadcast_node
(
beta_node
,
data
->
get_shape
());
std
::
shared_ptr
<
ngraph
::
Node
>
one_node
=
std
::
make_shared
<
ngraph
::
op
::
Constant
>
(
data
->
get_element_type
(),
Shape
{},
std
::
vector
<
double
>
{
1
});
one_node
=
make_broadcast_node
(
one_node
,
data
->
get_shape
());
std
::
shared_ptr
<
ngraph
::
Node
>
zero_node
=
std
::
make_shared
<
ngraph
::
op
::
Constant
>
(
data
->
get_element_type
(),
Shape
{},
std
::
vector
<
double
>
{
0
});
zero_node
=
make_broadcast_node
(
zero_node
,
data
->
get_shape
());
return
{
std
::
make_shared
<
ngraph
::
op
::
Maximum
>
(
zero_node
,
std
::
make_shared
<
ngraph
::
op
::
Minimum
>
(
one_node
,
alpha_node
*
data
+
beta_node
))};
}
}
// namespace op
}
// namespace onnx_import
}
// namespace ngraph
src/ngraph/frontend/onnx_import/op/hard_sigmoid.hpp
0 → 100644
View file @
61926759
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#pragma once
#include "ngraph/node_vector.hpp"
#include "core/node.hpp"
namespace
ngraph
{
namespace
onnx_import
{
namespace
op
{
NodeVector
hard_sigmoid
(
const
Node
&
node
);
}
// namespace op
}
// namespace onnx_import
}
// namespace ngraph
src/ngraph/frontend/onnx_import/op/identity.hpp
0 → 100644
View file @
61926759
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#pragma once
#include "ngraph/node_vector.hpp"
#include "core/node.hpp"
namespace
ngraph
{
namespace
onnx_import
{
namespace
op
{
inline
NodeVector
identity
(
const
Node
&
node
)
{
return
{
node
.
get_ng_inputs
().
at
(
0
)};
}
}
// namespace op
}
// namespace onnx_import
}
// namespace ngraph
src/ngraph/frontend/onnx_import/op/log.hpp
0 → 100644
View file @
61926759
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#pragma once
#include <memory>
#include "ngraph/node_vector.hpp"
#include "ngraph/op/log.hpp"
#include "core/node.hpp"
namespace
ngraph
{
namespace
onnx_import
{
namespace
op
{
inline
NodeVector
log
(
const
Node
&
node
)
{
return
{
std
::
make_shared
<
ngraph
::
op
::
Log
>
(
node
.
get_ng_inputs
().
at
(
0
))};
}
}
// namespace op
}
// namespace onnx_import
}
// namespace ngraph
src/ngraph/frontend/onnx_import/op/log_softmax.hpp
0 → 100644
View file @
61926759
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#pragma once
#include <memory>
#include "ngraph/node.hpp"
#include "ngraph/node_vector.hpp"
#include "ngraph/op/log.hpp"
#include "core/node.hpp"
#include "ngraph/frontend/onnx_import/op/softmax.hpp"
namespace
ngraph
{
namespace
onnx_import
{
namespace
op
{
inline
NodeVector
log_softmax
(
const
Node
&
node
)
{
return
{
std
::
make_shared
<
ngraph
::
op
::
Log
>
(
softmax
(
node
).
at
(
0
))};
}
}
// namespace op
}
// namespace onnx_import
}
// namespace ngraph
src/ngraph/frontend/onnx_import/op/neg.hpp
0 → 100644
View file @
61926759
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#pragma once
#include "ngraph/node_vector.hpp"
#include "ngraph/op/negative.hpp"
#include "core/node.hpp"
namespace
ngraph
{
namespace
onnx_import
{
namespace
op
{
inline
NodeVector
neg
(
const
Node
&
node
)
{
return
{
-
node
.
get_ng_inputs
().
at
(
0
)};
}
}
// namespace op
}
// namespace onnx_import
}
// namespace ngraph
src/ngraph/frontend/onnx_import/op/reciprocal.cpp
0 → 100644
View file @
61926759
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#include <memory>
#include <vector>
#include "ngraph/op/constant.hpp"
#include "ngraph/op/divide.hpp"
#include "ngraph/shape.hpp"
#include "utils/broadcasting.hpp"
#include "reciprocal.hpp"
namespace
ngraph
{
namespace
onnx_import
{
namespace
op
{
NodeVector
reciprocal
(
const
Node
&
node
)
{
auto
data
=
node
.
get_ng_inputs
().
at
(
0
);
std
::
shared_ptr
<
ngraph
::
Node
>
one_node
=
std
::
make_shared
<
ngraph
::
op
::
Constant
>
(
data
->
get_element_type
(),
Shape
{},
std
::
vector
<
double
>
{
1
});
one_node
=
make_broadcast_node
(
one_node
,
data
->
get_shape
());
return
{
one_node
/
data
};
}
}
// namespace op
}
// namespace onnx_import
}
// namespace ngraph
src/ngraph/frontend/onnx_import/op/reciprocal.hpp
0 → 100644
View file @
61926759
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#pragma once
#include "ngraph/node_vector.hpp"
#include "core/node.hpp"
namespace
ngraph
{
namespace
onnx_import
{
namespace
op
{
NodeVector
reciprocal
(
const
Node
&
node
);
}
// namespace op
}
// namespace onnx_import
}
// namespace ngraph
src/ngraph/frontend/onnx_import/op/softplus.cpp
0 → 100644
View file @
61926759
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#include <memory>
#include "ngraph/node.hpp"
#include "ngraph/op/add.hpp"
#include "ngraph/op/constant.hpp"
#include "ngraph/op/exp.hpp"
#include "ngraph/op/log.hpp"
#include "utils/broadcasting.hpp"
#include "softplus.hpp"
namespace
ngraph
{
namespace
onnx_import
{
namespace
op
{
NodeVector
softplus
(
const
Node
&
node
)
{
auto
data
=
node
.
get_ng_inputs
().
at
(
0
);
std
::
shared_ptr
<
ngraph
::
Node
>
one_node
=
std
::
make_shared
<
ngraph
::
op
::
Constant
>
(
data
->
get_element_type
(),
Shape
{},
std
::
vector
<
double
>
{
1
});
one_node
=
make_broadcast_node
(
one_node
,
data
->
get_shape
());
return
{
std
::
make_shared
<
ngraph
::
op
::
Log
>
(
std
::
make_shared
<
ngraph
::
op
::
Exp
>
(
data
)
+
one_node
)};
}
}
// namespace op
}
// namespace onnx_import
}
// namespace ngraph
src/ngraph/frontend/onnx_import/op/softplus.hpp
0 → 100644
View file @
61926759
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#pragma once
#include "ngraph/node_vector.hpp"
#include "core/node.hpp"
namespace
ngraph
{
namespace
onnx_import
{
namespace
op
{
NodeVector
softplus
(
const
Node
&
node
);
}
// namespace op
}
// namespace onnx_import
}
// namespace ngraph
src/ngraph/frontend/onnx_import/op/softsign.cpp
0 → 100644
View file @
61926759
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#include <memory>
#include <vector>
#include "ngraph/op/abs.hpp"
#include "ngraph/op/add.hpp"
#include "ngraph/op/constant.hpp"
#include "ngraph/op/divide.hpp"
#include "ngraph/shape.hpp"
#include "utils/broadcasting.hpp"
#include "softsign.hpp"
namespace
ngraph
{
namespace
onnx_import
{
namespace
op
{
NodeVector
softsign
(
const
Node
&
node
)
{
auto
data
=
node
.
get_ng_inputs
().
at
(
0
);
std
::
shared_ptr
<
ngraph
::
Node
>
one_node
=
std
::
make_shared
<
ngraph
::
op
::
Constant
>
(
data
->
get_element_type
(),
Shape
{},
std
::
vector
<
double
>
{
1
});
one_node
=
make_broadcast_node
(
one_node
,
data
->
get_shape
());
return
{
data
/
(
std
::
make_shared
<
ngraph
::
op
::
Abs
>
(
data
)
+
one_node
)};
}
}
// namespace op
}
// namespace onnx_import
}
// namespace ngraph
src/ngraph/frontend/onnx_import/op/softsign.hpp
0 → 100644
View file @
61926759
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#pragma once
#include "ngraph/node_vector.hpp"
#include "core/node.hpp"
namespace
ngraph
{
namespace
onnx_import
{
namespace
op
{
NodeVector
softsign
(
const
Node
&
node
);
}
// namespace op
}
// namespace onnx_import
}
// namespace ngraph
src/ngraph/frontend/onnx_import/op/sqrt.hpp
0 → 100644
View file @
61926759
//*****************************************************************************
// Copyright 2017-2018 Intel Corporation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//*****************************************************************************
#pragma once
#include <memory>
#include "ngraph/node_vector.hpp"
#include "ngraph/op/sqrt.hpp"
#include "core/node.hpp"
namespace
ngraph
{
namespace
onnx_import
{
namespace
op
{
inline
NodeVector
sqrt
(
const
Node
&
node
)
{
return
{
std
::
make_shared
<
ngraph
::
op
::
Sqrt
>
(
node
.
get_ng_inputs
().
at
(
0
))};
}
}
// namespace op
}
// namespace onnx_import
}
// namespace ngraph
src/ngraph/frontend/onnx_import/ops_bridge.cpp
View file @
61926759
...
...
@@ -18,34 +18,49 @@
#include <functional>
#include "core/attribute.hpp"
#include "op/abs.hpp"
#include "op/add.hpp"
#include "op/and.hpp"
#include "op/average_pool.hpp"
#include "op/batch_norm.hpp"
#include "op/cast.hpp"
#include "op/ceil.hpp"
#include "op/clip.hpp"
#include "op/concat.hpp"
#include "op/constant.hpp"
#include "op/conv.hpp"
#include "op/div.hpp"
#include "op/equal.hpp"
#include "op/exp.hpp"
#include "op/flatten.hpp"
#include "op/floor.hpp"
#include "op/gemm.hpp"
#include "op/greater.hpp"
#include "op/hard_sigmoid.hpp"
#include "op/identity.hpp"
#include "op/less.hpp"
#include "op/log.hpp"
#include "op/log_softmax.hpp"
#include "op/matmul.hpp"
#include "op/max.hpp"
#include "op/max_pool.hpp"
#include "op/mean.hpp"
#include "op/min.hpp"
#include "op/mul.hpp"
#include "op/neg.hpp"
#include "op/not.hpp"
#include "op/or.hpp"
#include "op/pow.hpp"
#include "op/reciprocal.hpp"
#include "op/reduce.hpp"
#include "op/relu.hpp"
#include "op/reshape.hpp"
#include "op/shape.hpp"
#include "op/softmax.hpp"
#include "op/softplus.hpp"
#include "op/softsign.hpp"
#include "op/split.hpp"
#include "op/sqrt.hpp"
#include "op/sub.hpp"
#include "op/sum.hpp"
#include "op/unsqueeze.hpp"
...
...
@@ -94,30 +109,43 @@ namespace ngraph
ops_bridge
()
{
m_map
.
emplace
(
"Abs"
,
std
::
bind
(
op
::
abs
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Add"
,
std
::
bind
(
op
::
add
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"And"
,
std
::
bind
(
op
::
logical_and
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"AveragePool"
,
std
::
bind
(
op
::
average_pool
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"BatchNormalization"
,
std
::
bind
(
op
::
batch_norm
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Cast"
,
std
::
bind
(
op
::
cast
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Ceil"
,
std
::
bind
(
op
::
ceil
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Clip"
,
std
::
bind
(
op
::
clip
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Concat"
,
std
::
bind
(
op
::
concat
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Constant"
,
std
::
bind
(
op
::
constant
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Conv"
,
std
::
bind
(
op
::
conv
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Div"
,
std
::
bind
(
op
::
div
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Equal"
,
std
::
bind
(
op
::
equal
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Exp"
,
std
::
bind
(
op
::
exp
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Flatten"
,
std
::
bind
(
op
::
flatten
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Floor"
,
std
::
bind
(
op
::
floor
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Gemm"
,
std
::
bind
(
op
::
gemm
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Greater"
,
std
::
bind
(
op
::
greater
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"HardSigmoid"
,
std
::
bind
(
op
::
hard_sigmoid
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Identity"
,
std
::
bind
(
op
::
identity
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Less"
,
std
::
bind
(
op
::
less
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Log"
,
std
::
bind
(
op
::
log
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"LogSoftmax"
,
std
::
bind
(
op
::
log_softmax
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"MatMul"
,
std
::
bind
(
op
::
matmul
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"MaxPool"
,
std
::
bind
(
op
::
max_pool
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Max"
,
std
::
bind
(
op
::
max
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Mean"
,
std
::
bind
(
op
::
mean
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Min"
,
std
::
bind
(
op
::
min
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Mul"
,
std
::
bind
(
op
::
mul
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Neg"
,
std
::
bind
(
op
::
neg
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Not"
,
std
::
bind
(
op
::
logical_not
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Or"
,
std
::
bind
(
op
::
logical_or
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Pow"
,
std
::
bind
(
op
::
pow
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Reciprocal"
,
std
::
bind
(
op
::
reciprocal
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"ReduceLogSum"
,
std
::
bind
(
op
::
reduce_log_sum
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"ReduceLogSumExp"
,
...
...
@@ -135,7 +163,10 @@ namespace ngraph
m_map
.
emplace
(
"Reshape"
,
std
::
bind
(
op
::
reshape
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Shape"
,
std
::
bind
(
op
::
shape
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Softmax"
,
std
::
bind
(
op
::
softmax
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Softplus"
,
std
::
bind
(
op
::
softplus
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Softsign"
,
std
::
bind
(
op
::
softsign
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Split"
,
std
::
bind
(
op
::
split
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Sqrt"
,
std
::
bind
(
op
::
sqrt
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Sub"
,
std
::
bind
(
op
::
sub
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Sum"
,
std
::
bind
(
op
::
sum
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Unsqueeze"
,
std
::
bind
(
op
::
unsqueeze
,
std
::
placeholders
::
_1
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment