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

feat: Add tket2 feature and lowerings for tket2.rotation extension #100

Merged
merged 16 commits into from
Sep 16, 2024

Conversation

doug-q
Copy link
Collaborator

@doug-q doug-q commented Sep 11, 2024

No description provided.

@doug-q doug-q changed the title Doug/init angle feat: Add tket2 feature and lowerings for angle extension Sep 11, 2024
@codecov-commenter
Copy link

codecov-commenter commented Sep 11, 2024

Codecov Report

Attention: Patch coverage is 84.61538% with 40 lines in your changes missing coverage. Please review.

Project coverage is 83.54%. Comparing base (99ad943) to head (bcdf0ba).

Files with missing lines Patch % Lines
src/custom/rotation.rs 84.05% 18 Missing and 19 partials ⚠️
src/emit/test.rs 80.00% 0 Missing and 2 partials ⚠️
src/emit.rs 92.30% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #100      +/-   ##
==========================================
+ Coverage   83.31%   83.54%   +0.22%     
==========================================
  Files          25       26       +1     
  Lines        3758     4016     +258     
  Branches     3758     4016     +258     
==========================================
+ Hits         3131     3355     +224     
- Misses        331      343      +12     
- Partials      296      318      +22     
Flag Coverage Δ
rust 83.54% <84.61%> (+0.22%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@doug-q doug-q linked an issue Sep 12, 2024 that may be closed by this pull request
@doug-q doug-q marked this pull request as ready for review September 12, 2024 09:40
@doug-q doug-q requested a review from a team as a code owner September 12, 2024 09:40
src/emit.rs Outdated Show resolved Hide resolved
src/emit/test.rs Outdated Show resolved Hide resolved

/// A codegen extension for the `tket2.angle` extension.
///
/// We lower [ANGLE_CUSTOM_TYPE] to the same [IntType] to which [USIZE_T] is
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason not to settle on 64-bit integers rather than USIZE_T, so as to be platform-independent?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The ops are defined to take USIZE_T arguments, so they are not platform independent.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

On reflection the choices are:

  • always use USIZE_T: all ops are platform dependent
  • use either i64 or a configurable int type: only anew is platform dependent

will change

src/custom/angle.rs Outdated Show resolved Hide resolved
src/custom/angle.rs Outdated Show resolved Hide resolved
src/custom/angle.rs Outdated Show resolved Hide resolved
src/custom/angle.rs Outdated Show resolved Hide resolved
src/custom/angle.rs Outdated Show resolved Hide resolved
src/custom/angle.rs Outdated Show resolved Hide resolved
src/custom/angle.rs Outdated Show resolved Hide resolved
@qartik
Copy link
Member

qartik commented Sep 13, 2024

Hi @doug-q could you resolve the conflict in src/custom.rs?

@doug-q doug-q changed the title feat: Add tket2 feature and lowerings for angle extension feat: Add tket2 feature and lowerings for tket2.rotation extension Sep 16, 2024
Comment on lines 98 to 99
// As we always normalise angles to have a log_denom of
// angle_width, we do not need the log_denom.
Copy link
Contributor

Choose a reason for hiding this comment

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

Obsolete comment.

Comment on lines +140 to +153
// let rads_ok = {
// let i32_ty = self.0.iw_context().i32_type();
// let builder = self.0.builder();
// let is_fpclass = get_intrinsic(module, "llvm.is.fpclass", [float_ty.as_basic_type_enum(), i32_ty.as_basic_type_enum()])?;
// // Here we pick out the following floats:
// // - bit 0: Signalling Nan
// // - bit 3: Negative normal
// // - bit 8: Positive normal
// let test = i32_ty.const_int((1 << 0) | (1 << 3) | (1 << 8), false);
// builder
// .build_call(is_fpclass, &[rads.into(), test.into()], "")?
// .try_as_basic_value()
// .left()
// .ok_or(anyhow!("llvm.is.fpclass has no return value"))?
// .into_int_value()
// };
Copy link
Contributor

Choose a reason for hiding this comment

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

Delete commented code?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This one is referenced in the comment above. this is the llvm-15 version of the code for later.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see.

src/custom/rotation.rs Outdated Show resolved Hide resolved
doug-q and others added 16 commits September 16, 2024 15:48
Co-authored-by: Alec Edgington <54802828+cqc-alec@users.noreply.github.com>
Co-authored-by: Alec Edgington <54802828+cqc-alec@users.noreply.github.com>
Co-authored-by: Alec Edgington <54802828+cqc-alec@users.noreply.github.com>
Co-authored-by: Alec Edgington <54802828+cqc-alec@users.noreply.github.com>
Co-authored-by: Alec Edgington <54802828+cqc-alec@users.noreply.github.com>
@doug-q doug-q added this pull request to the merge queue Sep 16, 2024
Merged via the queue into main with commit bcbd311 Sep 16, 2024
10 checks passed
@doug-q doug-q deleted the doug/init-angle branch September 16, 2024 14:52
@hugrbot hugrbot mentioned this pull request Sep 16, 2024
github-merge-queue bot pushed a commit that referenced this pull request Sep 16, 2024
## 🤖 New release
* `hugr-llvm`: 0.4.0 -> 0.5.0

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

## [0.5.0](v0.4.0...v0.5.0) -
2024-09-16

### New Features

- Add emitters for int <-> float/usize conversions
([#94](#94))
- [**breaking**] array ops
([#96](#96))
- Add conversions itobool, ifrombool
([#101](#101))
- Add `tket2` feature and lowerings for `tket2.rotation` extension
([#100](#100))

### Testing

- Add execution test framework
([#97](#97))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/MarcoIeni/release-plz/).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Emit float ops for tket2 angle operations
4 participants