Skip to content
New issue

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

Change names of some methods in resource estimation #6973

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions pennylane/labs/resource_estimation/ops/identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,27 @@ class ResourceIdentity(qml.Identity, re.ResourceOperator):
def _resource_decomp(*args, **kwargs) -> Dict[re.CompressedResourceOp, int]:
return {}

@property
def resource_params(self) -> dict:
return {}

@classmethod
def resource_rep(cls, **kwargs) -> re.CompressedResourceOp:
def make_resource_rep(cls, **kwargs) -> re.CompressedResourceOp:
return re.CompressedResourceOp(cls, {})

@classmethod
def adjoint_resource_decomp(cls) -> Dict[re.CompressedResourceOp, int]:
return {cls.resource_rep(): 1}
return {cls.make_resource_rep(): 1}

@classmethod
def controlled_resource_decomp(
cls, num_ctrl_wires, num_ctrl_values, num_work_wires
) -> Dict[re.CompressedResourceOp, int]:
return {cls.resource_rep(): 1}
return {cls.make_resource_rep(): 1}

@classmethod
def pow_resource_decomp(cls, z) -> Dict[re.CompressedResourceOp, int]:
return {cls.resource_rep(): 1}
return {cls.make_resource_rep(): 1}


class ResourceGlobalPhase(qml.GlobalPhase, re.ResourceOperator):
Expand All @@ -56,17 +57,18 @@ class ResourceGlobalPhase(qml.GlobalPhase, re.ResourceOperator):
def _resource_decomp(*args, **kwargs) -> Dict[re.CompressedResourceOp, int]:
return {}

@property
def resource_params(self) -> dict:
return {}

@classmethod
def resource_rep(cls, **kwargs) -> re.CompressedResourceOp:
def make_resource_rep(cls, **kwargs) -> re.CompressedResourceOp:
return re.CompressedResourceOp(cls, {})

@staticmethod
def adjoint_resource_decomp() -> Dict[re.CompressedResourceOp, int]:
"""The adjoint of a global phase is itself another global phase"""
return {re.ResourceGlobalPhase.resource_rep(): 1}
return {re.ResourceGlobalPhase.make_resource_rep(): 1}

@staticmethod
def controlled_resource_decomp(
Expand All @@ -82,15 +84,15 @@ def controlled_resource_decomp(
case, we sandwich the phase shift operation with two multi-controlled X gates.
"""
if num_ctrl_wires == 1:
gate_types = {re.ResourcePhaseShift.resource_rep(): 1}
gate_types = {re.ResourcePhaseShift.make_resource_rep(): 1}

if num_ctrl_values:
gate_types[re.ResourceX.resource_rep()] = 2
gate_types[re.ResourceX.make_resource_rep()] = 2

return gate_types

ps = re.ResourcePhaseShift.resource_rep()
mcx = re.ResourceMultiControlledX.resource_rep(
ps = re.ResourcePhaseShift.make_resource_rep()
mcx = re.ResourceMultiControlledX.make_resource_rep(
num_ctrl_wires=num_ctrl_wires,
num_ctrl_values=num_ctrl_values,
num_work_wires=num_work_wires,
Expand All @@ -101,4 +103,4 @@ def controlled_resource_decomp(
@staticmethod
def pow_resource_decomp(z) -> Dict[re.CompressedResourceOp, int]:
"""Taking arbitrary powers of a global phase produces another global phase"""
return {re.ResourceGlobalPhase.resource_rep(): 1}
return {re.ResourceGlobalPhase.make_resource_rep(): 1}
Loading