mindquantum.algorithm.compiler.BasicCompilerRule

View Source On Gitee
class mindquantum.algorithm.compiler.BasicCompilerRule(rule_name='BasicCompilerRule', log_level=0)[source]

The basic compiler rule class.

Compiler rule will handle a DAGCircuit and compile it following the rule in the do method. You must implement the do method when inheritance a child compiler rule. Please make sure that the do method will return a bool, which will tell whether the compiler successful compiled the circuit.

Parameters
  • rule_name (str) – The name of this compiler rule.

  • log_level (int) – The display log level. If 0, log will be disabled. If 1, a brief log will be displayed. If 2, a detail log will be displayed. Default: 0.

abstract do(dag_circuit: DAGCircuit)[source]

Inplace applying this compiler rule to the DAGCircuit.

Parameters

dag_circuit (DAGCircuit) – The DAG graph of quantum circuit.

set_log_level(log_level: int)[source]

Set display log level.

Parameters

log_level (int) – the display log level. Could be 0, 1 or 2. For more explanation of log level, please refers to BasicCompilerRule.