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

Implementation of relational operator for complex numbers in XLA #39133

Closed

Conversation

joschkabraun
Copy link

This is the suggestion to implement relational operators for complex numbers (<, <=, >, >=) as in numpy, i.e., the lexicographical order. In this PR only the ">" relation was implemented as feedback from the community is important to evaluate if this functionality is wished for and makes sense.

This could be leveraged for the implementation of np.unique in JAX as comparison and sorting of complex arrays is not supported by XLA but possible with numpy. Another usage could be an implementation of complex QR decomposition in JAX.

The remaining comparisons for complex numbers and tests for it, will be added if this functionality makes sense.

@google-ml-butler google-ml-butler bot added the size:S CL Change Size: Small label May 3, 2020
@google-ml-butler google-ml-butler bot requested a review from joker-eph May 3, 2020 21:36
@gbaned gbaned self-assigned this May 4, 2020
@gbaned gbaned added the comp:xla XLA label May 4, 2020
@gbaned gbaned added this to Assigned Reviewer in PR Queue via automation May 4, 2020
@gbaned gbaned added the awaiting review Pull request awaiting review label May 8, 2020
@gbaned gbaned requested a review from cheshire May 15, 2020 10:29
@cheshire
Copy link
Member

Matching numpy semantics makes sense to me, could we add tests?

@tensorflowbutler tensorflowbutler removed the awaiting review Pull request awaiting review label May 17, 2020
@gbaned
Copy link
Contributor

gbaned commented May 19, 2020

@joschkabraun Can you please check @cheshire's comments and keep us posted. Thanks!

@gbaned gbaned added the stat:awaiting response Status - Awaiting response from author label May 19, 2020
@joschkabraun
Copy link
Author

Okay, perfect! I’m currently working on it and will finish this weekend!

@tensorflowbutler tensorflowbutler removed the stat:awaiting response Status - Awaiting response from author label May 23, 2020
@gbaned gbaned added the stat:awaiting response Status - Awaiting response from author label May 27, 2020
@joschkabraun
Copy link
Author

I have been looking through the code. Am I correct in assuming the tests for that should be placed into the file elemental_ir_emitter_test.cc?

Copy link
Member

@cheshire cheshire left a comment

Choose a reason for hiding this comment

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

Yes, adding tests to elemental_ir_emitter_test would make sense.

@@ -1292,6 +1292,16 @@ StatusOr<llvm::Value*> ElementalIrEmitter::EmitComplexBinaryOp(
llvm_ir::EmitComparison(llvm::CmpInst::FCMP_UNE,
EmitExtractImag(lhs_value),
EmitExtractImag(rhs_value), b_));
case ComparisonDirection::kGt:
return Or(llvm_ir::EmitComparison(llvm::CmpInst::FCMP_OGT,
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a comment that we are using lexicographical comparison which is consistent with numpy behavior?

@@ -1292,6 +1292,16 @@ StatusOr<llvm::Value*> ElementalIrEmitter::EmitComplexBinaryOp(
llvm_ir::EmitComparison(llvm::CmpInst::FCMP_UNE,
EmitExtractImag(lhs_value),
EmitExtractImag(rhs_value), b_));
case ComparisonDirection::kGt:
Copy link
Member

Choose a reason for hiding this comment

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

What happens to other cases? kLt? Less-or-equal? You could also support this by implementing a normalization pass in algebraic_simplifier

PR Queue automation moved this from Assigned Reviewer to Reviewer Requested Changes May 29, 2020
@tensorflowbutler tensorflowbutler removed the stat:awaiting response Status - Awaiting response from author label May 31, 2020
@gbaned
Copy link
Contributor

gbaned commented Jun 2, 2020

@joschkabraun Can you please check @cheshire's comments and keep us posted. Thanks!

@gbaned gbaned added the stat:awaiting response Status - Awaiting response from author label Jun 2, 2020
@tensorflowbutler tensorflowbutler added the stale This label marks the issue/pr stale - to be closed automatically if no activity label Jun 24, 2020
@tensorflowbutler
Copy link
Member

It has been 20 days with no activity and the awaiting response label was assigned. Is this PR still valid? Assigning the stalled label. Please comment to reassure me that this is still being worked on.

@gbaned
Copy link
Contributor

gbaned commented Jul 3, 2020

@joschkabraun, Any update on this PR? Please. Thanks!

@joschkabraun
Copy link
Author

Unfortunately, I am currently very busy and seems advisable if someone else could take this over. I am sorry for answering so late!

@google-ml-butler google-ml-butler bot removed the stale This label marks the issue/pr stale - to be closed automatically if no activity label Jul 4, 2020
@tensorflowbutler tensorflowbutler removed the stat:awaiting response Status - Awaiting response from author label Jul 6, 2020
@gbaned
Copy link
Contributor

gbaned commented Jul 12, 2020

@joschkabraun Thanks for the confirmation. Closing the PR.

@gbaned gbaned closed this Jul 12, 2020
PR Queue automation moved this from Reviewer Requested Changes to Closed/Rejected Jul 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes comp:xla XLA size:S CL Change Size: Small
Projects
PR Queue
  
Closed/Rejected
Development

Successfully merging this pull request may close these issues.

None yet

5 participants