Giter VIP home page Giter VIP logo

qcpm's Introduction

qcpm

输入格式:

  • circuit data: (.qasm)

    example.qasm:

    OPENQASM 2.0;
    include "qelib1.inc";
    qreg q[16];
    creg c[16];
    cx q[4],q[1];
    t q[4];
    t q[2];
    q[0];
    ...
    
  • pattern data: (.json)

    pattern.json:

    [
        {
            "src": [
                ["cx", [0, 1]],
                ["cx", [1, 2]],
                ["cx", [0, 1]]
            ],
            "dst": [
                ["cx", [0, 2]],
                ["cx", [1, 2]]
            ]
        },
        ...
    ]

运行

Mapper 从 json 文件表示的映射关系中构建映射模式,用于内部的映射处理 Circuit 从 qasm 中构建电路

mapper.execute(circuit): 在线路 circuit 上应用映射 mapper

from qcpm.pattern.mapper import Mapper
from qcpm.circuit.circuit import Circuit

mapper = Mapper(pattern_path) # ./.json
circuit = Circuit(circuit_path) # ./.qasm

mapper.execute(circuit)

输出

测试结果的输出见 log.txt

包括:

根据输入构建的映射模式:

Pattern  1
cx [0, 1]
cx [1, 2]
cx [0, 1]
 => 
cx [0, 2]
cx [1, 2]
...

线路根据对应模式查找的可替换的候选项:

Pattern:  1

pos:  73 # 匹配处的第一个门操作在序列中的位置
# 以下是匹配到的对应的门操作序列
No: 73, cx [4, 1]
No: 74, cx [1, 2]
No: 75, cx [4, 1]
...
# 所有候选项的匹配位置
Candidate: 
 [73, 75]

qcpm's People

Contributors

shepherdlee519 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.