Repository navigation
OpenFHE emitter: support rank-0 tensor.from_elements - #3631
Draft
gauthamajoy wants to merge 1 commit into
Draft
gauthamajoy wants to merge 1 commit into
gauthamajoy wants to merge 1 commit into
Conversation
The printer rejected any non-rank-1 result with a bare failure(), so 0-d results (e.g. from generated decrypt helpers) failed with a generic "Failed to translate" error. Allow rank 0 (emitted as a size-1 vector, matching extract/insert), and emit a diagnostic for rank >= 2. Fixes google#3624
Author
|
Closed by accident, reopening the PR. |
Author
|
FYI: the cla/google check passing here isn't correct on our end. I'm getting it sorted and will mark this ready for review once it's resolved. |
j2kun
approved these changes
Nov 11, 2026
Comment on lines
+1695
to
+1696
| // Only rank-0 and rank-1 tensor construction is currently supported. | ||
| // TODO(#1703): Support higher-rank tensors. |
Collaborator
There was a problem hiding this comment.
Technically true, but I don't think we will see many natural workflows that produce a from_elements that produces a rank-2+ tensor.
Author
There was a problem hiding this comment.
Agreed, it’s unlikely to come up. The error is mainly so it fails clearly rather than emitting invalid code. Happy to drop the TODO (and #1703) if you’d rather not track it.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The printer rejected any non-rank-1 result with a bare failure(), so 0-d
results (e.g. from generated decrypt helpers) failed with a generic "Failed
to translate" error. Allow rank 0 (emitted as a size-1 vector, matching
extract/insert), and emit a diagnostic for rank >= 2.
Fixes #3624
Testing
from_elementscase toemit_0d_tensor.mlir, and a newemit_2d_tensor_error.mlirchecking the diagnostic for rank >= 2.bazel test //tests/Emitter/...:all) passed withthe fix before I added the negative test. Tested on nightly-2026.11.06,
then rebased onto current main without re-running.
Question
Since the emitter flattens all tensors to
std::vector, should rank >= 2from_elementsjust be allowed too (row-major elements match theflattening)? I kept it rejected pending #1703, but happy to change it.
I'll join the next office hours.
I used AI to help edit and elaborate this PR description.