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

Wrong implementation of copy constructor for the different type of layout #166

Open
amitsingh19975 opened this issue Feb 12, 2022 · 0 comments
Labels

Comments

@amitsingh19975
Copy link
Collaborator

amitsingh19975 commented Feb 12, 2022

The dynamic and static rank tensors have a constructor, which takes the tensor of different layouts, implemented incorrectly with an unknown or unimplemented member function. To fix the issue, we have to use the copy algorithm, but instead, we are just copying the whole container, without considering the layout. Furthermore, we are not asserting or checking the type of the tensor if it matches the current tensor.

Current Implementation

  template<typename OTE>
  explicit inline tensor_core (const tensor_core<OTE> &other)
    : tensor_expression_type<self_type>{}
    , _extents  (ublas::begin(other.extents  ()), ublas::end (other.extents  ()))
    , _strides  (ublas::begin(other.extents  ()), ublas::end (other.extents  ()))
    , _container(  std::begin(other.container()),   std::end (other.container()))
  {
  }

To fix:

  • use the method tensor::base instead of unknown method tensor::container
  • use the copy algorithm from the boost/numeric/ublas/tensor/algorithm.hpp
  • static assert to check if the types are the same or not.

After the fix, enable the test that tests the construction of the other layout.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant