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
f749c9d0
Commit
f749c9d0
authored
Nov 28, 2019
by
Tomasz Dołbniak
Committed by
Michał Karzyński
Nov 28, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[SPEC] ConvertLike op (#3944)
parent
8f999289
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
112 additions
and
0 deletions
+112
-0
CMakeLists.txt
src/ngraph/CMakeLists.txt
+2
-0
convert_like.cpp
src/ngraph/op/convert_like.cpp
+48
-0
convert_like.hpp
src/ngraph/op/convert_like.hpp
+52
-0
op_version_tbl.hpp
src/ngraph/op/op_version_tbl.hpp
+1
-0
ops.hpp
src/ngraph/ops.hpp
+1
-0
opset1_tbl.hpp
src/ngraph/opsets/opset1_tbl.hpp
+1
-0
serializer.cpp
src/ngraph/serializer.cpp
+7
-0
No files found.
src/ngraph/CMakeLists.txt
View file @
f749c9d0
...
...
@@ -138,6 +138,8 @@ set (SRC
op/constant.hpp
op/convert.cpp
op/convert.hpp
op/convert_like.cpp
op/convert_like.hpp
op/convolution.cpp
op/convolution.hpp
op/cos.cpp
...
...
src/ngraph/op/convert_like.cpp
0 → 100644
View file @
f749c9d0
//*****************************************************************************
// 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.
//*****************************************************************************
#include <memory>
#include "ngraph/op/convert_like.hpp"
using
namespace
std
;
using
namespace
ngraph
;
constexpr
NodeTypeInfo
op
::
v1
::
ConvertLike
::
type_info
;
op
::
v1
::
ConvertLike
::
ConvertLike
(
const
Output
<
Node
>&
data
,
const
Output
<
Node
>&
like
)
:
Op
({
data
,
like
})
{
constructor_validate_and_infer_types
();
}
void
op
::
v1
::
ConvertLike
::
validate_and_infer_types
()
{
set_output_type
(
0
,
get_input_element_type
(
1
),
get_input_partial_shape
(
0
));
}
shared_ptr
<
Node
>
op
::
v1
::
ConvertLike
::
copy_with_new_args
(
const
NodeVector
&
new_args
)
const
{
check_new_args_count
(
this
,
new_args
);
return
make_shared
<
ConvertLike
>
(
new_args
.
at
(
0
),
new_args
.
at
(
1
));
}
void
op
::
v1
::
ConvertLike
::
generate_adjoints
(
autodiff
::
Adjoints
&
adjoints
,
const
NodeVector
&
deltas
)
{
const
auto
delta
=
deltas
.
at
(
0
);
adjoints
.
add_delta
(
input_value
(
0
),
make_shared
<
op
::
v1
::
ConvertLike
>
(
delta
,
input_value
(
1
)));
}
src/ngraph/op/convert_like.hpp
0 → 100644
View file @
f749c9d0
//*****************************************************************************
// 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.
//*****************************************************************************
#pragma once
#include "ngraph/op/op.hpp"
namespace
ngraph
{
namespace
op
{
namespace
v1
{
/// \brief Elementwise type conversion operation.
class
ConvertLike
:
public
Op
{
public
:
NGRAPH_API
static
constexpr
NodeTypeInfo
type_info
{
"ConvertLike"
,
1
};
const
NodeTypeInfo
&
get_type_info
()
const
override
{
return
type_info
;
}
/// \brief Constructs a conversion operation.
ConvertLike
()
=
default
;
/// \brief Constructs a conversion operation.
/// \param data Node that produces the input tensor.
/// \param like Node which provides the target type information for the conversion.
ConvertLike
(
const
Output
<
Node
>&
data
,
const
Output
<
Node
>&
like
);
void
validate_and_infer_types
()
override
;
virtual
std
::
shared_ptr
<
Node
>
copy_with_new_args
(
const
NodeVector
&
new_args
)
const
override
;
protected
:
virtual
void
generate_adjoints
(
autodiff
::
Adjoints
&
adjoints
,
const
NodeVector
&
deltas
)
override
;
};
}
}
}
src/ngraph/op/op_version_tbl.hpp
View file @
f749c9d0
...
...
@@ -60,6 +60,7 @@ NGRAPH_OP(CompiledKernel, ngraph::op, 0)
NGRAPH_OP
(
Concat
,
ngraph
::
op
::
v0
,
0
)
NGRAPH_OP
(
Constant
,
ngraph
::
op
,
0
)
NGRAPH_OP
(
Convert
,
ngraph
::
op
,
0
)
NGRAPH_OP
(
ConvertLike
,
ngraph
::
op
::
v1
,
1
)
NGRAPH_OP
(
Convolution
,
ngraph
::
op
::
v0
,
0
)
NGRAPH_OP
(
Convolution
,
ngraph
::
op
::
v1
,
1
)
NGRAPH_OP
(
ConvolutionBackpropData
,
ngraph
::
op
::
v0
,
0
)
...
...
src/ngraph/ops.hpp
View file @
f749c9d0
...
...
@@ -39,6 +39,7 @@
#include "ngraph/op/concat.hpp"
#include "ngraph/op/constant.hpp"
#include "ngraph/op/convert.hpp"
#include "ngraph/op/convert_like.hpp"
#include "ngraph/op/convolution.hpp"
#include "ngraph/op/cos.hpp"
#include "ngraph/op/cosh.hpp"
...
...
src/ngraph/opsets/opset1_tbl.hpp
View file @
f749c9d0
...
...
@@ -65,6 +65,7 @@ NGRAPH_OP(Clamp, ngraph::op::v0)
NGRAPH_OP
(
Concat
,
ngraph
::
op
::
v0
)
NGRAPH_OP
(
Constant
,
ngraph
::
op
)
NGRAPH_OP
(
Convert
,
ngraph
::
op
::
v0
)
NGRAPH_OP
(
ConvertLike
,
ngraph
::
op
::
v1
)
NGRAPH_OP
(
Convolution
,
ngraph
::
op
::
v1
)
NGRAPH_OP
(
ConvolutionBackpropData
,
ngraph
::
op
::
v1
)
NGRAPH_OP
(
Cos
,
ngraph
::
op
::
v0
)
...
...
src/ngraph/serializer.cpp
View file @
f749c9d0
...
...
@@ -1057,6 +1057,11 @@ shared_ptr<Node> JSONDeserializer::deserialize_node(json node_js)
node
=
make_shared
<
op
::
Convert
>
(
args
[
0
],
target_type
);
break
;
}
case
OP_TYPEID
:
:
ConvertLike_v1
:
{
node
=
make_shared
<
op
::
v1
::
ConvertLike
>
(
args
[
0
],
args
[
1
]);
break
;
}
case
OP_TYPEID
:
:
Convolution
:
{
auto
window_movement_strides
=
...
...
@@ -3135,6 +3140,8 @@ json JSONSerializer::serialize_node(const Node& n)
node
[
"target_type"
]
=
write_element_type
(
tmp
->
get_convert_element_type
());
break
;
}
case
OP_TYPEID
:
:
ConvertLike_v1
:
{
break
;
}
case
OP_TYPEID
:
:
Convolution
:
{
auto
tmp
=
static_cast
<
const
op
::
v0
::
Convolution
*>
(
&
n
);
...
...
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