Comments (8)
Thanks @Faaux.
This should not happen. We will review this bug.
I have a simplified version with no extra additional type using the tensor
type: godbolt
Seems that our tests do not include optimization:
travis.yml
from ublas.
Dear @Faaux
We have discussed this matter in our gitter channel.
This bug is caused by not applying the rule of three for expression template types. With optimization flags, a compiler can optimize the implicitly defined constructors such that const&
to values are not copied.
You can prevent such behavior by not copy-constructing expression template objects, as you already have presented in your example.
We will fix this bug with the next releases by restructing and revisiting expression templates with tensors, matrices and vectors. Either we will use Boost.Yap as already presented in our GSoC19 project or fully get rid of expression templates. The GSoC20 project will provide the latest changes for Boost.uBlas.
Thanks.
from ublas.
Hey @bassoy
Good to hear :)
I was wondering if there is a quick way to determine when this is happening? I am working with a pre-existing code-base and there are possibly quite a lot of situations where this could occur. I have found (by now) three situations where this is happening. This is new to us since we are currently in the process of upgrading Boost to 1.73. This could be breaking for us!
Maybe a patch that deletes the copy-constructor, just to determine where we are using it?
Best,
Faaux
from ublas.
template<class E1, class E2, class F>
struct vector_binary_scalar2_traits {
typedef vector_binary_scalar2<E1, E2, F> expression_type; // allow E2 to be builtin type
#ifndef BOOST_UBLAS_SIMPLE_ET_DEBUG
typedef expression_type result_type;
#else
typedef typename E1::vector_temporary_type result_type;
#endif
};
As in the inital bug report defining BOOST_UBLAS_SIMPLE_ET_DEBUG
got rid of the problem as well (even though this might just be in the presented case). Could you confirm this? What would the implications be when we compile with BOOST_UBLAS_SIMPLE_ET_DEBUG
?
Thanks again!
Edit: For our use-case it might be possible to overload the according operators. Something like: https://godbolt.org/z/BHLwV9
Am I missing something?
from ublas.
Hey @bassoy
Good to hear :)I was wondering if there is a quick way to determine when this is happening?
As you have already found out, the problem occurs when you copy construct an expression template.
I recommend to evaluate the expression instantaneously.
I am working with a pre-existing code-base and there are possibly quite a lot of situations where this could occur. I have found > (by now) three situations where this is happening. This is new to us since we are currently in the process of upgrading Boost to > 1.73. This could be breaking for us!
Maybe a patch that deletes the copy-constructor, just to determine where we are using it?
We are working on a completely new stable solution using Boost.Yap which will be thoroughly tested and more powerful.
Best,
Faaux
from ublas.
Hey @bassoy,
any update or timeline on this?
from ublas.
@Faaux thanks for asking.
Yes, we have found the root cause and propose two possible solutions, see #125.
We might fixing this issue for tensor expressions in the develop branch in the next two months.
However, I do not want to promise any timeline for the release in the master branch as we are still in the transition phase from matrix to tensor.
A quick solution is to directly use tensor, matrix or vector objects on the lhs of the expression. This will not slow down your program and you program will produce the correct results.
Hope this helps.
from ublas.
Thanks for letting me know and glad you found a fix.
Sadly that still is not an option to change a larger codebase and find all instances to change the auto. I have a workaround in place, thanks for your work :)
from ublas.
Related Issues (20)
- Exception raised on the construction of the tensor from the `tensor_expression`
- Wrong `to_strides_v` computation
- Transpose for Rank One Tensors HOT 1
- Exception Raised for Static Rank Tensor inside the Tensor Times Tensor Product
- Use of Template Type in the Wrong Place HOT 4
- Extension of lifetime within tensor expression templates for prvalues not guaranteed. HOT 1
- Incorrect parameter ordering in element_sub HOT 4
- Error in Github Actions due to incorrect msvc toolset version
- Compiler cannot perform small-object and other optimizations in algorithms.cpp HOT 5
- Use function call operator for indexing instead of at HOT 2
- Fixing iteration-type of for-loop. HOT 3
- Wrong implementation of copy constructor for the different type of layout
- Tensor examples in the documentation are not correct.
- Boost\libs\numeric\ublas failed to build due to error C2059, C2065, C2923, C2976, C2447 .... on MSVC HOT 6
- Deprecated Inheritance From std::iterator Didn't Make It To Release HOT 7
- ublas::matrix broken with compiler error with build 1.80 but not 1.63 HOT 2
- ublas::matrix::resize with preserve= true, can it be implemented without temporary storage?
- No type named ''allocator_size_type“ in namespace 'boost' HOT 1
- Modular Boost C++ Libraries Request HOT 1
- Wrong behavior of map_array copy constructor.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ublas.