-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Transformations][CPU] Introduce Convolution fusion with bias #29076
base: master
Are you sure you want to change the base?
Conversation
2c87699
to
ce6fcca
Compare
@@ -51,5 +54,8 @@ std::vector<TRShape> shape_infer(const TOp* op, | |||
return output_shapes; | |||
} | |||
} // namespace v1 | |||
|
|||
using v1::shape_infer; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could using
be avoided in .hpp file? How complex is alternative solution?
fyi @praasz
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be removed or have some local scope only like: function, code block etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adjusted, the only drawback is the change of 1 line in GPU plugin
Are there going to be any tests added for the added functionality? |
namespace op { | ||
namespace internal { | ||
|
||
class TRANSFORMATIONS_API ConvolutionBiased : public ov::op::util::ConvolutionFwdPropBase { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TRANSFORMATIONS_API is usually used for exporting transformations, not operations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, this is strange. I can see TRANSFORMATIONS_API
macro usage in this context across many files in src/common/transformations/include/ov_ops
dir. Do they also use that in incorrect way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, then we may re-do this in separate PR. Operation is not a transformation:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be TRANSFORMATIONS_API
as it regards build target, not class category.
|
||
} // namespace pass | ||
} // namespace ov | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add description for this transofrmation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where it is better to add such description? This is transformation from convolution of the particular opset to the convolution of the internal opset
@@ -266,8 +270,35 @@ Convolution::Convolution(const std::shared_ptr<ov::Node>& op, const GraphContext | |||
|
|||
auto convolutionOp = ov::as_type_ptr<ov::op::v1::Convolution>(op); | |||
auto groupConvolutionOp = ov::as_type_ptr<ov::op::v1::GroupConvolution>(op); | |||
auto biasedConvolutionOp = ov::as_type_ptr<ov::op::internal::ConvolutionBiased>(op); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we add specification for this operation here: https://github.com/openvinotoolkit/openvino/tree/master/docs/articles_en/documentation/openvino-ir-format/operation-sets/operation-specs/internal ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good question. Shall we? if it is a regular convolution, but with bias input supported
b043ab0
to
6f3e01a
Compare
Added unit test for the new operation. Functional tests already check whether node is fused or not. Basically, here we have the situation that this pass was disabled in graph_optimizer and enabled on transformation side. So current functional and model tests play the role of regression tests that transformation was moved correctly from one infrastructure to another |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok for core part.
@aobolensk General comment for this PR:
Item 1 is especially important to avoid cartesian product of operation types in bounds of item 2. So applying it for Convolution I would say we need to have 2 Internal operations:
GPU plugin already support such semantics inplemented as intel_gpu::op::Convolution (src/plugins/intel_gpu/include/intel_gpu/op/convolution.hpp). |
447e18b
to
14089a2
Compare
#include "itt.hpp" | ||
#include "openvino/op/util/precision_sensitive_attribute.hpp" | ||
|
||
using namespace std; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove it
const auto& bias_et = get_input_element_type(2); | ||
result_et = bias_et; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const auto& bias_et = get_input_element_type(2); | |
result_et = bias_et; | |
result_et = get_input_element_type(2); |
|
||
using namespace std; | ||
|
||
namespace ov { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
namespace ov { | |
namespace ov::op::internal { |
Just optional detail to consider
|
||
const auto output_shapes = op::shape_infer(this, input_shapes, m_pads_begin, m_pads_end); | ||
set_output_type(0, result_et, output_shapes[0]); | ||
set_num_spatial(num_spatial, input_shapes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be set if value is undefined?
#include "openvino/pass/pattern/op/wrap_type.hpp" | ||
#include "ov_ops/convolution.hpp" | ||
|
||
using namespace ov; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be removed?
namespace ov { | ||
namespace op { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
namespace ov { | |
namespace op { | |
namespace ov::op::internal { |
template <class TOp, | ||
class TShape, | ||
class TRShape = result_shape_t<TShape>, | ||
typename std::enable_if<std::is_same<TOp, internal::Convolution>::value>::type* = nullptr> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the enable_if shoudl not be required just use internal::Convolution as type
#include "utils.hpp" | ||
|
||
namespace ov { | ||
namespace op { | ||
namespace v1 { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
restore v1
also
const auto pads_end = CoordinateDiff{0, 0, 0}; | ||
const auto auto_pad = op::PadType::SAME_UPPER; | ||
|
||
const auto data = std::make_shared<op::v0::Parameter>(element::f32, PartialShape{-1, -1, -1, -1, -1}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const auto data = std::make_shared<op::v0::Parameter>(element::f32, PartialShape{-1, -1, -1, -1, -1}); | |
const auto data = std::make_shared<op::v0::Parameter>(element::f32, PartialShape::dynamic(5)); |
#include "ov_ops/convolution.hpp" | ||
#include "utils.hpp" | ||
|
||
using namespace ov; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove it.
There can be some collisions in type e.g. Shape
is better to use ov:: for types from core.
Details:
Tickets: