This repository was archived by the owner on Jan 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 173
Classically Controlled to Master #310
Merged
Merged
Changes from all commits
Commits
Show all changes
66 commits
Select commit
Hold shift + click to select a range
27be592
Added Andres's basic implementation of the Classically Controlled tra…
ScottCarda-MS 110aada
Merge branch 'master' into sccarda/ClassicallyControlled
ScottCarda-MS 3dc34f6
Added rewrite step
ScottCarda-MS 97a730b
Filled in type information for injected control flow operation calls.
ScottCarda-MS 374172c
Added logic to hoist sub-scopes into generated operators. Logic is cu…
ScottCarda-MS 5107fe3
Changed 'operator' to 'operation'
ScottCarda-MS 2c5f1cd
Nested if's will be processed.
ScottCarda-MS 16d6931
Convert elif to nested if structure to allow for processing.
ScottCarda-MS 53f9f8b
Added logic to generated parameters/arguments for the generated opera…
ScottCarda-MS 43182e4
Added super-scope's type params to the signiture of the generated ope…
ScottCarda-MS e0264df
Forwarding type parameters into the generated operations.
ScottCarda-MS 5ca3ad7
Merged in from master
ScottCarda-MS 3bf4f6c
Updated transformation with nullable locations
ScottCarda-MS 6e4b139
Expanded on the type param reroute transformation so that it operates…
ScottCarda-MS 45f3060
Reorganized the reroute transform to be a self-contained transform su…
ScottCarda-MS 863df6d
WIP
ScottCarda-MS a814d8c
WIP, all that's left is condition expression encapsulation and condit…
ScottCarda-MS ed4a5da
WIP, not going to do expression encapsulation anymore. Still need to …
ScottCarda-MS 33b00e7
WIP, mostly finished with implementation. Need to do some cleaning up.
ScottCarda-MS e2c8d6e
Cleaned up code. Everything seems to be working.
ScottCarda-MS 31ef6f9
Partially fixed a bug with generic references being separated from th…
ScottCarda-MS ce0d72f
Fixed minor bug with the logic that handles mutables.
ScottCarda-MS 274a0cd
Got most of the implementation for functor support in generated contr…
ScottCarda-MS 603cce3
Getting close, still need to use the appropriate ApplyIf for the call.
ScottCarda-MS 6dcbd6a
The generated operations now correctly have functor support, and the …
ScottCarda-MS 7b59dcc
Cleanup
ScottCarda-MS 739ceb1
Fixed some line endings
ScottCarda-MS 8dc3ba9
Basic test
ScottCarda-MS 57d22b9
Added test to check if-else and if-elif-else structures.
ScottCarda-MS 5dc5d89
Set up some logic to tests what calls are being made in callables.
ScottCarda-MS 0c831ca
just more progress
ScottCarda-MS 483db3f
Trying to make test for Elif structure. Not quite there yet.
ScottCarda-MS 53a9db1
Pulled out some common logic.
ScottCarda-MS 2b41f24
And and Or conditions tests
ScottCarda-MS f155c86
Finished off 'Hoisting' tests. Still need tests for mutable support, …
ScottCarda-MS 30afb16
Added tests to cover mutable variables and support for generics.
ScottCarda-MS 2d67001
Test for Adjoint functor support.
ScottCarda-MS 4153762
Tested functor support for generated operations. Moved Classical Cont…
ScottCarda-MS e8e84cb
Cleaned up the names and categories. Skipped tests that are failing, …
ScottCarda-MS c3fd9c5
Updated Rewrite step class for transformation.
ScottCarda-MS 7df6941
Merge pull request #282 from microsoft/sccarda/ConditionalAnd
ScottCarda-MS 2977df0
Merge branch 'features/ClassicallyControlled' into sccarda/Classicall…
ScottCarda-MS 087644f
getting updates from master
b8df44a
enabling ConvertClassicalControl if the execution target is a quantum…
fd3f1de
Fixed line endings
ScottCarda-MS 7ae62c6
Fixed line endings
ScottCarda-MS 57a6420
PR comments
ScottCarda-MS 7900e2e
PR comments
ScottCarda-MS b4f4665
Merge pull request #287 from microsoft/sccarda/ClassicallyControlledU…
ScottCarda-MS 6304aab
Merge branch 'features/ClassicallyControlled' into beheim/branching
bettinaheim e0bc6d9
helper function for ensuring that IRewriteSteps are executed atomic
c8b1bcc
Merge branch 'beheim/branching' of https://github.com/microsoft/qshar…
78d6d1b
getting updates from master
d9c5e97
Fix Unit Test Failures for Classical Control (#289)
ScottCarda-MS 112faf6
Merge branch 'master' into beheim/branching
be3d813
Merge branch 'features/ClassicallyControlled' into beheim/branching
487fe37
fixing build failure due to option change
b522f7a
reenabling execution tests
6599f61
forgot to actually update the packages
433b9e4
Merge pull request #290 from microsoft/beheim/branching
ScottCarda-MS 0762467
Removed completed ToDo's (#309)
ScottCarda-MS 6b65781
Added precondition to the rewrite step.
ScottCarda-MS 16ad138
Removed extra onStatement call.
ScottCarda-MS e6c1a1a
Addressed PR comments
ScottCarda-MS 173c6ba
Merge branch 'sccarda/ClassicallyControlledToMaster' of https://githu…
ScottCarda-MS 93cfc4e
Update src/QsCompiler/Compiler/CompilationLoader.cs
bettinaheim File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
72 changes: 72 additions & 0 deletions
72
src/QsCompiler/Compiler/RewriteSteps/ClassicallyControlled.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| using System.Collections.Generic; | ||
| using System.Linq; | ||
| using Microsoft.Quantum.QsCompiler.DataTypes; | ||
| using Microsoft.Quantum.QsCompiler.SyntaxTree; | ||
| using Microsoft.Quantum.QsCompiler.Transformations.ClassicallyControlledTransformation; | ||
|
|
||
|
|
||
| namespace Microsoft.Quantum.QsCompiler.BuiltInRewriteSteps | ||
| { | ||
| internal class ClassicallyControlled : IRewriteStep | ||
| { | ||
| public string Name => "ClassicallyControlled"; | ||
| public int Priority => 10; // Not used for built-in transformations like this | ||
| public IDictionary<string, string> AssemblyConstants { get; } | ||
| public IEnumerable<IRewriteStep.Diagnostic> GeneratedDiagnostics => null; | ||
|
|
||
| public bool ImplementsTransformation => true; | ||
| public bool ImplementsPreconditionVerification => true; | ||
| public bool ImplementsPostconditionVerification => false; | ||
|
|
||
| public ClassicallyControlled() | ||
| { | ||
| AssemblyConstants = new Dictionary<string, string>(); | ||
| } | ||
|
|
||
| public bool Transformation(QsCompilation compilation, out QsCompilation transformed) | ||
| { | ||
| transformed = ClassicallyControlledTransformation.Apply(compilation); | ||
| return true; | ||
| } | ||
|
|
||
| public bool PreconditionVerification(QsCompilation compilation) | ||
| { | ||
| var controlNs = compilation.Namespaces | ||
| .FirstOrDefault(ns => ns.Name.Equals(BuiltIn.ClassicallyControlledNamespace)); | ||
|
|
||
| if (controlNs == null) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| var providedOperations = new QsNamespace[] { controlNs }.Callables().Select(c => c.FullName.Name); | ||
| var requiredBuiltIns = new List<NonNullable<string>>() | ||
| { | ||
| BuiltIn.ApplyIfZero.Name, | ||
| BuiltIn.ApplyIfZeroA.Name, | ||
| BuiltIn.ApplyIfZeroC.Name, | ||
| BuiltIn.ApplyIfZeroCA.Name, | ||
|
|
||
| BuiltIn.ApplyIfOne.Name, | ||
| BuiltIn.ApplyIfOneA.Name, | ||
| BuiltIn.ApplyIfOneC.Name, | ||
| BuiltIn.ApplyIfOneCA.Name, | ||
|
|
||
| BuiltIn.ApplyIfElseR.Name, | ||
| BuiltIn.ApplyIfElseRA.Name, | ||
| BuiltIn.ApplyIfElseRC.Name, | ||
| BuiltIn.ApplyIfElseRCA.Name | ||
| }; | ||
|
|
||
| return requiredBuiltIns.All(builtIn => providedOperations.Any(provided => provided.Equals(builtIn))); | ||
| } | ||
|
|
||
| public bool PostconditionVerification(QsCompilation compilation) | ||
| { | ||
| throw new System.NotImplementedException(); | ||
| } | ||
| } | ||
| } | ||
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
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
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.