Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@memoize_method
def _maker(self, with_defaults=False):
def format_arg(f):
if with_defaults:
return "%s=%s" % (f.name, repr(f.default_value()))
else:
return f.name
code = "lambda pack, %s: pack(%s, %s)" % (
", ".join(format_arg(f) for f in self.fields),
repr(self.struct_format()),
", ".join(f.struct_maker_code(f.name) for f in self.fields))
return eval(code)
@memoize_method
def all_insn_inames(self):
"""Return a mapping from instruction ids to inames inside which
they should be run.
"""
return find_all_insn_inames(self)
@memoize_method
def subkernel_to_surrounding_inames(self):
current_outer_inames = set()
within_subkernel = False
result = {}
for sched_item_idx, sched_item in enumerate(self.kernel.schedule):
if isinstance(sched_item, CallKernel):
within_subkernel = True
result[sched_item.kernel_name] = frozenset(current_outer_inames)
elif isinstance(sched_item, ReturnFromKernel):
within_subkernel = False
elif isinstance(sched_item, EnterLoop):
if not within_subkernel:
current_outer_inames.add(sched_item.iname)
elif isinstance(sched_item, LeaveLoop):
current_outer_inames.discard(sched_item.iname)
@memoize_method
def gmsh_node_tuples(self):
result = []
for tup in generate_triangle_vertex_tuples(self.order):
result.append(tup)
for tup in generate_triangle_edge_tuples(self.order):
result.append(tup)
return result
@memoize_method
def __str__(self):
return BINARY_SEARCH_TEMPLATE.render(**self.render_vars)
@memoize_method
def read_dependency_names(self):
from loopy.symbolic import get_dependencies
result = (
super(MultiAssignmentBase, self).read_dependency_names()
| get_dependencies(self.expression))
for subscript_deps in self.assignee_subscript_deps():
result = result | subscript_deps
return result
@memoize_method
def process_list2_knl(self, box_id_dtype, box_level_dtype):
return ElementwiseKernel(
self.queue.context,
Template(r"""
double *nm2l,
${box_id_t} *target_or_target_parent_boxes,
${box_id_t} *from_sep_siblings_starts,
${box_level_t} *box_levels,
double *m2l_cost
""").render(
box_id_t=dtype_to_ctype(box_id_dtype),
box_level_t=dtype_to_ctype(box_level_dtype)
),
Template(r"""
${box_id_t} start = from_sep_siblings_starts[i];
${box_id_t} end = from_sep_siblings_starts[i+1];
@memoize_method
def get_quadrature_info(self, exact_to_degree):
return self.QuadratureInfo(self, exact_to_degree)
@memoize_method
def local_var_names(self):
from loopy.kernel.data import AddressSpace
return set(
tv.name
for tv in six.itervalues(self.temporary_variables)
if tv.address_space == AddressSpace.LOCAL)
@memoize_method
def tokenize(self, text):
toks = self.tokenizer.tokenize(text)
toks = [self.tokenizer.vocab[t] for t in toks]
return toks