Skip to content
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

[OV20] Layout class implementation - basic API #7452

Merged
merged 11 commits into from
Sep 13, 2021

Conversation

nosovmik
Copy link
Contributor

@nosovmik nosovmik commented Sep 9, 2021

Details:

  • Class representing parameter/result layout, like 'NCHW'
  • For mean/scale vector operations: get 'channels' dimension of layout for appropriate constant creation
  • Test code coverage is 100%

Tickets:

  • 62181

@nosovmik nosovmik requested a review from a team September 9, 2021 16:52
@nosovmik nosovmik marked this pull request as draft September 9, 2021 16:53
@openvino-pushbot openvino-pushbot added the category: Core OpenVINO Core (aka ngraph) label Sep 9, 2021
@nosovmik nosovmik marked this pull request as ready for review September 9, 2021 19:19
@ilya-lavrenov ilya-lavrenov added this to the 2022.1 milestone Sep 10, 2021
- Removed setters
- Removed LayoutRank from public classes
ngraph/core/include/openvino/core/layout.hpp Show resolved Hide resolved
int64_t m_right_size = 0;
};

namespace layouts {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe just layout

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, will change

ngraph/test/layout.cpp Show resolved Hide resolved
TEST(layout, custom_dims) {
Layout l = "0ac";
EXPECT_FALSE(layouts::has_batch(l));
EXPECT_ANY_THROW(layouts::batch(l));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why any throw here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, will correct. Also will change exception type from ngraph_error to ov::AssertFailure

- Rename 'layouts' namespace to 'layout'
- 'get_index_by_name' - specify throw exception type
ngraph/core/include/openvino/core/layout.hpp Show resolved Hide resolved
static const std::map<std::string, std::string>& dim_aliases() {
static const std::map<std::string, std::string> DIM_ALIASES = {{BATCH, BATCH},
{"BATCH", BATCH},
{"B", BATCH},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we really need "B" as batch? I don't think it's a common name for batch

@jane-intel do you have any advices here?

auto layout = std::dynamic_pointer_cast<VariantWrapper<Layout>>(it->second);
OPENVINO_ASSERT(layout, "Layout runtime info for node is invalid");
if (!layout::has_channels(layout->get())) {
return -1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-1 means channels is last. Maybe we need different invalid value?


static StaticShape construct_mean_scale_shape(const std::shared_ptr<Node>& node, size_t values_size) {
// TODO: support also Mean/Scale image case
auto channels = get_channels_helper(node);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

channels_index? Channels here seems to be a number of channels itself..

@ilya-lavrenov ilya-lavrenov merged commit 2236c61 into openvinotoolkit:master Sep 13, 2021
@ilya-lavrenov
Copy link
Contributor

Let's fix comments in next PR together with case when we add mean / scale preprocessing for case "N..C"

akuporos pushed a commit to akuporos/openvino that referenced this pull request Sep 29, 2021
* Draft

* More tests

* to_string + advanced_syntax + more tests

* Coding style

* Add mean/scale - vector version with layout support

Vector version requires layout to be set

* Added comments to LayoutRank

* Removed unnecessary public API
- Removed setters
- Removed LayoutRank from public classes

* Review comments:
- Rename 'layouts' namespace to 'layout'
- 'get_index_by_name' - specify throw exception type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: Core OpenVINO Core (aka ngraph)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants