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
b1aa0815
Unverified
Commit
b1aa0815
authored
Jul 23, 2019
by
Scott Cyphers
Committed by
GitHub
Jul 23, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into cyphers/adjointout
parents
8fa64880
f6f3a032
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
65 additions
and
4 deletions
+65
-4
pad.hpp
src/ngraph/op/pad.hpp
+1
-1
cpu_emitter.cpp
src/ngraph/runtime/cpu/cpu_emitter.cpp
+3
-1
unit_test.manifest
src/ngraph/runtime/gpu/unit_test.manifest
+1
-0
unit_test.manifest
src/ngraph/runtime/intelgpu/unit_test.manifest
+1
-0
unit_test.manifest
src/ngraph/runtime/plaidml/unit_test.manifest
+1
-0
pad.hpp
src/ngraph/runtime/reference/pad.hpp
+25
-2
pad.in.cpp
test/backend/pad.in.cpp
+33
-0
No files found.
src/ngraph/op/pad.hpp
View file @
b1aa0815
...
...
@@ -34,7 +34,7 @@ namespace ngraph
/// \param arg_pad_value The node producing the scalar value to be inserted for padding.
/// \param padding_below The padding-below widths.
/// \param padding_above The padding-above widths.
/// \param pad_mode The padding mode: CONSTANT(default), EDGE
or REFLECT
.
/// \param pad_mode The padding mode: CONSTANT(default), EDGE
, REFLECT or SYMMETRIC
.
Pad
(
const
std
::
shared_ptr
<
Node
>&
arg
,
const
std
::
shared_ptr
<
Node
>&
arg_pad_value
,
const
CoordinateDiff
&
padding_below
,
...
...
src/ngraph/runtime/cpu/cpu_emitter.cpp
View file @
b1aa0815
...
...
@@ -3027,7 +3027,9 @@ namespace ngraph
case
ngraph
:
:
op
::
PadMode
::
REFLECT
:
pad_mode_string
=
"ngraph::op::PadMode::REFLECT"
;
break
;
case
ngraph
:
:
op
::
PadMode
::
SYMMETRIC
:
throw
ngraph_error
(
"Unsupported PadMode"
);
case
ngraph
:
:
op
::
PadMode
::
SYMMETRIC
:
pad_mode_string
=
"ngraph::op::PadMode::SYMMETRIC"
;
break
;
}
writer
<<
"reference::pad<"
<<
out
[
0
].
get_type
()
<<
">("
<<
args
[
0
].
get_name
()
<<
",
\n
"
;
...
...
src/ngraph/runtime/gpu/unit_test.manifest
View file @
b1aa0815
...
...
@@ -123,6 +123,7 @@ pad_reflect_1d_bottom_neg_bigger_than_tensor
pad_reflect_1d_multi_reflect
pad_reflect_2d
pad_reflect_2d_with_neg
pad_symmetric
# Quantized operators are not supported on gpu backend
model_dequantize_linear
...
...
src/ngraph/runtime/intelgpu/unit_test.manifest
View file @
b1aa0815
...
...
@@ -40,6 +40,7 @@ pad_reflect_1d_bottom_neg_bigger_than_tensor
pad_reflect_1d_multi_reflect
pad_reflect_2d
pad_reflect_2d_with_neg
pad_symmetric
# Not implemented
batch_mat_mul_forward
...
...
src/ngraph/runtime/plaidml/unit_test.manifest
View file @
b1aa0815
...
...
@@ -137,6 +137,7 @@ pad_reflect_2d_with_neg
pad_negative_exterior_2d
pad_negative_exterior_2d_all_negative
pad_negative_exterior_4d
pad_symmetric
max_trivial_int8
max_trivial_5d_int32
max_3d_to_scalar_double
...
...
src/ngraph/runtime/reference/pad.hpp
View file @
b1aa0815
...
...
@@ -164,8 +164,31 @@ namespace ngraph
}
case
op
:
:
PadMode
::
SYMMETRIC
:
{
// TODO: Add support for Symmetric mode
throw
ngraph_error
(
"Symmetric mode padding not supported"
);
Coordinate
c
=
in_coord
;
// have to copy because in_coord is const
for
(
size_t
i
=
0
;
i
<
c
.
size
();
i
++
)
{
ptrdiff_t
pos
=
padding_below
[
i
]
-
(
c
[
i
]
+
1
);
if
(
pos
>=
0
)
{
c
[
i
]
=
static_cast
<
size_t
>
(
pos
+
padding_below
[
i
]);
}
else
{
pos
=
-
(
pos
+
1
);
ptrdiff_t
src_dim
=
static_cast
<
ptrdiff_t
>
(
arg0_shape
[
i
]);
if
(
pos
<
src_dim
)
{
c
[
i
]
=
static_cast
<
size_t
>
(
pos
+
padding_below
[
i
]);
}
else
{
c
[
i
]
=
static_cast
<
size_t
>
(
padding_below
[
i
]
+
src_dim
+
padding_above
[
i
]
-
pos
);
}
}
}
v
=
arg0
[
input_transform
.
index
(
c
)];
break
;
}
}
...
...
test/backend/pad.in.cpp
View file @
b1aa0815
...
...
@@ -939,3 +939,36 @@ NGRAPH_TEST(${BACKEND_NAME}, pad_2channel_2image_asym)
read_vector
<
float
>
(
result
),
MIN_FLOAT_TOLERANCE_BITS
));
}
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
pad_symmetric
)
{
Shape
shape_a
{
2
,
3
};
auto
A
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
shape_a
);
Shape
shape_b
{};
auto
B
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
shape_b
);
Shape
shape_r
{
4
,
7
};
CoordinateDiff
padding_below
{
1
,
2
};
CoordinateDiff
padding_above
{
1
,
2
};
auto
f
=
make_shared
<
Function
>
(
make_shared
<
op
::
Pad
>
(
A
,
B
,
padding_below
,
padding_above
,
op
::
PadMode
::
SYMMETRIC
),
ParameterVector
{
A
,
B
});
auto
backend
=
runtime
::
Backend
::
create
(
"${BACKEND_NAME}"
);
// Create some tensors for input/output
auto
a
=
backend
->
create_tensor
(
element
::
f32
,
shape_a
);
copy_data
(
a
,
test
::
NDArray
<
float
,
2
>
({{
1
,
2
,
3
},
{
4
,
5
,
6
}}).
get_vector
());
auto
b
=
backend
->
create_tensor
(
element
::
f32
,
shape_b
);
copy_data
(
b
,
vector
<
float
>
{
2112
});
auto
result
=
backend
->
create_tensor
(
element
::
f32
,
shape_r
);
auto
handle
=
backend
->
compile
(
f
);
handle
->
call_with_validate
({
result
},
{
a
,
b
});
EXPECT_TRUE
(
test
::
all_close_f
((
test
::
NDArray
<
float
,
2
>
({{
2
,
1
,
1
,
2
,
3
,
3
,
2
},
{
2
,
1
,
1
,
2
,
3
,
3
,
2
},
{
5
,
4
,
4
,
5
,
6
,
6
,
5
},
{
5
,
4
,
4
,
5
,
6
,
6
,
5
}})
.
get_vector
()),
read_vector
<
float
>
(
result
),
MIN_FLOAT_TOLERANCE_BITS
));
}
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