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

[XLA] Fix compilation errors in exhaustive test #30434

Conversation

DavidNorman
Copy link
Contributor

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

@tensorflow-bot tensorflow-bot bot added the size:M CL Change Size: Medium label Jul 5, 2019
@rthadur rthadur self-assigned this Jul 7, 2019
@rthadur rthadur added this to Assigned Reviewer in PR Queue via automation Jul 7, 2019
@rthadur rthadur requested a review from sanjoy July 7, 2019 21:57
@rthadur rthadur added the comp:xla XLA label Jul 7, 2019
PR Queue automation moved this from Assigned Reviewer to Reviewer Requested Changes Jul 7, 2019
@DavidNorman
Copy link
Contributor Author

done :)

Copy link
Contributor

@sanjoy sanjoy left a comment

Choose a reason for hiding this comment

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

lgtm

PR Queue automation moved this from Reviewer Requested Changes to Approved by Reviewer Jul 9, 2019
@tensorflow-bot tensorflow-bot bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels Jul 9, 2019
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Jul 9, 2019
@@ -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;
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok. will do.

Copy link
Contributor Author

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.

Copy link
Contributor

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>
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor

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.

@DavidNorman
Copy link
Contributor Author

regarding the windows test failure, it seems very very unlikely that this change can have caused the failure:

AttributeError: Can't pickle local object 'TFRecordWriterCloseAndFlushTests.testFlush.<locals>.childProcess'

@rthadur rthadur removed the ready to pull PR ready for merge process label Jul 12, 2019
@rthadur rthadur requested review from bixia1 and sanjoy July 12, 2019 17:16
@tensorflow-bot tensorflow-bot bot added kokoro:force-run Tests on submitted change ready to pull PR ready for merge process labels Jul 19, 2019
@kokoro-team kokoro-team removed the kokoro:force-run Tests on submitted change label Jul 19, 2019
@rthadur rthadur added ready to pull PR ready for merge process and removed ready to pull PR ready for merge process labels Jul 22, 2019
@tensorflow-copybara tensorflow-copybara merged commit 20f510c into tensorflow:master Jul 22, 2019
PR Queue automation moved this from Approved by Reviewer to Merged Jul 22, 2019
tensorflow-copybara pushed a commit that referenced this pull request Jul 22, 2019
…mpile-issue

PiperOrigin-RevId: 259404629
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes comp:xla XLA ready to pull PR ready for merge process size:M CL Change Size: Medium
Projects
PR Queue
  
Merged
Development

Successfully merging this pull request may close these issues.

None yet

7 participants