-
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.
init: run a empty "hello oqd world!" capi stub
- Loading branch information
Showing
4 changed files
with
103 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
; ModuleID = 'LLVMDialectModule' | ||
source_filename = "LLVMDialectModule" | ||
|
||
@"{'shots': 1000}" = internal constant [16 x i8] c"{'shots': 1000}\00" | ||
@oqd = internal constant [4 x i8] c"oqd\00" | ||
@"/home/paul.wang/catalyst_new/catalyst/frontend/catalyst/utils/../../catalyst/third_party/oqd/src/build/librtd_oqd.so" = internal constant [117 x i8] c"/home/paul.wang/catalyst_new/catalyst/frontend/catalyst/utils/../../catalyst/third_party/oqd/src/build/librtd_oqd.so\00" | ||
|
||
declare void @__catalyst__oqd__greetings() | ||
|
||
declare void @__catalyst__rt__finalize() | ||
|
||
declare void @__catalyst__rt__initialize(ptr) | ||
|
||
declare void @__catalyst__rt__device_release() | ||
|
||
declare void @__catalyst__rt__device_init(ptr, ptr, ptr, i64) | ||
|
||
define void @jit_f() { | ||
call void @f_0() | ||
ret void | ||
} | ||
|
||
define void @_catalyst_pyface_jit_f(ptr %0, ptr %1) { | ||
call void @_catalyst_ciface_jit_f(ptr %0) | ||
ret void | ||
} | ||
|
||
define void @_catalyst_ciface_jit_f(ptr %0) { | ||
call void @jit_f() | ||
ret void | ||
} | ||
|
||
define void @f_0() { | ||
call void @__catalyst__rt__device_init(ptr @"/home/paul.wang/catalyst_new/catalyst/frontend/catalyst/utils/../../catalyst/third_party/oqd/src/build/librtd_oqd.so", ptr @oqd, ptr @"{'shots': 1000}", i64 1000) | ||
call void @__catalyst__oqd__greetings() | ||
call void @__catalyst__rt__device_release() | ||
ret void | ||
} | ||
|
||
define void @setup() { | ||
call void @__catalyst__rt__initialize(ptr null) | ||
ret void | ||
} | ||
|
||
define void @teardown() { | ||
call void @__catalyst__rt__finalize() | ||
ret void | ||
} | ||
|
||
; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite) | ||
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #0 | ||
|
||
attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) } | ||
|
||
!llvm.module.flags = !{!0} | ||
|
||
!0 = !{i32 2, !"Debug Info Version", i32 3} |
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,21 @@ | ||
import pennylane as qml | ||
import pytest | ||
|
||
import catalyst | ||
from catalyst import qjit | ||
from catalyst.third_party.oqd import OQDDevice | ||
from catalyst.debug import get_compilation_stage, replace_ir | ||
|
||
dev = OQDDevice(backend="default", shots=1000, wires=8) | ||
|
||
@qjit#(keep_intermediate=True) | ||
@qml.qnode(dev) | ||
def f(): | ||
qml.Hadamard(wires=0) | ||
return qml.probs() | ||
|
||
with open("6_llvm_ir.ll", "r") as file: | ||
ir = file.read() | ||
replace_ir(f, "llvm_ir", ir) | ||
|
||
f() |
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,24 @@ | ||
// Copyright 2025 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. | ||
|
||
#include <iostream> | ||
|
||
extern "C" { | ||
|
||
void __catalyst__oqd__greetings() { | ||
std::cout << "Hello OQD world!" << std::endl; | ||
} | ||
|
||
|
||
} |