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
[XLA] Fix compilation errors in exhaustive test #30434
[XLA] Fix compilation errors in exhaustive test #30434
Conversation
done :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@@ -369,7 +369,8 @@ class Exhaustive32BitOrLessUnaryTest | |||
// type being tested. | |||
template <typename T> | |||
void FillInput(Literal* input_literal) { | |||
using IntegralT = typename IntegralTypeWithByteWidth<sizeof(T)>::type; | |||
using IntegralT = | |||
typename test_util::IntegralTypeWithByteWidth<sizeof(T)>::type; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I realized that this is not use, we can replace the use of IntegralT in the routine with int64.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. will do.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are you sure this is true? IntegralT is a type which depends on the template type T. This does vary from use to use of FillInput.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, IntegralT was left here while it should be remove after I added ConvertAndReplaceKnownIncorrectValueWith.
If input_val is a int64, ConvertAndReplaceKnownIncorrectValueWith will convert it to IntegralT.
IntegralT input_val = i + begin;
input_arr[i] = ConvertAndReplaceKnownIncorrectValueWith<T>(input_val, 0);
@@ -30,6 +30,26 @@ limitations under the License. | |||
namespace xla { | |||
using Eigen::half; | |||
|
|||
namespace test_util { | |||
template <int N> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After we remove the use of this template in the exhaustive_unary_test.cc, would it be better to put this back to the class as "private" or use anonymous namespace here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you still cannot have a specialization of a template class embedded inside a class in official c++. so it has to remain in a separate namespace.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
although it could be an anonymous namespace as you say
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see comment above - i don't think that IntegralT can be removed from the FillInput function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my reply above - I think we should be able to remove IntegralT from FillInput.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that IntegralT is not int64, but we can still replace IntegralT with int64 here, because ConvertAndReplaceKnownIncorrectValueWith will ensure that we will retrieve the right bits from input_val. I am approving this and will make the change I am talking about later.
regarding the windows test failure, it seems very very unlikely that this change can have caused the failure:
|
…mpile-issue PiperOrigin-RevId: 259404629
When I compile the code in the exchaustive ops tests, I get an error. The internet seems to think that this error is due to the code being out of spec for standard C++, as shown here:
https://stackoverflow.com/questions/3052579/explicit-specialization-in-non-namespace-scope
and
https://stackoverflow.com/questions/2097811/c-syntax-for-explicit-specialization-of-a-template-function-in-a-template-clas
This change moves the template out of the enclosing class into a namespace, as the standard requires.
It also adds a constructor for the ErrorSpec class, which also fails to compile due to the use of the braces initialization.
My compiler version is
gcc (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0