We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
MWE, need https://github.com/QuantumBFS/YaoTargetQASM.jl for the syntax, on 1.6.1
using OpenQASM using YaoTargetQASM using YaoCompiler using YaoCompiler.Intrinsics using CompilerPluginTools qasm""" OPENQASM 2.0; gate cx c,t { CX c,t; } gate u1(lambda) q { U(0,0,lambda) q; } gate t a { u1(pi/4) a; } gate h a { u2(0,pi) a; } gate tdg a { u1(-pi/4) a; } gate ccx a,b,c { h c; cx b,c; tdg c; cx a,c; t c; cx b,c; tdg c; cx a,c; t b; t c; h c; cx a,b; t a; tdg b; cx a,b; } gate majority a,b,c { cx c,b; cx c,a; ccx a,b,c; } """ ast = code_qasm(typeof(majority()))
This gives you the following
julia> ast = code_qasm(typeof(majority())) OPENQASM 2.0; qreg qreg_1[3]; CX qreg_1[2], qreg_1[1]; CX qreg_1[2], qreg_1[0]; h qreg_1[2]; CX qreg_1[1], qreg_1[2]; tdg qreg_1[2]; CX qreg_1[0], qreg_1[2]; t qreg_1[2]; CX qreg_1[1], qreg_1[2]; tdg qreg_1[2]; CX qreg_1[0], qreg_1[2]; t qreg_1[1]; t qreg_1[2]; h qreg_1[2]; CX qreg_1[0], qreg_1[1]; t qreg_1[0]; tdg qreg_1[1]; CX qreg_1[0], qreg_1[1];
but h and t should be inlined instead of invoke, this seems to only happen when ccx is called inside another function, and for ccx itself it is fine
h
t
invoke
ccx
julia> code_qasm(typeof(ccx())) OPENQASM 2.0; qreg qreg_1[3]; h qreg_1[2]; CX qreg_1[1], qreg_1[2]; rz(0) qreg_1[2]; ry(0) qreg_1[2]; rz(-0.7853981633974483) qreg_1[2]; CX qreg_1[0], qreg_1[2]; rz(0) qreg_1[2]; ry(0) qreg_1[2]; rz(0.7853981633974483) qreg_1[2]; CX qreg_1[1], qreg_1[2]; rz(0) qreg_1[2]; ry(0) qreg_1[2]; rz(-0.7853981633974483) qreg_1[2]; CX qreg_1[0], qreg_1[2]; rz(0) qreg_1[1]; ry(0) qreg_1[1]; rz(0.7853981633974483) qreg_1[1]; rz(0) qreg_1[2]; ry(0) qreg_1[2]; rz(0.7853981633974483) qreg_1[2]; h qreg_1[2]; CX qreg_1[0], qreg_1[1]; rz(0) qreg_1[0]; ry(0) qreg_1[0]; rz(0.7853981633974483) qreg_1[0]; rz(0) qreg_1[1]; ry(0) qreg_1[1]; rz(-0.7853981633974483) qreg_1[1]; CX qreg_1[0], qreg_1[1];
the CodeInfo can be obtained via
CodeInfo
code_typed(Intrinsics.apply, (AnyReg, typeof(majority())); interp=YaoInterpreter())
I think need some help from you @vchuravy
The text was updated successfully, but these errors were encountered:
When apply is called via a non-intrinsic user-defined Operation, it is forced to inline by making inlineable=true in CodeInfo
apply
Operation
inlineable=true
https://github.com/QuantumBFS/YaoCompiler.jl/blob/master/src/compiler/syntax.jl#L248
thus I'm not sure why inlining pass decide not to inline them.
Sorry, something went wrong.
083d49a
No branches or pull requests
MWE, need https://github.com/QuantumBFS/YaoTargetQASM.jl for the syntax, on 1.6.1
This gives you the following
but
h
andt
should be inlined instead ofinvoke
, this seems to only happen whenccx
is called inside another function, and forccx
itself it is finethe
CodeInfo
can be obtained viaI think need some help from you @vchuravy
The text was updated successfully, but these errors were encountered: