提交 35b848ab authored 作者: james@X40's avatar james@X40

moved KitComponent to rmodule

上级 77b0b3ef
...@@ -998,32 +998,6 @@ FancyModule = Module ...@@ -998,32 +998,6 @@ FancyModule = Module
FancyModuleInstance = ModuleInstance FancyModuleInstance = ModuleInstance
class KitComponent(Component):
"""
Represents a SymbolicInputKit (see io.py).
"""
def __init__(self, kit):
super(KitComponent, self).__init__()
self.kit = kit
def allocate(self, memo):
"""
Allocates a Container for each input in the kit. Sets a key in
the memo that maps the SymbolicInputKit to the list of
Containers.
"""
for input in self.kit.sinputs:
r = input.result
if r not in memo:
input = copy(input)
input.value = gof.Container(r, storage = [None])
memo[r] = input
def build(self, mode, memo):
return [memo[i.result].value for i in self.kit.sinputs]
def func_to_mod(f): def func_to_mod(f):
""" """
Creates a dummy module, with external member variables for the input Creates a dummy module, with external member variables for the input
......
...@@ -8,11 +8,37 @@ from collections import deque ...@@ -8,11 +8,37 @@ from collections import deque
import numpy import numpy
from ...compile import (SymbolicInputKit, SymbolicInput, from ...compile import (SymbolicInputKit, SymbolicInput,
Module, KitComponent, module, Method, Member, In, Component) Module, module, Method, Member, In, Component)
from ...gof import Container from ...gof import Container
from ...tensor import raw_random from ...tensor import raw_random
class KitComponent(Component):
"""
Represents a SymbolicInputKit (see io.py).
"""
def __init__(self, kit):
super(KitComponent, self).__init__()
self.kit = kit
def allocate(self, memo):
"""
Allocates a Container for each input in the kit. Sets a key in
the memo that maps the SymbolicInputKit to the list of
Containers.
"""
for input in self.kit.sinputs:
r = input.result
if r not in memo:
input = copy(input)
input.value = gof.Container(r, storage = [None])
memo[r] = input
def build(self, mode, memo):
return [memo[i.result].value for i in self.kit.sinputs]
class RandomKit(SymbolicInputKit): class RandomKit(SymbolicInputKit):
def __init__(self, name, value = None): def __init__(self, name, value = None):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论