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
76e144d3
Unverified
Commit
76e144d3
authored
Sep 09, 2019
by
Robert Kimball
Committed by
GitHub
Sep 09, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into gauri/new_reshape_error_master
parents
30af51f2
a15d2ec5
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
101 additions
and
113 deletions
+101
-113
release-notes.rst
doc/sphinx/source/project/release-notes.rst
+3
-1
CMakeLists.txt
src/contrib/mlir/compiler/CMakeLists.txt
+2
-0
normalize_l2.cpp
src/ngraph/op/fused/normalize_l2.cpp
+41
-42
normalize_l2.hpp
src/ngraph/op/fused/normalize_l2.hpp
+1
-0
unit_test.manifest
src/ngraph/runtime/intelgpu/unit_test.manifest
+6
-5
fused_op.in.cpp
test/backend/fused_op.in.cpp
+31
-41
normalize.cpp
test/type_prop/normalize.cpp
+17
-24
No files found.
doc/sphinx/source/project/release-notes.rst
View file @
76e144d3
...
...
@@ -19,7 +19,9 @@ We are pleased to announce the release of version |version|.
Core updates for |version|
--------------------------
Allow DLLs that link nGraph statically to load backends
+ Allow DLLs that link nGraph statically to load backends
+ Add rank id to trace file name.
+ Allow provenance merging to be disabled
.. important:: Pre-releases (``-rc-0.*``) have newer features, and are less stable.
...
...
src/contrib/mlir/compiler/CMakeLists.txt
View file @
76e144d3
...
...
@@ -94,3 +94,5 @@ ngraph_tablegen(ops.cpp.inc -gen-op-defs)
add_public_tablegen_target
(
ngraph_ops_gen
)
add_dependencies
(
mlir_backend ngraph_ops_gen
)
target_include_directories
(
mlir_backend PRIVATE
${
CMAKE_CURRENT_BINARY_DIR
}
)
install
(
TARGETS mlir_backend DESTINATION
${
NGRAPH_INSTALL_LIB
}
)
src/ngraph/op/fused/normalize_l2.cpp
View file @
76e144d3
...
...
@@ -42,27 +42,49 @@ op::NormalizeL2::NormalizeL2(const Output<Node>& data,
void
op
::
NormalizeL2
::
pre_validate_and_infer_types
()
{
const
auto
&
data_pshape
=
get_input_partial_shape
(
0
);
auto
axes_node
=
input_value
(
1
).
get_node_shared_ptr
();
const
auto
&
input_pshape
=
get_input_partial_shape
(
0
);
const
auto
&
axes_pshape
=
get_input_partial_shape
(
1
);
const
auto
&
input_rank
=
input_pshape
.
rank
();
const
auto
&
axes_rank
=
axes_pshape
.
rank
();
NODE_VALIDATION_CHECK
(
this
,
data_pshape
.
is_static
(),
"Input data must be static."
);
NODE_VALIDATION_CHECK
(
this
,
axes_pshape
.
is_static
(),
"Input axes must be static."
);
NODE_VALIDATION_CHECK
(
this
,
axes_node
->
is_constant
(),
"Input axes must be Constant type"
);
const
Shape
data_shape
{
data_pshape
.
to_shape
()};
// Input data must be 2, 3 or 4D tensor.
NODE_VALIDATION_CHECK
(
this
,
(
data_shape
.
size
()
>=
2
&&
data_shape
.
size
()
<=
4
),
"Input tensor rank must be 2, 3 or 4 dimensional (actual input "
"shape: "
,
data_shape
,
")."
);
if
(
axes_rank
.
is_static
())
{
NODE_VALIDATION_CHECK
(
this
,
static_cast
<
size_t
>
(
axes_rank
)
==
1
,
"Input axes must have rank equals 1 (axes rank: "
,
axes_rank
,
")."
);
if
(
input_rank
.
is_static
())
{
const
auto
reduction_axes
=
get_reduction_axes
();
for
(
auto
axis
:
reduction_axes
)
{
NODE_VALIDATION_CHECK
(
this
,
axis
<
size_t
(
input_rank
),
"Reduction axis ("
,
axis
,
") is out of bounds "
,
"(argument shape: "
,
input_pshape
,
")"
);
}
}
}
}
NODE_VALIDATION_CHECK
(
this
,
static_cast
<
size_t
>
(
axes_pshape
.
rank
())
==
1
,
"Input axes must have rank equals 1 (axes shape: "
,
axes_pshape
,
")."
);
AxisSet
op
::
NormalizeL2
::
get_reduction_axes
()
const
{
AxisSet
axes
;
auto
axes_input_node
=
input_value
(
1
).
get_node_shared_ptr
();
if
(
auto
const_op
=
dynamic_pointer_cast
<
op
::
Constant
>
(
axes_input_node
))
{
axes
=
const_op
->
get_axis_set_val
();
}
return
axes
;
}
NodeVector
op
::
NormalizeL2
::
decompose_op
()
const
...
...
@@ -70,37 +92,14 @@ NodeVector op::NormalizeL2::decompose_op() const
Output
<
Node
>
data
{
input_value
(
0
)};
const
Shape
input_shape
{
data
.
get_shape
()};
// Reshape to 4D tensor.
if
(
input_shape
.
size
()
!=
4
)
{
Shape
data_shape
(
4
-
input_shape
.
size
(),
1
);
copy
(
begin
(
input_shape
),
end
(
input_shape
),
back_inserter
(
data_shape
));
data
=
builder
::
reshape
(
data
,
data_shape
);
}
auto
axes_node
=
input
(
1
).
get_source_output
().
get_node_shared_ptr
();
NODE_VALIDATION_CHECK
(
this
,
axes_node
->
is_constant
(),
"doesn't support 'axes' input of other type than a Constant."
);
// Calculate norm over axes indicated by axes input param
auto
axes_constant
=
dynamic_pointer_cast
<
op
::
Constant
>
(
axes_node
);
auto
axes_vector
=
axes_constant
->
get_vector
<
size_t
>
();
AxisSet
reduction_axes
{
axes_vector
};
AxisSet
reduction_axes
=
get_reduction_axes
();
// Calculate l2 norm across axes determined by axes input
auto
builder_bias_mode
=
(
m_eps_mode
==
EpsMode
::
MAX
)
?
builder
::
BiasMode
::
MAX
:
builder
::
BiasMode
::
ADD
;
Output
<
Node
>
norm
=
builder
::
l2_norm
(
data
,
reduction_axes
,
m_eps
,
builder_bias_mode
);
norm
=
make_broadcast_node
(
norm
,
data
.
get_shape
(),
0
);
data
=
data
/
norm
;
// get back original input tensor rank
if
(
input_shape
.
size
()
!=
4
)
{
data
=
builder
::
reshape
(
data
,
input_shape
);
}
data
=
make_shared
<
op
::
Divide
>
(
data
,
norm
,
AutoBroadcastSpec
(
AutoBroadcastType
::
NUMPY
));
return
as_node_vector
({
data
});
}
...
...
src/ngraph/op/fused/normalize_l2.hpp
View file @
76e144d3
...
...
@@ -54,6 +54,7 @@ namespace ngraph
EpsMode
get_eps_mode
()
const
{
return
m_eps_mode
;
}
virtual
NodeVector
decompose_op
()
const
override
;
virtual
void
pre_validate_and_infer_types
()
override
;
AxisSet
get_reduction_axes
()
const
;
virtual
std
::
shared_ptr
<
Node
>
copy_with_new_args
(
const
NodeVector
&
new_args
)
const
override
;
...
...
src/ngraph/runtime/intelgpu/unit_test.manifest
View file @
76e144d3
...
...
@@ -69,13 +69,14 @@ gather_4d_indices_no_axis_2d_input
gemm
gemm_broadcast_input_C
normalize_across_chw_4d
normalize_across_empty_axes_input
normalize_across_h_4d
normalize_across_1axis_5d
normalize_across_123axes_5d
normalize_across_chw_4d_max_bias
normalize_across_chw_3d
normalize_across_chw_2d
normalize_across_hw_4d
normalize_invalid_input_tensor_rank
normalize_axes_input_not_constant
normalize_invalid_axes_rank
normalize_
output_shape_across_chw
normalize_
axes_out_of_bounds
hardsigmoid
model_erf
model_erf_int32
...
...
test/backend/fused_op.in.cpp
View file @
76e144d3
...
...
@@ -582,7 +582,7 @@ NGRAPH_TEST(${BACKEND_NAME}, normalize_across_chw_4d)
{
Shape
data_shape
{
1
,
2
,
3
,
4
};
auto
data
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
data_shape
);
const
auto
axes
=
make_shared
<
op
::
Constant
>
(
element
::
u
64
,
Shape
{
3
},
vector
<
int64_t
>
{
1
,
2
,
3
});
const
auto
axes
=
make_shared
<
op
::
Constant
>
(
element
::
i
64
,
Shape
{
3
},
vector
<
int64_t
>
{
1
,
2
,
3
});
float
eps
{
1e-6
f
};
auto
eps_mode
=
op
::
EpsMode
::
ADD
;
...
...
@@ -605,11 +605,11 @@ NGRAPH_TEST(${BACKEND_NAME}, normalize_across_chw_4d)
test_case
.
run
(
DEFAULT_FLOAT_TOLERANCE_BITS
+
1
);
}
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
normalize_across_
chw_3d
)
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
normalize_across_
empty_axes_input
)
{
Shape
data_shape
{
2
,
3
,
4
};
Shape
data_shape
{
1
,
2
,
3
,
4
};
auto
data
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
data_shape
);
const
auto
axes
=
make_shared
<
op
::
Constant
>
(
element
::
u64
,
Shape
{
3
},
vector
<
int64_t
>
{
1
,
2
,
3
});
const
auto
axes
=
make_shared
<
op
::
Constant
>
(
element
::
i64
,
Shape
{
0
},
vector
<
int64_t
>
{
});
float
eps
{
1e-6
f
};
auto
eps_mode
=
op
::
EpsMode
::
ADD
;
...
...
@@ -623,20 +623,17 @@ NGRAPH_TEST(${BACKEND_NAME}, normalize_across_chw_3d)
test_case
.
add_input
<
float
>
(
input_data
);
test_case
.
add_expected_output
<
float
>
(
data_shape
,
{
0.01428571
f
,
0.02857143
f
,
0.04285714
f
,
0.05714286
f
,
0.07142857
f
,
0.08571429
f
,
0.1
f
,
0.11428571
f
,
0.12857144
f
,
0.14285715
f
,
0.15714286
f
,
0.17142858
f
,
0.18571429
f
,
0.2
f
,
0.21428572
f
,
0.22857143
f
,
0.24285714
f
,
0.25714287
f
,
0.27142859
f
,
0.2857143
f
,
0.30000001
f
,
0.31428573
f
,
0.32857144
f
,
0.34285715
f
});
// output should be filled with 1f values
test_case
.
add_expected_output
<
float
>
(
data_shape
,
vector
<
float
>
(
shape_size
(
data_shape
),
1
));
test_case
.
run
(
DEFAULT_FLOAT_TOLERANCE_BITS
+
1
);
}
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
normalize_across_
chw_2
d
)
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
normalize_across_
h_4
d
)
{
Shape
data_shape
{
3
,
4
};
Shape
data_shape
{
1
,
2
,
3
,
4
};
auto
data
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
data_shape
);
const
auto
axes
=
make_shared
<
op
::
Constant
>
(
element
::
u64
,
Shape
{
3
},
vector
<
int64_t
>
{
1
,
2
,
3
});
const
auto
axes
=
make_shared
<
op
::
Constant
>
(
element
::
i64
,
Shape
{
1
},
vector
<
int64_t
>
{
1
});
float
eps
{
1e-6
f
};
auto
eps_mode
=
op
::
EpsMode
::
ADD
;
...
...
@@ -650,28 +647,19 @@ NGRAPH_TEST(${BACKEND_NAME}, normalize_across_chw_2d)
test_case
.
add_input
<
float
>
(
input_data
);
test_case
.
add_expected_output
<
float
>
(
data_shape
,
{
0.03922323
f
,
0.07844646
f
,
0.11766968
f
,
0.15689291
f
,
0.19611613
f
,
0.23533936
f
,
0.2745626
f
,
0.31378582
f
,
0.35300905
f
,
0.39223227
f
,
0.43145549
f
,
0.47067872
f
});
test_case
.
run
();
test_case
.
add_expected_output
<
float
>
(
data_shape
,
{
0.0766965
f
,
0.14142136
f
,
0.19611613
f
,
0.24253564
f
,
0.28216633
f
,
0.31622776
f
,
0.34570536
f
,
0.37139067
f
,
0.39391932
f
,
0.41380295
f
,
0.43145549
f
,
0.44721359
f
,
0.99705452
f
,
0.98994946
f
,
0.98058069
f
,
0.97014254
f
,
0.95936549
f
,
0.94868332
f
,
0.93834311
f
,
0.92847669
f
,
0.91914505
f
,
0.91036648
f
,
0.90213418
f
,
0.89442718
f
});
test_case
.
run
(
DEFAULT_FLOAT_TOLERANCE_BITS
+
1
);
}
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
normalize_across_
empty_axes_input
)
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
normalize_across_
1axis_5d
)
{
Shape
data_shape
{
1
,
2
,
3
,
4
};
Shape
data_shape
{
1
,
2
,
2
,
2
,
3
};
auto
data
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
data_shape
);
const
auto
axes
=
make_shared
<
op
::
Constant
>
(
element
::
u64
,
Shape
{
0
},
vector
<
int64_t
>
{
});
const
auto
axes
=
make_shared
<
op
::
Constant
>
(
element
::
i64
,
Shape
{
1
},
vector
<
int64_t
>
{
1
});
float
eps
{
1e-6
f
};
auto
eps_mode
=
op
::
EpsMode
::
ADD
;
...
...
@@ -685,17 +673,19 @@ NGRAPH_TEST(${BACKEND_NAME}, normalize_across_empty_axes_input)
test_case
.
add_input
<
float
>
(
input_data
);
// output should be filled with 1f values
test_case
.
add_expected_output
<
float
>
(
data_shape
,
vector
<
float
>
(
shape_size
(
data_shape
),
1
));
test_case
.
add_expected_output
<
float
>
(
data_shape
,
{
0.0766965
f
,
0.14142136
f
,
0.19611613
f
,
0.24253564
f
,
0.28216633
f
,
0.31622776
f
,
0.34570536
f
,
0.37139067
f
,
0.39391932
f
,
0.41380295
f
,
0.43145549
f
,
0.44721359
f
,
0.99705452
f
,
0.98994946
f
,
0.98058069
f
,
0.97014254
f
,
0.95936549
f
,
0.94868332
f
,
0.93834311
f
,
0.92847669
f
,
0.91914505
f
,
0.91036648
f
,
0.90213418
f
,
0.89442718
f
});
test_case
.
run
(
DEFAULT_FLOAT_TOLERANCE_BITS
+
1
);
}
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
normalize_across_
hw_4
d
)
NGRAPH_TEST
(
$
{
BACKEND_NAME
},
normalize_across_
123axes_5
d
)
{
Shape
data_shape
{
1
,
2
,
3
,
4
};
Shape
data_shape
{
1
,
2
,
2
,
2
,
3
};
auto
data
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
data_shape
);
const
auto
axes
=
make_shared
<
op
::
Constant
>
(
element
::
u64
,
Shape
{
2
},
vector
<
int64_t
>
{
2
,
3
});
const
auto
axes
=
make_shared
<
op
::
Constant
>
(
element
::
i64
,
Shape
{
3
},
vector
<
int64_t
>
{
1
,
2
,
3
});
float
eps
{
1e-6
f
};
auto
eps_mode
=
op
::
EpsMode
::
ADD
;
...
...
@@ -710,10 +700,10 @@ NGRAPH_TEST(${BACKEND_NAME}, normalize_across_hw_4d)
test_case
.
add_input
<
float
>
(
input_data
);
test_case
.
add_expected_output
<
float
>
(
data_shape
,
{
0.0
3922323
f
,
0.07844646
f
,
0.11766968
f
,
0.15689291
f
,
0.19611613
f
,
0.23533936
f
,
0.
2745626
f
,
0.31378582
f
,
0.35300905
f
,
0.39223227
f
,
0.43145549
f
,
0.47067872
f
,
0.
1994109
f
,
0.2147502
f
,
0.2300895
f
,
0.2454288
f
,
0.26076809
f
,
0.276107
4
f
,
0.
29144669
f
,
0.306786
f
,
0.32212529
f
,
0.3374646
f
,
0.35280389
f
,
0.368143
2
f
});
data_shape
,
{
0.0
2638899
f
,
0.04956816
f
,
0.070014
f
,
0.10555596
f
,
0.1239204
f
,
0.140028
f
,
0.
18472293
f
,
0.19827265
f
,
0.210042
f
,
0.26388991
f
,
0.27262488
f
,
0.280056
f
,
0.
34305686
f
,
0.34697714
f
,
0.35007
f
,
0.42222384
f
,
0.42132938
f
,
0.42008
4
f
,
0.
50139081
f
,
0.49568161
f
,
0.49009803
f
,
0.58055776
f
,
0.57003385
f
,
0.56011
2
f
});
test_case
.
run
(
DEFAULT_FLOAT_TOLERANCE_BITS
+
1
);
}
...
...
@@ -721,7 +711,7 @@ NGRAPH_TEST(${BACKEND_NAME}, normalize_across_chw_4d_max_bias)
{
Shape
data_shape
{
1
,
2
,
3
,
4
};
auto
data
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
data_shape
);
const
auto
axes
=
make_shared
<
op
::
Constant
>
(
element
::
u
64
,
Shape
{
3
},
vector
<
int64_t
>
{
1
,
2
,
3
});
const
auto
axes
=
make_shared
<
op
::
Constant
>
(
element
::
i
64
,
Shape
{
3
},
vector
<
int64_t
>
{
1
,
2
,
3
});
float
eps
{
5000
};
auto
eps_mode
=
op
::
EpsMode
::
MAX
;
...
...
test/type_prop/normalize.cpp
View file @
76e144d3
...
...
@@ -20,11 +20,12 @@
using
namespace
std
;
using
namespace
ngraph
;
TEST
(
type_prop
,
normalize_invalid_input_tensor_rank
)
TEST
(
type_prop
,
normalize_axes_input_not_constant
)
{
Shape
data_shape
{
1
,
2
,
3
,
4
,
5
};
Shape
data_shape
{
1
,
2
,
3
,
4
};
auto
data
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
data_shape
);
auto
axes
=
make_shared
<
op
::
Parameter
>
(
element
::
u64
,
Shape
{
1
,
2
});
auto
axes
=
make_shared
<
op
::
Parameter
>
(
element
::
u64
,
Shape
{
1
});
float
eps
{
1e-6
f
};
auto
eps_mode
=
op
::
EpsMode
::
ADD
;
...
...
@@ -36,15 +37,21 @@ TEST(type_prop, normalize_invalid_input_tensor_rank)
}
catch
(
const
NodeValidationFailure
&
error
)
{
EXPECT_HAS_SUBSTRING
(
error
.
what
(),
std
::
string
(
"Input tensor rank must be 2, 3 or 4 dimensional"
));
EXPECT_HAS_SUBSTRING
(
error
.
what
(),
std
::
string
(
"Input axes must be Constant type"
));
}
catch
(...)
{
FAIL
()
<<
"Deduced type check failed for unexpected reason"
;
}
}
data
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
Shape
{
2
});
TEST
(
type_prop
,
normalize_invalid_axes_rank
)
{
Shape
data_shape
{
1
,
2
,
3
,
4
};
auto
data
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
data_shape
);
const
auto
axes
=
make_shared
<
op
::
Constant
>
(
element
::
i64
,
Shape
{
1
,
2
},
vector
<
int64_t
>
{
1
,
2
});
float
eps
{
1e-6
f
};
auto
eps_mode
=
op
::
EpsMode
::
ADD
;
try
{
...
...
@@ -54,8 +61,7 @@ TEST(type_prop, normalize_invalid_input_tensor_rank)
}
catch
(
const
NodeValidationFailure
&
error
)
{
EXPECT_HAS_SUBSTRING
(
error
.
what
(),
std
::
string
(
"Input tensor rank must be 2, 3 or 4 dimensional"
));
EXPECT_HAS_SUBSTRING
(
error
.
what
(),
std
::
string
(
"Input axes must have rank equals 1"
));
}
catch
(...)
{
...
...
@@ -63,11 +69,11 @@ TEST(type_prop, normalize_invalid_input_tensor_rank)
}
}
TEST
(
type_prop
,
normalize_
invalid_axes_rank
)
TEST
(
type_prop
,
normalize_
axes_out_of_bounds
)
{
Shape
data_shape
{
1
,
2
,
3
,
4
};
auto
data
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
data_shape
);
auto
axes
=
make_shared
<
op
::
Parameter
>
(
element
::
u64
,
Shape
{
1
,
2
});
const
auto
axes
=
make_shared
<
op
::
Constant
>
(
element
::
i64
,
Shape
{
2
},
vector
<
int64_t
>
{
3
,
4
});
float
eps
{
1e-6
f
};
auto
eps_mode
=
op
::
EpsMode
::
ADD
;
...
...
@@ -79,23 +85,10 @@ TEST(type_prop, normalize_invalid_axes_rank)
}
catch
(
const
NodeValidationFailure
&
error
)
{
EXPECT_HAS_SUBSTRING
(
error
.
what
(),
std
::
string
(
"
Input axes must have rank equals 1
"
));
EXPECT_HAS_SUBSTRING
(
error
.
what
(),
std
::
string
(
"
Reduction axis (
"
));
}
catch
(...)
{
FAIL
()
<<
"Deduced type check failed for unexpected reason"
;
}
}
TEST
(
type_prop
,
normalize_output_shape_across_chw
)
{
Shape
data_shape
{
2
,
3
,
4
};
auto
data
=
make_shared
<
op
::
Parameter
>
(
element
::
f32
,
data_shape
);
const
auto
axes
=
make_shared
<
op
::
Constant
>
(
element
::
u64
,
Shape
{
3
},
vector
<
int64_t
>
{
1
,
2
,
3
});
float
eps
{
1e-6
f
};
auto
eps_mode
=
op
::
EpsMode
::
ADD
;
auto
normalize
=
make_shared
<
op
::
NormalizeL2
>
(
data
,
axes
,
eps
,
eps_mode
);
EXPECT_EQ
(
normalize
->
get_element_type
(),
element
::
f32
);
EXPECT_EQ
(
normalize
->
get_shape
(),
(
Shape
{
2
,
3
,
4
}));
}
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