8000 Introducing a new and versatile way to create the tensor interface. by amitsingh19975 · Pull Request #90 · boostorg/ublas · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Introducing a new and versatile way to create the tensor interface. #90

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

Merged
merged 52 commits into from
Dec 10, 2020

Conversation

amitsingh19975
Copy link
Collaborator
@amitsingh19975 amitsingh19975 commented Jul 8, 2020

Previously the tensor was constraints to three type of tensors

  • Dynamic tensor
  • Static tensor
  • Fixed rank tensor
    which were predefined and were written in stone or has a rigid interface and the user cannot change the storage type or permute the settings.

With the new tensor interface, we can easily new tensor type even custom storage by the user with proper configuration and easily interact with the current tensor environment without any hassle. This makes the new tensor interface very flexible.

There are few downsides right now

  • Had to remove static tensor tests because we introduced new constraints to the interface but it will be fixed in the next pull request which will be all about proper static tensor integration.
  • For a similar reason had to remove a few tests from the fixed rank tensors and will be fixed with the next pull request.

How to Use the New Interface

/// creates the engine traits with extents and strides with dynamic property with the static storage
using ctype1 = tensor_engine<extents<>, layout::first_order<>, std::array<float,50>>;

/// creates the engine traits with extents  with dynamic property and strides  with static property with the static storage
using ctype2 = tensor_engine<extents<>, layout::first_order<static_extents<1,2,3,4>>, std::array<float,50>>;

/// creates the engine traits with extents and strides with static property with the dynamic storage
using ctype3 = tensor_engine<layout::first_order<static_extents<1,2,3,4>>, std::vector<float>>;

using ttype1 = tensor_core<ctype1>;
using ttype2 = tensor_core<ctype2>;
using ttype3 = tensor_core<ctype3>;

auto t1 = ttype1{extents<>{1,2,3},1.f};
auto t2 = ttype2{extents<>{1,2,3,4},1.f};
auto t3 = ttype3{1.f};

Other than these there are a few minor tweaks to improve the consistency of the code and bug fixes.

@coder3101
Copy link
Contributor

@amitsingh19975 Would you please sync with current development branch and resolve the conflicts.

@amitsingh19975
Copy link
Collaborator Author
amitsingh19975 commented Jul 11, 2020

@amitsingh19975 Would you please sync with current development branch and resolve the conflicts.

Sorry about that I cloned the branch before the new pull request. Now I have synced it. Thanks.

Copy link
@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Reports by clang tidy

@github-actions
Copy link

This Pull request Passed all of clang-tidy tests. 👍

@codecov
Copy link
codecov bot commented Jul 11, 2020

Codecov Report

Merging #90 into develop will decrease coverage by 0.79%.
The diff coverage is 95.41%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop      #90      +/-   ##
===========================================
- Coverage    95.33%   94.54%   -0.80%     
===========================================
  Files           22       19       -3     
  Lines         1223     1192      -31     
===========================================
- Hits          1166     1127      -39     
- Misses          57       65       +8     
Impacted Files Coverage Δ
include/boost/numeric/ublas/tensor/multi_index.hpp 100.00% <ø> (ø)
...lude/boost/numeric/ublas/tensor/multiplication.hpp 85.83% <ø> (-0.84%) ⬇️
.../boost/numeric/ublas/tensor/fixed_rank_strides.hpp 94.28% <85.71%> (-0.96%) ⬇️
...ude/boost/numeric/ublas/tensor/dynamic_strides.hpp 94.59% <86.66%> (-0.76%) ⬇️
.../boost/numeric/ublas/tensor/fixed_rank_extents.hpp 96.15% <92.85%> (+1.86%) ⬆️
include/boost/numeric/ublas/tensor/tensor_core.hpp 93.18% <93.18%> (ø)
include/boost/numeric/ublas/tensor/functions.hpp 94.94% <98.33%> (+0.26%) ⬆️
include/boost/numeric/ublas/tensor/algorithms.hpp 99.09% <100.00%> (ø)
...ude/boost/numeric/ublas/tensor/dynamic_extents.hpp 100.00% <100.00%> (+2.32%) ⬆️
include/boost/numeric/ublas/tensor/expression.hpp 100.00% <100.00%> (ø)
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 92177ce...580bae1. Read the comment docs.

Copy link
@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Reports by clang tidy

Copy link
@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Reports by clang tidy

@amitsingh19975 amitsingh19975 force-pushed the features/tensor_redesign branch from 32e1e24 to 8afd714 Compare August 17, 2020 10:30
Copy link
Collaborator
@bassoy bassoy left a comment

Choose a reason for hiding this comment

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

I still cannot approve due to rebind_storage_t usage.

layout::first_order<c_extents_type>,
layout::last_order<c_extents_type>
>,
rebind_storage_t<c_extents_type,array_type,value_type>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let me phrase it differently. With rebind_storage_t the resulting storage type depends on the input storage type. In this case, the user of the library needs to look into type_traits_tensor.hpp for understanding the output type. Moreover, if the user wants to only have statically allocated containers, this rule forces him/her to not use the prod function or to change the implementation of rebind_storage_t.

Therefore, we should not to have that feature (at least for now) and at most use tag dispatching. Again the prod function with that signature should only be implemented for containers with dynamic extents and strides.

@amitsingh19975 amitsingh19975 force-pushed the features/tensor_redesign branch from ba351d5 to da91a80 Compare October 2, 2020 11:29
Copy link
@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Reports by clang tidy

@amitsingh19975 amitsingh19975 force-pushed the features/tensor_redesign branch from 83521c0 to 75bae8f Compare October 2, 2020 12:06
@amitsingh19975 amitsingh19975 force-pushed the features/tensor_redesign branch from 75bae8f to 9ffd554 Compare October 2, 2020 13:16
@amitsingh19975 amitsingh19975 force-pushed the features/tensor_redesign branch from 11d159a to 80e161a Compare October 2, 2020 13:45
@amitsingh19975 amitsingh19975 force-pushed the features/tensor_redesign branch from 09fae55 to e2680d3 Compare October 2, 2020 14:48
Copy link
Collaborator
@bassoy bassoy left a comment

Choose a reason for hiding this comment

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

Great enhancements!
Only two comments which you can find in the corresponding files.
Please change the valid function to is_valid to be consistent with the naming.

@amitsingh19975
Copy link
Collaborator Author

Great enhancements!
Only two comments which you can find in the corresponding files.
Please change the valid function to is_valid to be consistent with the naming.

Changed valid to is_valid.

Copy link
Collaborator
@bassoy bassoy left a comment

Choose a reason for hiding this comment

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

I think I have three remaining comments. Please look at them and see if there is something you would like to change. Otherwise I approve this.

@amitsingh19975 amitsingh19975 force-pushed the features/tensor_redesign branch from b91a78d to 580bae1 Compare October 5, 2020 09:22
@bassoy bassoy merged commit 799ef70 into develop Dec 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0