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
559d5890
Commit
559d5890
authored
Aug 24, 2018
by
Michał Karzyński
Committed by
Robert Kimball
Aug 24, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ONNX] Move Convolution and Pooling helpers to utils/convpool (#1486)
parent
e81d30f1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
81 additions
and
69 deletions
+81
-69
CMakeLists.txt
src/ngraph/frontend/onnx_import/CMakeLists.txt
+10
-10
node.hpp
src/ngraph/frontend/onnx_import/core/node.hpp
+0
-59
convpool.cpp
src/ngraph/frontend/onnx_import/utils/convpool.cpp
+37
-0
convpool.hpp
src/ngraph/frontend/onnx_import/utils/convpool.hpp
+34
-0
No files found.
src/ngraph/frontend/onnx_import/CMakeLists.txt
View file @
559d5890
...
@@ -34,6 +34,15 @@ add_library(onnx_import_interface OBJECT
...
@@ -34,6 +34,15 @@ add_library(onnx_import_interface OBJECT
add_library
(
onnx_import STATIC
add_library
(
onnx_import STATIC
onnx.pb.cc
onnx.pb.cc
core/attribute.cpp
core/attribute.hpp
core/graph.cpp
core/graph.hpp
core/model.hpp
core/node.cpp
core/node.hpp
core/tensor.hpp
core/value_info.hpp
exceptions.hpp
exceptions.hpp
op/add.hpp
op/add.hpp
op/batch_norm.cpp
op/batch_norm.cpp
...
@@ -48,16 +57,7 @@ add_library(onnx_import STATIC
...
@@ -48,16 +57,7 @@ add_library(onnx_import STATIC
utils/broadcasting.cpp
utils/broadcasting.cpp
utils/broadcasting.hpp
utils/broadcasting.hpp
utils/convpool.cpp
utils/convpool.cpp
utils/convpool.hpp
utils/convpool.hpp
)
core/attribute.cpp
core/attribute.hpp
core/graph.cpp
core/graph.hpp
core/model.hpp
core/node.cpp
core/node.hpp
core/tensor.hpp
core/value_info.hpp
)
add_dependencies
(
onnx_import onnx_import_interface
)
add_dependencies
(
onnx_import onnx_import_interface
)
...
...
src/ngraph/frontend/onnx_import/core/node.hpp
View file @
559d5890
...
@@ -117,65 +117,6 @@ namespace ngraph
...
@@ -117,65 +117,6 @@ namespace ngraph
return
(
outs
<<
"<Node("
<<
node
.
op_type
()
<<
"): "
<<
node
.
get_name
()
<<
">"
);
return
(
outs
<<
"<Node("
<<
node
.
op_type
()
<<
"): "
<<
node
.
get_name
()
<<
">"
);
}
}
namespace
attribute
{
/**
* @brief Get shape of kernel (filter) in pixels.
*
* @param node The Node ptr representing Conv or Pool operation.
* @return The kernel Shape object representing its dimensions (height, width, depth).
*/
inline
Shape
get_kernel_shape
(
const
Node
&
node
)
{
return
node
.
get_attribute_value
<
std
::
vector
<
std
::
size_t
>>
(
"kernel_shape"
,
{
1
,
1
});
}
namespace
detail
{
inline
Strides
get_strides_helper
(
const
Node
&
node
,
const
std
::
string
&
name
,
const
Shape
&
kernel_shape
)
{
return
node
.
get_attribute_value
<
std
::
vector
<
std
::
size_t
>>
(
name
,
std
::
vector
<
std
::
size_t
>
(
kernel_shape
.
size
(),
1UL
));
}
}
// namespace detail
/**
* @brief Get number of pixels to stride operation by in each direction.
*
* @param node The Node ptr representing Conv or Pool operation.
* @param kernel_shape The shape of the kernel which we retrieve strides for.
* @return The kernel Shape object representing its dimensions (height, width, depth).
*/
inline
Strides
get_strides
(
const
Node
&
node
,
const
Shape
&
kernel_shape
)
{
return
detail
::
get_strides_helper
(
node
,
"strides"
,
kernel_shape
);
}
/**
* @brief Get number of pixels to stride operation by in each direction.
*
* @param node The Node ptr representing Conv or Pool operation.
* @return The kernel Shape object representing its dimensions (height, width, depth).
*/
inline
Strides
get_strides
(
const
Node
&
node
)
{
return
get_strides
(
node
,
get_kernel_shape
(
node
));
}
/**
* @brief Get number of pixels for filter dilation in each direction.
*
* @param node The Node ptr representing ONNX operation.
* @return The Strides object containing number of pixels for filter dilation
* (height, width, depth).
*/
inline
Strides
get_dilations
(
const
Node
&
node
)
{
return
detail
::
get_strides_helper
(
node
,
"dilations"
,
get_kernel_shape
(
node
));
}
}
// namespace attribute
}
// namespace onnx_import
}
// namespace onnx_import
}
// namespace ngraph
}
// namespace ngraph
src/ngraph/frontend/onnx_import/utils/convpool.cpp
View file @
559d5890
...
@@ -17,12 +17,49 @@
...
@@ -17,12 +17,49 @@
#include "convpool.hpp"
#include "convpool.hpp"
#include <cmath>
#include <cmath>
#include "ngraph/coordinate_diff.hpp"
#include "ngraph/shape.hpp"
#include "core/attribute.hpp"
#include "core/node.hpp"
namespace
ngraph
namespace
ngraph
{
{
namespace
onnx_import
namespace
onnx_import
{
{
namespace
attribute
namespace
attribute
{
{
Shape
get_kernel_shape
(
const
Node
&
node
)
{
return
node
.
get_attribute_value
<
std
::
vector
<
std
::
size_t
>>
(
"kernel_shape"
,
{
1
,
1
});
}
namespace
detail
{
Strides
get_strides_helper
(
const
Node
&
node
,
const
std
::
string
&
name
,
const
Shape
&
kernel_shape
)
{
return
node
.
get_attribute_value
<
std
::
vector
<
std
::
size_t
>>
(
name
,
std
::
vector
<
std
::
size_t
>
(
kernel_shape
.
size
(),
1UL
));
}
}
// namespace detail
Strides
get_strides
(
const
Node
&
node
,
const
Shape
&
kernel_shape
)
{
return
detail
::
get_strides_helper
(
node
,
"strides"
,
kernel_shape
);
}
Strides
get_strides
(
const
Node
&
node
)
{
return
get_strides
(
node
,
get_kernel_shape
(
node
));
}
Strides
get_dilations
(
const
Node
&
node
)
{
return
detail
::
get_strides_helper
(
node
,
"dilations"
,
get_kernel_shape
(
node
));
}
namespace
namespace
{
{
CoordinateDiff
get_auto_pads
(
const
Shape
&
kernel_shape
,
const
std
::
string
&
auto_pad
)
CoordinateDiff
get_auto_pads
(
const
Shape
&
kernel_shape
,
const
std
::
string
&
auto_pad
)
...
...
src/ngraph/frontend/onnx_import/utils/convpool.hpp
View file @
559d5890
...
@@ -28,6 +28,40 @@ namespace ngraph
...
@@ -28,6 +28,40 @@ namespace ngraph
{
{
namespace
attribute
namespace
attribute
{
{
/**
* @brief Get shape of kernel (filter) in pixels.
*
* @param node The Node ptr representing Conv or Pool operation.
* @return The kernel Shape object representing its dimensions (height, width, depth).
*/
Shape
get_kernel_shape
(
const
Node
&
node
);
/**
* @brief Get number of pixels to stride operation by in each direction.
*
* @param node The Node ptr representing Conv or Pool operation.
* @param kernel_shape The shape of the kernel which we retrieve strides for.
* @return The kernel Shape object representing its dimensions (height, width, depth).
*/
Strides
get_strides
(
const
Node
&
node
,
const
Shape
&
kernel_shape
);
/**
* @brief Get number of pixels to stride operation by in each direction.
*
* @param node The Node ptr representing Conv or Pool operation.
* @return The kernel Shape object representing its dimensions (height, width, depth).
*/
Strides
get_strides
(
const
Node
&
node
);
/**
* @brief Get number of pixels for filter dilation in each direction.
*
* @param node The Node ptr representing ONNX operation.
* @return The Strides object containing number of pixels for filter dilation
* (height, width, depth).
*/
Strides
get_dilations
(
const
Node
&
node
);
/**
/**
* @brief Get padding values for the operation described by an ONNX node.
* @brief Get padding values for the operation described by an ONNX node.
* @details If `auto_pad` attribute is specified as SAME_UPPER or SAME_LOWER, or VALID
* @details If `auto_pad` attribute is specified as SAME_UPPER or SAME_LOWER, or VALID
...
...
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