Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
feifei-111 committed Sep 25, 2023
1 parent c59fe21 commit 84ae86e
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions sot/opcode_translator/executor/variables/callable.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,12 @@ def __init__(
):
super().__init__(layer, graph, tracker)

def __len__(self):
return len(self.value)

def len(self):
return ConstantVariable(len(self), self.graph, DummyTracker([self]))

def call_function(self, /, *args, **kwargs):
fn_var = UserDefinedFunctionVariable(
self.value.__class__.__call__,
Expand Down Expand Up @@ -540,6 +546,10 @@ def call_function(self, /, *args, **kwargs):
)
return var

@property
def main_info(self) -> dict[str, Any]:
return {"name": self.value.__name__}

@VariableFactory.register_from_value(
successor="UserDefinedFunctionVariable"
)
Expand All @@ -548,10 +558,6 @@ def from_value(value: Any, graph: FunctionGraph, tracker: Tracker):
return UserDefinedGeneratorVariable(value, graph, tracker)
return None

@property
def main_info(self) -> dict[str, Any]:
return {"name": self.value.__name__}


class PaddleLayerVariable(LayerVariable):
"""
Expand All @@ -571,12 +577,6 @@ def __init__(
super().__init__(layer, graph, tracker)
self.name = self.layer_name_generator.next()

def __len__(self):
return len(self.value)

def len(self):
return ConstantVariable(len(self), self.graph, DummyTracker([self]))

def get_symbol(self) -> Symbol:
return Symbol(self.name)

Expand Down

0 comments on commit 84ae86e

Please sign in to comment.