-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
**Context:** The so-called offending commit was not the actual cause of CPL rc/rc/rc not passing. It was a problem with the Enzyme cache **Description of the Change:** Revert the commit that reverts the commit **Benefits:** The bug fixed by this commit will be fixed. **Possible Drawbacks:** Not so clean commit history
- Loading branch information
1 parent
2007d9d
commit 0b8213d
Showing
3 changed files
with
65 additions
and
2 deletions.
There are no files selected for viewing
This file contains 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 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 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,60 @@ | ||
# Copyright 2024 Xanadu Quantum Technologies Inc. | ||
|
||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
|
||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
# RUN: %PYTHON %s | FileCheck %s | ||
|
||
import pennylane as qml | ||
from catalyst import pure_callback | ||
|
||
|
||
def i(x): | ||
return x | ||
|
||
|
||
# CHECK-LABEL: module @one_callback_cached | ||
@qml.qjit | ||
# CHECK-NOT: catalyst.callback @callback | ||
# CHECK-LABEL: func.func public @jit_one_callback_cached | ||
def one_callback_cached(x: float): | ||
"""Single callback is created, but called twice""" | ||
c = pure_callback(i, float) | ||
return c(x), c(x) | ||
|
||
|
||
# CHECK-LABEL: catalyst.callback @callback | ||
# CHECK-NOT: catalyst.callback @callback | ||
print(one_callback_cached.mlir) | ||
|
||
|
||
@pure_callback | ||
def always_return_float(x) -> float: | ||
if x == 0.0: | ||
return x | ||
else: | ||
return x + 0.0 | ||
|
||
|
||
# CHECK-LABEL: module @test2 | ||
@qml.qjit | ||
# CHECK-NOT: catalyst.callback @callback | ||
# CHECK-LABEL: func.func public @jit_test2 | ||
def test2(): | ||
return always_return_float(0.0), always_return_float(1) | ||
|
||
|
||
# CHECK-LABEL: catalyst.callback @callback | ||
# CHECK-LABEL: catalyst.callback @callback | ||
# CHECK-NOT: catalyst.callback @callback | ||
|
||
print(test2.mlir) |