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
1d1d6633
Commit
1d1d6633
authored
Jan 20, 2018
by
Robert Kimball
Committed by
Scott Cyphers
Jan 20, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
simplify argument type check (#398)
parent
bd01bf2c
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
36 additions
and
87 deletions
+36
-87
binary_elementwise.cpp
src/ngraph/ops/binary_elementwise.cpp
+4
-9
binary_elementwise_arithmetic.cpp
src/ngraph/ops/binary_elementwise_arithmetic.cpp
+10
-19
binary_elementwise_comparison.cpp
src/ngraph/ops/binary_elementwise_comparison.cpp
+5
-13
convert.cpp
src/ngraph/ops/convert.cpp
+1
-5
not.cpp
src/ngraph/ops/not.cpp
+1
-13
op.hpp
src/ngraph/ops/op.hpp
+7
-10
unary_elementwise.cpp
src/ngraph/ops/unary_elementwise.cpp
+3
-5
unary_elementwise_arithmetic.cpp
src/ngraph/ops/unary_elementwise_arithmetic.cpp
+5
-13
No files found.
src/ngraph/ops/binary_elementwise.cpp
View file @
1d1d6633
...
...
@@ -20,12 +20,10 @@
using
namespace
std
;
using
namespace
ngraph
;
op
::
BinaryElementwise
::
BinaryElementwise
(
const
std
::
string
&
node_type
,
std
::
function
<
const
element
::
Type
&
(
const
element
::
Type
&
,
const
element
::
Type
&
)
>
element_type_function
,
const
std
::
shared_ptr
<
Node
>&
arg0
,
const
std
::
shared_ptr
<
Node
>&
arg1
)
op
::
BinaryElementwise
::
BinaryElementwise
(
const
std
::
string
&
node_type
,
const
element
::
Type
&
result_element_type
,
const
std
::
shared_ptr
<
Node
>&
arg0
,
const
std
::
shared_ptr
<
Node
>&
arg1
)
:
RequiresTensorViewArgs
(
node_type
,
Nodes
{
arg0
,
arg1
})
{
auto
&
input_0
=
get_inputs
().
at
(
0
);
...
...
@@ -35,8 +33,5 @@ op::BinaryElementwise::BinaryElementwise(
throw
ngraph_error
(
"Arguments must have the same tensor view shape"
);
}
const
element
::
Type
&
result_element_type
=
element_type_function
(
input_0
.
get_element_type
(),
input_1
.
get_element_type
());
set_value_type_checked
(
make_shared
<
TensorViewType
>
(
result_element_type
,
input_0
.
get_shape
()));
}
src/ngraph/ops/binary_elementwise_arithmetic.cpp
View file @
1d1d6633
...
...
@@ -20,24 +20,15 @@ using namespace ngraph;
op
::
BinaryElementwiseArithmetic
::
BinaryElementwiseArithmetic
(
const
std
::
string
&
node_type
,
const
std
::
shared_ptr
<
Node
>&
arg0
,
const
std
::
shared_ptr
<
Node
>&
arg1
)
:
BinaryElementwise
(
node_type
,
[](
const
element
::
Type
&
arg0_element_type
,
const
element
::
Type
&
arg1_element_type
)
->
const
element
::
Type
&
{
if
(
arg0_element_type
!=
arg1_element_type
)
{
throw
ngraph_error
(
"Arguments must have the same tensor view element type"
);
}
if
(
arg0_element_type
==
element
::
boolean
)
{
throw
ngraph_error
(
"Operands for arithmetic operators must have numeric element type"
);
}
return
arg0_element_type
;
},
arg0
,
arg1
)
:
BinaryElementwise
(
node_type
,
arg0
->
get_element_type
(),
arg0
,
arg1
)
{
if
(
arg0
->
get_element_type
()
!=
arg1
->
get_element_type
())
{
throw
ngraph_error
(
"Arguments must have the same tensor view element type"
);
}
if
(
arg0
->
get_element_type
()
==
element
::
boolean
)
{
throw
ngraph_error
(
"Operands for arithmetic operators must have numeric element type"
);
}
}
src/ngraph/ops/binary_elementwise_comparison.cpp
View file @
1d1d6633
...
...
@@ -21,18 +21,10 @@ using namespace ngraph;
op
::
BinaryElementwiseComparison
::
BinaryElementwiseComparison
(
const
std
::
string
&
node_type
,
const
std
::
shared_ptr
<
Node
>&
arg0
,
const
std
::
shared_ptr
<
Node
>&
arg1
)
:
BinaryElementwise
(
node_type
,
[](
const
element
::
Type
&
arg0_element_type
,
const
element
::
Type
&
arg1_element_type
)
->
const
element
::
Type
&
{
if
(
arg0_element_type
!=
arg1_element_type
)
{
throw
ngraph_error
(
"Arguments must have the same tensor view element type"
);
}
return
element
::
boolean
;
},
arg0
,
arg1
)
:
BinaryElementwise
(
node_type
,
element
::
boolean
,
arg0
,
arg1
)
{
if
(
arg0
->
get_element_type
()
!=
arg1
->
get_element_type
())
{
throw
ngraph_error
(
"Arguments must have the same tensor view element type"
);
}
}
src/ngraph/ops/convert.cpp
View file @
1d1d6633
...
...
@@ -20,11 +20,7 @@ using namespace std;
using
namespace
ngraph
;
op
::
Convert
::
Convert
(
const
std
::
shared_ptr
<
Node
>&
arg
,
const
ngraph
::
element
::
Type
&
element_type
)
:
UnaryElementwise
(
"Convert"
,
[
&
](
const
ngraph
::
element
::
Type
&
ignored
)
->
const
ngraph
::
element
::
Type
&
{
return
element_type
;
},
arg
)
:
UnaryElementwise
(
"Convert"
,
element_type
,
arg
)
,
m_element_type
(
element_type
)
{
}
...
...
src/ngraph/ops/not.cpp
View file @
1d1d6633
...
...
@@ -19,19 +19,7 @@ using namespace ngraph;
using
namespace
ngraph
::
op
;
op
::
Not
::
Not
(
const
std
::
shared_ptr
<
Node
>&
arg
)
:
UnaryElementwise
(
"Not"
,
[](
const
ngraph
::
element
::
Type
&
arg_element_type
)
->
const
ngraph
::
element
::
Type
&
{
if
(
arg_element_type
!=
element
::
boolean
)
{
throw
ngraph_error
(
"Operands for logical operators must have boolean element "
"type"
);
}
return
arg_element_type
;
},
arg
)
:
UnaryElementwise
(
"Not"
,
arg
->
get_element_type
(),
arg
)
{
}
...
...
src/ngraph/ops/op.hpp
View file @
1d1d6633
...
...
@@ -60,10 +60,9 @@ namespace ngraph
/// \brief Constructs a unary elementwise tensor operation.
///
/// \param arg Node that produces the input tensor.
UnaryElementwise
(
const
std
::
string
&
node_type
,
std
::
function
<
const
element
::
Type
&
(
const
element
::
Type
&
)
>
element_type_function
,
const
std
::
shared_ptr
<
Node
>&
arg
);
UnaryElementwise
(
const
std
::
string
&
node_type
,
const
element
::
Type
&
result_element_type
,
const
std
::
shared_ptr
<
Node
>&
arg
);
};
/// \brief Abstract base class for elementwise unary arithmetic operations, i.e., operations where the same
...
...
@@ -119,12 +118,10 @@ namespace ngraph
///
/// \param arg0 Node that produces the first input tensor.
/// \param arg1 Node that produces the second input tensor.
BinaryElementwise
(
const
std
::
string
&
node_type
,
std
::
function
<
const
element
::
Type
&
(
const
element
::
Type
&
,
const
element
::
Type
&
)
>
element_type_function
,
const
std
::
shared_ptr
<
Node
>&
arg0
,
const
std
::
shared_ptr
<
Node
>&
arg1
);
BinaryElementwise
(
const
std
::
string
&
node_type
,
const
element
::
Type
&
result_element_type
,
const
std
::
shared_ptr
<
Node
>&
arg0
,
const
std
::
shared_ptr
<
Node
>&
arg1
);
};
/// \brief Abstract base class for elementwise binary comparison operations, i.e., operations where the same
...
...
src/ngraph/ops/unary_elementwise.cpp
View file @
1d1d6633
...
...
@@ -19,14 +19,12 @@
using
namespace
std
;
using
namespace
ngraph
;
op
::
UnaryElementwise
::
UnaryElementwise
(
const
std
::
string
&
node_type
,
std
::
function
<
const
element
::
Type
&
(
const
element
::
Type
&
)
>
element_type_function
,
const
std
::
shared_ptr
<
Node
>&
arg
)
op
::
UnaryElementwise
::
UnaryElementwise
(
const
std
::
string
&
node_type
,
const
element
::
Type
&
result_element_type
,
const
std
::
shared_ptr
<
Node
>&
arg
)
:
RequiresTensorViewArgs
(
node_type
,
Nodes
{
arg
})
{
auto
&
input
=
get_inputs
().
at
(
0
);
const
element
::
Type
&
result_element_type
=
element_type_function
(
input
.
get_element_type
());
set_value_type_checked
(
result_element_type
,
input
.
get_shape
());
}
src/ngraph/ops/unary_elementwise_arithmetic.cpp
View file @
1d1d6633
...
...
@@ -18,18 +18,10 @@ using namespace ngraph;
op
::
UnaryElementwiseArithmetic
::
UnaryElementwiseArithmetic
(
const
std
::
string
&
node_type
,
const
std
::
shared_ptr
<
Node
>&
arg
)
:
UnaryElementwise
(
node_type
,
[](
const
ngraph
::
element
::
Type
&
arg_element_type
)
->
const
ngraph
::
element
::
Type
&
{
if
(
arg_element_type
==
element
::
boolean
)
{
throw
ngraph_error
(
"Operands for arithmetic operators must have numeric element "
"type"
);
}
return
arg_element_type
;
},
arg
)
:
UnaryElementwise
(
node_type
,
arg
->
get_element_type
(),
arg
)
{
if
(
arg
->
get_element_type
()
==
element
::
boolean
)
{
throw
ngraph_error
(
"Operands for arithmetic operators must have numeric element type"
);
}
}
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