TIOVX User Guide
tiovx.kernel.Kernel Class Reference

Kernel class containing parameter information. More...

Public Member Functions

def __init__ (self, name="default")
 Constructor used to create this object. More...
 
def setTarget (self, target)
 Method used to set a possible target of the kernel. More...
 
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. More...
 
def allocateLocalMemory (self, local_mem_name, attribute_list, parameter_name="")
 Method used to allocated local memory; called per instance of memory allocation. More...
 
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 used in validate stage Note: these parameters must have already been set prior to the invocation of this method. More...
 

Detailed Description

Kernel class containing parameter information.

Example Usage: Initializing kernel object with specified kernel name
from tiovx import *
kernel = Kernel("<kernel_name>")

Definition at line 126 of file kernel.py.

Constructor & Destructor Documentation

◆ __init__()

def tiovx.kernel.Kernel.__init__ (   self,
  name = "default" 
)

Constructor used to create this object.

Parameters
name[in] [optional] Name of the kernel (by default, the name is set to "default")

Definition at line 130 of file kernel.py.

Member Function Documentation

◆ setTarget()

def tiovx.kernel.Kernel.setTarget (   self,
  target 
)

Method used to set a possible target of the kernel.

Example Usage: Setting a new parameter of the kernel
kernel.setTarget(Target.DSP1)
Parameters
target[in] Possible target for the kernel to run on (use Target object as input)

Definition at line 160 of file kernel.py.

◆ setParameter()

def tiovx.kernel.Kernel.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.

Example Usage: Setting a new parameter of the kernel
kernel.setParameter(Type.IMAGE, Direction.INPUT, ParamState.REQUIRED, "IN", do_map=False, do_unmap=False)
Parameters
type[in] OpenVX data type of this parameter (use Type object as input)
direction[in] Direction of the parameter (use Direction object as input)
state[in] Required/optional state of this parameter
name[in] Name of this parameter
data_types[in] [optional] Possible data types for a given data object; Default=[]
do_map[in] [optional] Flag to indicate whether or not to do buffer mapping in target kernel; Default=True
do_unmap[in] [optional] Flag to indicate whether or not to do buffer unmapping in target kernel; Default=True
do_map_unmap_all_planes[in] [optional] Flag to indicate whether or not to do buffer unmapping for all planes in target kernel; Default=False

Definition at line 192 of file kernel.py.

◆ allocateLocalMemory()

def tiovx.kernel.Kernel.allocateLocalMemory (   self,
  local_mem_name,
  attribute_list,
  parameter_name = "" 
)

Method used to allocated local memory; called per instance of memory allocation.

The allocateLocalMemory method generates OpenVX code for allocating and free-ing local memory based on characteristics of existing data objects or on constant values. The method works by specifying the name of the memory to be allocated, the attributes or constant values to use for determining the amount of memory allocation and optionally specifying the existing parameter in the case of using attributes for memory allocation. The attribute list can consist of a) a comma-separated list of Attributes of the respective data type as defined in enums.py b) a comma-separated list of integers or c) a string containing a mixture of keywords per data type and string literals to be passed to the memory allocation. Each element of this list is multiplied together to The list of keywords per data type can be found below. (Note: in the case of images, the respective attributes are taken from plane 0.)

Image:
  • width
  • height
  • stride_x
  • stride_y
Array:
  • capacity
  • itemsize
  • itemtype
  • numitems
Pyramid:
  • levels
Matrix:
  • rows
  • columns
  • size
Distribution:
  • dimensions
  • offset
  • range
  • bins
  • window
  • size
LUT:
  • count
  • size
Remap:
  • source_width
  • source_height
  • destination_width
  • destination_height
Convolution:
  • rows
  • columns
  • size
  • scale
Object Array:
  • numitems
Example Usage #1:
Allocating memory based on attributes of existing image "IN_IMAGE"
kernel.allocateLocalMemory("img_scratch_mem", [Attribute.Image.WIDTH, Attribute.Image.HEIGHT], "IN_IMAGE")
Example Usage #2:
Alternative method of allocating memory from Example #1 based on string keywords.
kernel.allocateLocalMemory("img_scratch_mem", ["width*height"], "IN_IMAGE")
Example Usage #3:
Combining attribute method of allocation with an integer. The example below allocates 2 * width * height.
kernel.allocateLocalMemory("img_scratch_mem", [2, Attribute.Image.WIDTH, Attribute.Image.HEIGHT], "IN_IMAGE")
Example Usage #4:
Combining all methods for allocating memory. The output from this example will allocate width * height * 2 * width * height.
kernel.allocateLocalMemory("img_scratch_mem", ["width*height", 2, Attribute.Image.WIDTH, Attribute.Image.HEIGHT], "IN_IMAGE")
Example Usage #5:
Using non-keywords for string allocation method. The string method of allocation can also take other arguments such as "sizeof" and copies the string directly. Therefore, if there are errors in the string literal then there will be errors in the output result.
kernel.allocateLocalMemory("img_scratch_mem", ["width*height*sizeof(uint32_t)"], "IN_IMAGE")
Parameters
local_mem_name[in] Name of scratch memory pointer to be allocated
attribute_list[in] Attribute list to determine amount of memory to be allocated
parameter_name[in] [optional] Existing parameter of which previous list of attributes is based

Definition at line 297 of file kernel.py.

◆ setParameterRelationship()

def tiovx.kernel.Kernel.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 used in validate stage Note: these parameters must have already been set prior to the invocation of this method.

Example Usage: Setting the relationship between two parameter
kernel.setParameterRelationship(["INPUT", "OUTPUT"], [Attribute.Image.Width, Attribute.Image.HEIGHT])
Parameters
name_list[in] List of parameters that are to be connected
attribute_list[in] [optional] Attributes to connect between parameters; default=["all"]
type[in] [optional] Relationship type; default=equal

Definition at line 400 of file kernel.py.


The documentation for this class was generated from the following file: