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
f8c4a44e
Commit
f8c4a44e
authored
Jun 07, 2019
by
Adam Procter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test generator for DynSlice
parent
080d4f95
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
144 additions
and
2 deletions
+144
-2
dyn_slice.cpp
src/ngraph/op/experimental/dyn_slice.cpp
+9
-1
dyn_elimination.cpp
src/ngraph/pass/dyn_elimination.cpp
+5
-1
CMakeLists.txt
test/CMakeLists.txt
+1
-0
dyn_slice_test.in.cpp
test/dyn_slice_test.in.cpp
+96
-0
generate_dyn_slice_ref.py
test/ref_generators/generate_dyn_slice_ref.py
+0
-0
update_dyn_slice_reference.sh
test/update_dyn_slice_reference.sh
+18
-0
update_reference.sh
test/update_reference.sh
+15
-0
No files found.
src/ngraph/op/experimental/dyn_slice.cpp
View file @
f8c4a44e
...
...
@@ -240,7 +240,15 @@ void op::DynSlice::validate_and_infer_types()
shared_ptr
<
Node
>
op
::
DynSlice
::
copy_with_new_args
(
const
NodeVector
&
new_args
)
const
{
check_new_args_count
(
this
,
new_args
);
return
make_shared
<
DynSlice
>
(
new_args
.
at
(
0
),
new_args
.
at
(
1
),
new_args
.
at
(
2
),
new_args
.
at
(
3
));
return
make_shared
<
DynSlice
>
(
new_args
.
at
(
0
),
new_args
.
at
(
1
),
new_args
.
at
(
2
),
new_args
.
at
(
3
),
m_lower_bounds_mask
,
m_upper_bounds_mask
,
m_new_axis
,
m_shrink_axis
,
m_ellipsis_mask
);
}
void
op
::
DynSlice
::
generate_adjoints
(
autodiff
::
Adjoints
&
adjoints
,
const
NodeVector
&
deltas
)
...
...
src/ngraph/pass/dyn_elimination.cpp
View file @
f8c4a44e
...
...
@@ -153,7 +153,11 @@ static SlicePlan make_plan(const Shape& input_shape,
}
}
NGRAPH_CHECK
(
num_real_axes
<=
input_shape
.
size
());
NGRAPH_CHECK
(
num_real_axes
<=
input_shape
.
size
(),
"num_real_axes="
,
num_real_axes
,
", input_shape="
,
input_shape
);
// Figure out how many axes need to be inserted when the ellipsis (which
// may be an implicit ellipsis at the end) is expanded.
...
...
test/CMakeLists.txt
View file @
f8c4a44e
...
...
@@ -170,6 +170,7 @@ set(MULTI_TEST_SRC
backend_test.in.cpp
backend_unary_elementwise.in.cpp
convolution_test.in.cpp
dyn_slice_test.in.cpp
dynamic.in.cpp
)
...
...
test/dyn_slice_test.in.cpp
0 → 100644
View file @
f8c4a44e
//*****************************************************************************
// Copyright 2017-2019 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.
//*****************************************************************************
// !!!!!!!!!!!!!! THIS FILE IS AUTOGENERATED OUTSIDE OF THE BUILD PROCESS !!!!!!!!!!!!!!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! DO NOT EDIT THIS FILE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
//
// DO NOT EDIT THIS FILE. If you want to add new tests, you should edit
// test/ref_generators/generate_dyn_slice_ref.py and regenerate this file.
//
// To regenerate:
//
// $ cd <ngraph source dir>/test
// $ ./update_dyn_slice_reference.sh
//
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! DO NOT EDIT THIS FILE !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// !!!!!!!!!!!!!! THIS FILE IS AUTOGENERATED OUTSIDE OF THE BUILD PROCESS !!!!!!!!!!!!!!
//
// clang-format off
#include <cmath>
#include "gtest/gtest.h"
#include "ngraph/ngraph.hpp"
#include "util/test_tools.hpp"
#include "util/autodiff/numeric_compare.hpp"
#include "util/all_close_f.hpp"
#include "util/test_control.hpp"
using
namespace
std
;
using
namespace
ngraph
;
static
string
s_manifest
=
"${MANIFEST}"
;
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
dyn_slice
)
{
{
auto
arg
=
std
::
make_shared
<
op
::
Parameter
>
(
element
::
i32
,
Shape
{
4
});
auto
lb
=
std
::
make_shared
<
op
::
Parameter
>
(
element
::
i64
,
Shape
{
2
});
auto
ub
=
std
::
make_shared
<
op
::
Parameter
>
(
element
::
i64
,
Shape
{
2
});
auto
strides
=
std
::
make_shared
<
op
::
Parameter
>
(
element
::
i64
,
Shape
{
2
});
std
::
vector
<
int32_t
>
input_values
{
0
,
1
,
2
,
3
};
std
::
vector
<
int64_t
>
lb_values
{
0
,
3
};
std
::
vector
<
int64_t
>
ub_values
{
0
,
0
};
std
::
vector
<
int64_t
>
strides_values
{
1
,
-
1
};
AxisSet
lb_mask
{};
AxisSet
ub_mask
{};
AxisSet
new_mask
{
0
};
AxisSet
shrink_mask
{};
AxisSet
ellipsis_mask
{};
auto
slice
=
std
::
make_shared
<
op
::
DynSlice
>
(
arg
,
lb
,
ub
,
strides
,
lb_mask
,
ub_mask
,
new_mask
,
shrink_mask
,
ellipsis_mask
);
auto
f
=
std
::
make_shared
<
Function
>
(
NodeVector
{
slice
},
ParameterVector
{
arg
,
lb
,
ub
,
strides
});
auto
backend
=
runtime
::
Backend
::
create
(
"${BACKEND_NAME}"
,
true
);
auto
ex
=
backend
->
compile
(
f
);
auto
input_arg
=
backend
->
create_tensor
(
element
::
i32
,
Shape
{
4
});
auto
input_lb
=
backend
->
create_tensor
(
element
::
i64
,
Shape
{
2
});
auto
input_ub
=
backend
->
create_tensor
(
element
::
i64
,
Shape
{
2
});
auto
input_strides
=
backend
->
create_tensor
(
element
::
i64
,
Shape
{
2
});
copy_data
(
input_arg
,
input_values
);
copy_data
(
input_lb
,
lb_values
);
copy_data
(
input_ub
,
ub_values
);
copy_data
(
input_strides
,
strides_values
);
auto
output
=
backend
->
create_dynamic_tensor
(
element
::
i32
,
PartialShape
::
dynamic
());
ex
->
call
({
output
},
{
input_arg
,
input_lb
,
input_ub
,
input_strides
});
EXPECT_EQ
(
output
->
get_element_type
(),
(
element
::
i32
));
EXPECT_EQ
(
output
->
get_shape
(),
(
Shape
{
1
,
3
}));
auto
output_values
=
read_vector
<
int32_t
>
(
output
);
std
::
vector
<
int32_t
>
expected_values
{
3
,
2
,
1
};
EXPECT_EQ
(
output_values
,
expected_values
);
}
}
// clang-format on
test/ref_generators/generate_dyn_slice_ref.py
0 → 100644
View file @
f8c4a44e
This diff is collapsed.
Click to expand it.
test/update_dyn_slice_reference.sh
0 → 100755
View file @
f8c4a44e
#!/bin/bash
# ******************************************************************************
# Copyright 2017-2019 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.
# ******************************************************************************
declare
THIS_SCRIPT_DIR
=
"
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
"
&&
pwd
)
"
python
${
THIS_SCRIPT_DIR
}
/ref_generators/generate_dyn_slice_ref.py
${
THIS_SCRIPT_DIR
}
/dyn_slice_test.in.cpp
test/update_reference.sh
View file @
f8c4a44e
#!/bin/bash
# ******************************************************************************
# Copyright 2017-2019 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.
# ******************************************************************************
declare
THIS_SCRIPT_DIR
=
"
$(
cd
"
$(
dirname
"
${
BASH_SOURCE
[0]
}
"
)
"
&&
pwd
)
"
python
${
THIS_SCRIPT_DIR
}
/ref_generators/generate_convolution_ref.py
${
THIS_SCRIPT_DIR
}
/convolution_test.in.cpp
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