QPanda3  0.1.0
Supported by OriginQ
Loading...
Searching...
No Matches
pyqpanda3.profiling.Wrapper.Wrapper Class Reference
Inheritance diagram for pyqpanda3.profiling.Wrapper.Wrapper:

Public Member Functions

 __init__ (self, routine)
 Initialise the wrapper with the given routine.
 
ty.Iterable["Wrapper"] __iter__ (self)
 Magic Python method to make the RoutineWrapper object iterable.
 
 ops (self)
 
bool is_base (self)
 Check if the wrapped routine is a "base" routine.
 
str name (self)
 Returns the name of the wrapped subroutine.
 
int __hash__ (self)
 Computes the hash of the wrapped routine.
 
bool __eq__ (self, "Wrapper" other)
 Equality testing for wrapped routines.
 

Constructor & Destructor Documentation

◆ __init__()

pyqpanda3.profiling.Wrapper.Wrapper.__init__ ( self,
routine )

Initialise the wrapper with the given routine.

:param routine: a framework-specific routine that will be wrapped.

Reimplemented in pyqpanda3.profiling.Wrapper.QPandaWrapper.

Member Function Documentation

◆ __eq__()

bool pyqpanda3.profiling.Wrapper.Wrapper.__eq__ ( self,
"Wrapper" other )

Equality testing for wrapped routines.

hash and eq methods are used by qprof to cache routines and re-use already computed data. This optimisation gives impressive results on some circuits and is expected to improve the runtime of qprof on nearly all quantum circuits, because routines are most of the time re-used.

Two routines should be considered equal if and only if they generate exactly the same circuit.

Comparing the generated circuits might be a costly task, but other methods can be used. For example, routines with the same name and the same parameters might be considered as equal (may be framework-dependent).

:param other: instance of RoutineWrapper to test for equality with self. :return: True if self and other are equal (i.e. generate the exact same quantum circuit) else False.

Reimplemented in pyqpanda3.profiling.Wrapper.QPandaWrapper.

◆ __hash__()

int pyqpanda3.profiling.Wrapper.Wrapper.__hash__ ( self)

Computes the hash of the wrapped routine.

hash and eq methods are used by qprof to cache routines and re-use already computed data. This optimisation gives impressive results on some circuits and is expected to improve the runtime of qprof on nearly all quantum circuits, because routines are most of the time re-used.

:return: int representing a hash of the wrapper routine.

Reimplemented in pyqpanda3.profiling.Wrapper.QPandaWrapper.

◆ __iter__()

ty.Iterable["Wrapper"] pyqpanda3.profiling.Wrapper.Wrapper.__iter__ ( self)

Magic Python method to make the RoutineWrapper object iterable.

:return: an iterable over all the subroutines called by the wrapped routine. The subroutines should be wrapped by the RoutineWrapper.

Reimplemented in pyqpanda3.profiling.Wrapper.QPandaWrapper.

◆ is_base()

bool pyqpanda3.profiling.Wrapper.Wrapper.is_base ( self)

Check if the wrapped routine is a "base" routine.

Base routines are routines that are considered as primitive, i.e. that do not call any subroutine. The concept of base routine is essential for qprof as only base routines should have an entry in the "gate_times" dictionary provided to the "profile" method and base routines are used to stop the recursion into the call-tree.

:return: True if the wrapped routine is considered as a "base" routine, else False.

Reimplemented in pyqpanda3.profiling.Wrapper.QPandaWrapper.

◆ name()

str pyqpanda3.profiling.Wrapper.Wrapper.name ( self)

Returns the name of the wrapped subroutine.

Reimplemented in pyqpanda3.profiling.Wrapper.QPandaWrapper.

◆ ops()

pyqpanda3.profiling.Wrapper.Wrapper.ops ( self)

The documentation for this class was generated from the following file: