65 def __init__(self, index, type, direction, state, name, data_types=[], do_map=True, do_unmap=True, do_map_unmap_all_planes=False):
68 self.direction = direction
70 self.name_upper = name.upper()
71 self.name_lower = name.lower()
72 self.name_camel = toCamelCase(name)
73 self.data_types = data_types
75 self.do_unmap = do_unmap
76 self.do_map_unmap_all_planes = do_map_unmap_all_planes
77 if Type.is_scalar_type(type) :
79 self.do_unmap =
False;
82 return "Param " + str(self.index) +
": " + self.name_upper +
" " + Type.get_vx_enum_name(self.type) +
" " + Direction.get_vx_enum_name(self.direction) +
" " + ParamState.get_vx_enum_name(self.state)
84 class KernelParamRelationship :
85 def __init__(self, prm_list, attribute_list, type, state):
86 self.attribute_list = attribute_list
87 self.prm_list = prm_list
92 rel_str =
"Param Relationship:\n" 93 for param
in self.prm_list :
94 rel_str +=
'\t' + str(param) +
"\n" 95 for attr
in self.attribute_list :
96 rel_str +=
'\t' + str(attr) +
"\n" 99 class KernelLocalMem :
100 def __init__(self, prm, attribute_list, name, state):
101 self.attribute_list = attribute_list
107 mem_str =
"Local Mem:\n\t" + self.name +
"\n" 108 mem_str +=
'\t' + str(self.prm) +
"\n" 109 mem_str +=
'\t' + str(self.state) +
"\n" 110 for attr
in self.attribute_list :
111 mem_str +=
'\t' + str(attr) +
"\n" 147 def setKernelPrefix(self, name_str_prefix, enum_str_prefix) :
165 kernel_str +=
"Targets: " 167 if type(target)
is Target :
168 kernel_str += Target.get_vx_enum_name(target) +
"(CPU: " + Cpu.get_vx_enum_name(Target.get_cpu(target)) +
") " 170 sys.exit(
"target arguments have invalid type.")
173 kernel_str += str(prm) +
"\n" 192 def setParameter(self, type, direction, state, name, data_types=[], do_map=True, do_unmap=True, do_map_unmap_all_planes=False):
200 assert in_list ==
False,
"'%s' was already used as local memory name" % name
202 params = KernelParams(self.
index, type, direction, state, name, data_types, do_map, do_unmap, do_map_unmap_all_planes);
203 self.
params.append(params)
311 assert in_list ==
False,
"'%s' was already used as local memory name" % local_mem_name
317 if parameter_name.lower() == prm.name_lower :
318 if KernelExportCode.is_supported_type(self, prm.type):
322 assert found ==
True,
"'%s' was not found in image parameter list" % parameter_name
325 localmem = KernelLocalMem(local_prm, attribute_list, local_mem_name, local_prm.state)
327 localmem = KernelLocalMem(local_prm, attribute_list, local_mem_name, ParamState.REQUIRED)
331 def getNumImages(self) :
334 if prm.type == Type.IMAGE :
338 def getNumRequiredImages(self) :
341 if prm.type == Type.IMAGE
and prm.state == ParamState.REQUIRED :
345 def getNumOptionalImages(self) :
348 if prm.type == Type.IMAGE
and prm.state == ParamState.OPTIONAL :
352 def getNumScalars(self) :
355 if Type.is_scalar_type(prm.type)
is True :
359 def getNumInputImages(self) :
362 if prm.type == Type.IMAGE
and prm.direction == Direction.INPUT:
363 num_input_images += 1
364 return num_input_images
366 def getNumRequiredInputImages(self) :
369 if prm.type == Type.IMAGE
and prm.direction == Direction.INPUT
and prm.state == ParamState.REQUIRED :
370 num_input_images += 1
371 return num_input_images
373 def getNumOutputImages(self) :
374 num_output_images = 0
376 if prm.type == Type.IMAGE
and prm.direction == Direction.OUTPUT:
377 num_output_images += 1
378 return num_output_images
380 def getNumRequiredOutputImages(self) :
381 num_output_images = 0
383 if prm.type == Type.IMAGE
and prm.direction == Direction.OUTPUT
and prm.state == ParamState.REQUIRED :
384 num_output_images += 1
385 return num_output_images
401 assert len(name_list) > 1,
"There should be more than 1 parameter in name_list" 408 for name
in name_list :
411 if name.lower() == prm.name_lower :
413 if prm.state == ParamState.REQUIRED :
414 if first_required == 0 :
417 elif prm.state == ParamState.OPTIONAL :
421 assert found ==
True,
"'%s' was not found in parameter list" % name
426 relationship = KernelParamRelationship(prm_list, attribute_list, type, ParamState.REQUIRED)
429 for prm
in prm_list :
430 if prm.state == ParamState.REQUIRED :
431 sub_prm_list.append(prm)
433 relationship = KernelParamRelationship(sub_prm_list, attribute_list, type, ParamState.REQUIRED)
440 for prm
in prm_list :
441 if prm.state == ParamState.OPTIONAL :
442 sub_prm_list.append(prm)
443 sub_prm_list.append(first_required)
444 relationship = KernelParamRelationship(sub_prm_list, attribute_list, type, ParamState.OPTIONAL)
450 relationship = KernelParamRelationship(prm_list, attribute_list, type, ParamState.OPTIONAL)
Kernel class containing parameter information.
def __init__(self, name="default")
Constructor used to create this object.
def setTarget(self, target)
Method used to set a possible target of the kernel.
def setParameter(self, type, direction, state, name, data_types=[], do_map=True, do_unmap=True, do_map_unmap_all_planes=False)
Method used to set a parameter of the kernel; called for as many parameters as necessary.
def __init__(self, df_image, image_patch_address, name="default")
Constructor used to create this object.
def setParameterRelationship(self, name_list=[], attribute_list=["all"], type="equal")
Method used to set the relationship between two parameters of a kernels Information from this method ...
def allocateLocalMemory(self, local_mem_name, attribute_list, parameter_name="")
Method used to allocated local memory; called per instance of memory allocation.