google / google/ruy

Compilation error when Scalar is Eigen::half and not float

Open
#346 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
325
Forks
97
PR merge metrics
No merged PRs in 30d

Description

Since `class Matrix` is templatized

````c++
template
class Matrix final {
......
private:
...........
// The zero_point, i.e. which Scalar value is to be interpreted as zero.
// When Scalar is floating-point, this must be 0.
Scalar zero_point_ = 0;
};
````
I could have something like: `Matrix myMatrix;`

but then at compilation I get `error: no viable conversion from 'int' to 'Eigen::half' Scalar zero_point_ = 0;` since the zero isn't templatized

integer 0 and float zero are interchangeable so the above code works; but it's not the generic case for templates. I believe an implementation like `Scalar zero_point_ = Scalar{0};` is more generic

Similar fixes to other classes and parts of the code?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.