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
9d1f2367
Commit
9d1f2367
authored
Sep 19, 2018
by
tsocha
Committed by
Artur Wojcik
Sep 19, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ONNX] Slice op (#1610)
* [ONNX] Slice op * Review fix pt. 1 * Review fix pt. 2
parent
302ab491
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
108 additions
and
3 deletions
+108
-3
CMakeLists.txt
src/ngraph/frontend/onnx_import/CMakeLists.txt
+4
-2
slice.cpp
src/ngraph/frontend/onnx_import/op/slice.cpp
+67
-0
slice.hpp
src/ngraph/frontend/onnx_import/op/slice.hpp
+34
-0
ops_bridge.cpp
src/ngraph/frontend/onnx_import/ops_bridge.cpp
+3
-1
No files found.
src/ngraph/frontend/onnx_import/CMakeLists.txt
View file @
9d1f2367
...
...
@@ -88,11 +88,13 @@ add_library(onnx_import STATIC
op/relu.hpp
op/reshape.cpp
op/reshape.hpp
op/shape.cpp
op/shape.hpp
op/selu.cpp
op/selu.hpp
op/shape.hpp
op/shape.cpp
op/sigmoid.hpp
op/slice.cpp
op/slice.hpp
op/softmax.cpp
op/softmax.hpp
op/softplus.cpp
...
...
src/ngraph/frontend/onnx_import/op/slice.cpp
0 → 100644
View file @
9d1f2367
//*****************************************************************************
// 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 <algorithm>
#include <memory>
#include <vector>
#include "ngraph/node.hpp"
#include "ngraph/op/slice.hpp"
#include "slice.hpp"
#include "utils/common.hpp"
static
inline
int64_t
get_valid_array_idx
(
int64_t
idx
,
int64_t
last_idx
)
{
return
(
idx
>=
0
)
?
std
::
min
(
idx
,
last_idx
)
:
std
::
max
<
int64_t
>
(
0
,
last_idx
+
idx
);
}
namespace
ngraph
{
namespace
onnx_import
{
namespace
op
{
NodeVector
slice
(
const
Node
&
node
)
{
std
::
shared_ptr
<
ngraph
::
Node
>
data
=
node
.
get_ng_inputs
().
at
(
0
);
Shape
data_shape
=
data
->
get_shape
();
auto
starts
=
node
.
get_attribute_value
<
std
::
vector
<
int64_t
>>
(
"starts"
);
auto
ends
=
node
.
get_attribute_value
<
std
::
vector
<
int64_t
>>
(
"ends"
);
auto
axes
=
node
.
get_attribute_value
<
std
::
vector
<
int64_t
>>
(
"axes"
,
common
::
get_monotonic_range
<
int64_t
>
(
data_shape
.
size
()));
Shape
lower_bounds
(
data_shape
.
size
());
Shape
upper_bounds
=
data_shape
;
for
(
auto
idx
=
0
;
idx
<
axes
.
size
();
++
idx
)
{
size_t
axis
=
axes
.
at
(
idx
);
lower_bounds
.
at
(
axis
)
=
get_valid_array_idx
(
starts
.
at
(
idx
),
data_shape
.
at
(
axis
));
upper_bounds
.
at
(
axis
)
=
get_valid_array_idx
(
ends
.
at
(
idx
),
data_shape
.
at
(
axis
));
}
return
{
std
::
make_shared
<
ngraph
::
op
::
Slice
>
(
data
,
lower_bounds
,
upper_bounds
)};
}
}
// namespace op
}
// namespace onnx_import
}
// namespace ngraph
src/ngraph/frontend/onnx_import/op/slice.hpp
0 → 100644
View file @
9d1f2367
//*****************************************************************************
// 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
slice
(
const
Node
&
node
);
}
// namespace op
}
// namespace onnx_import
}
// namespace ngraph
src/ngraph/frontend/onnx_import/ops_bridge.cpp
View file @
9d1f2367
...
...
@@ -61,6 +61,7 @@
#include "op/selu.hpp"
#include "op/shape.hpp"
#include "op/sigmoid.hpp"
#include "op/slice.hpp"
#include "op/softmax.hpp"
#include "op/softplus.hpp"
#include "op/softsign.hpp"
...
...
@@ -171,9 +172,10 @@ namespace ngraph
std
::
bind
(
op
::
reduce_sum_square
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Relu"
,
std
::
bind
(
op
::
relu
,
std
::
placeholders
::
_1
));
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
(
"Selu"
,
std
::
bind
(
op
::
selu
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Shape"
,
std
::
bind
(
op
::
shape
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Sigmoid"
,
std
::
bind
(
op
::
sigmoid
,
std
::
placeholders
::
_1
));
m_map
.
emplace
(
"Slice"
,
std
::
bind
(
op
::
slice
,
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
));
...
...
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