Auto Tiler Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
CNN_Graph

Functions

void AT_SetGraphCtrl (AT_GraphCtrl_T Ctrl, void *Val)
 Set graph processing options. More...
 
char * CNNGraphName ()
 Returns the name of the defined graph. More...
 
CNNGraph_TCNNGraph ()
 Returns the defined graph. More...
 
CNNGraph_TCreateGraph (char *GraphName, CKernel_Arg_T **CArgs, CKernel_Arg_T **Locals)
 Declare a new CNN Graph and open it. More...
 
void AddGraphCArg (CKernel_Arg_T *CArg)
 Declare a new CNN Graph CArg argument. More...
 
void AddGraphLocal (CKernel_Arg_T *CArg)
 Declare a new CNN Graph Local argument. More...
 
void CommitGraphArgsAndLocals ()
 Commit to open CNN Graph AddGraphCArg and AddGraphLocal contributions. More...
 
void AddNode (char *NodeName, ArgBindingDescr_T **BindingList)
 Add a layer to the opened CNN graph. More...
 
void AddCallToNode (char *NodeName, CallLocationT Where, char *FunName, ArgBindingDescr_T **FunArgs)
 Add a C call before or after a graph node. More...
 
ArgBindingDescr_TGNodeArg (GraghNodeArgT Type, char *ArgName, char *AliasedArgName)
 Binds a given Graph node arg to a user kernel kernel argument. More...
 
ArgBindingDescr_TGNodeCArg (char *ArgName)
 Binds a given Graph node arg to a user kernel kernel C argument. More...
 
ArgBindingDescr_TGNodeArgImmOper (GraghNodeArgT Type, char *ArgName, char *AliasedArgName, char Oper, int Value)
 Binds a given Graph node arg applying an immediate operation to it. More...
 
void AddGraphArgExportSymbols (char *GraphCArgName, char *ExportAddrName, char *ExportLocName)
 Add a pair of symbols to a graph C arg to pass it's allocated address and memory location. More...
 
ArgBindingDescr_TGArg (char *ArgName)
 Binds a given Graph node arg, simplified form. More...
 
void CloseGraph ()
 Close the currently open CNN Graph and process it. More...
 
int GenerateCodeForCNNGraph (CNNGraph_T *Graph, int Declare, unsigned int TensorDumpFilter, char *L2_DumpBuffer, unsigned int L2_DumpBufferSize, FILE *Fi)
 Generate code for the CNN Graph if any. More...
 
void CNN_InitGenCtrl (CNN_GenControl_T *Ctrl)
 Initializes a CNN Generator control descriptor, all fields are set to default. More...
 
void CNN_SetGenCtrl (CNN_GenControl_T *Ctrl, char *Name, void *Val)
 Overides default behaviour of a CNN Generator. Set one CNN generator control descriptor field described by it's name to Val. More...
 
void CNN_SetGenCtrlList (CNN_GenControl_T *Ctrl,...)
 Overides default behaviour of a CNN Generator. Set list of CNN generator control descriptor fields (Name, Val) stops when Name = 0. More...
 
int * CNN_Type (int I1, int I2, int I3, int I4, int O)
 Create a CNN type size vector(4) More...
 
KernelOper_TCNN_OperList (int N,...)
 Create a list of N CNN operation. More...
 
CNN_LayerOp_TCNN_Match (KernelOper_T *KerOper1, KernelOper_T *KerOper2, int ParFeat, int *OpType, int Fx, int Fy, int Dx, int Dy, int Sx, int Sy)
 Create a CNN matching condition for a Basic Kernel. More...
 
char * CNN_FindMatchingKernel (KernelOper_T KerOper1, KernelOper_T KerOper2, int ParallelOutFeat, int I1Size, int I2Size, int I3Size, int I4Size, int OSize, int FX, int FY, int DX, int DY, int SX, int SY, int *NeedFx, int *NeedFy, int *NeedDx, int *NeedDy, int *NeedSx, int *NeedSy, int *ArgCount)
 Look into KernelLibs operation descriptor, return best match if any. More...
 
char * CNN_ArgDataType (int DataSize, int Pointer, int Restrict)
 Returns a signed C type for an argument given it's size in byte. More...
 
char * CNN_ArgDataTypeUns (int DataSize, int Pointer, int Restrict)
 Returns an unsigned C type for an argument given it's size in byte. More...
 
KernelOper_T CNN_CompositeKernel (KernelOper_T K1, KernelOper_T K2, KernelOper_T K3)
 For merged CNN layers retrieves composite Layer operation from individual operations. More...
 
char * CNN_KernelOperImage (KernelOper_T Op)
 Returns CNN Oper Name. More...
 

Description

CNN Graph related functions

CNN Kernels operation related functions

Function Documentation

void AddCallToNode ( char *  NodeName,
CallLocationT  Where,
char *  FunName,
ArgBindingDescr_T **  FunArgs 
)

Add a C call before or after a graph node. Calls order follows insertion order

Parameters
NodeNameExisting graph node name
WhereBefore: CALL_PROLOG. After: CALL:EPILOG
FunNameCalled function name
FunArgsFunction Argument list, use GArg
void AddGraphArgExportSymbols ( char *  GraphCArgName,
char *  ExportAddrName,
char *  ExportLocName 
)

Add a pair of symbols to a graph C arg to pass it's allocated address and memory location

Parameters
GraphCArgNameGraph CArg name, should be CArg with scope=ARG_SCOPE_GLOBAL
ExportAddrNameLegal C Name to store Graph CArg allocated address, type is unsigned int
ExportLocNameLegal C Name to store n which memort Graph CArg has been allocated, an int
void AddGraphCArg ( CKernel_Arg_T CArg)

Declare a new CNN Graph CArg argument

void AddGraphLocal ( CKernel_Arg_T CArg)

Declare a new CNN Graph Local argument

void AddNode ( char *  NodeName,
ArgBindingDescr_T **  BindingList 
)

Add a layer to the opened CNN graph

Parameters
NodeNameA user kernel name or a user kernel group name
BindingListBindings for this kernel call
void AT_SetGraphCtrl ( AT_GraphCtrl_T  Ctrl,
void *  Val 
)

Set graph processing options Possible Ctrl are: AT_GRAPH_MONITOR_CYCLES, Enable automatic cycle capture for each node of the graph, default is 0 AT_GRAPH_MONITOR_CVAR_NAME, When monitor cycles is on name of the C var array to receive results, default is AT_GraphPerf AT_GRAPH_PRODUCE_NODE_NAMES, Enable production of an array containing the name of each graph node, default is 0 AT_GRAPH_PRODUCE_NODE_CVAR_NAME, When producing node names is on name of the C array receiving the names as strings, default is AT_GraphNodeNames AT_GRAPH_PRODUCE_OPERINFOS, Enable production of number of macs for each layer, default is 0 AT_GRAPH_PRODUCE_OPERINFOS_CVAR_NAME, When Number of oper Infos is on name of the C array receiving mac infos for each node, default is AT_GraphOperInfosNames AT_GRAPH_REORDER_CONSTANT_IN, Enable reodering of constant inputs in order to transform 2D accesses into 1D accesses, default is 1 AT_GRAPH_TRACE_EXEC, Enable trace of activity, default is 1 AT_GRAPH_NOINLINE_NODE, If 1 all user kernel function is marked as noinline, default is 0 AT_GRAPH_PREF_L3_EXEC, In case a symbol must be allocated in L3 for execution this is the prefered memory, default is AT_MEM_L3_HRAM AT_GRAPH_CONST_EXEC_FROM_FLASH, If 1, for constant symbol executes from home location, default is 0 AT_GRAPH_PREF_L3_HOME, For constant symbols which L3 flash prefered memory, default is AT_MEM_L3_HFLASH

For Val use Use APT_OPT_ON, AT_OPT_OFF, AT_OPT_VAL(Val)

Parameters
CtrlWhich option
ValValue for this option. Use APT_OPT_ON, AT_OPT_OFF, AT_OPT_VAL(Val)
void CloseGraph ( )

Close the currently open CNN Graph and process it

char* CNN_ArgDataType ( int  DataSize,
int  Pointer,
int  Restrict 
)

Returns a signed C type for an argument given it's size in byte

Parameters
DataSizeArgument size in byte (1,2 or 4)
PointerIs this argument a pointer
RestrictIn case this argument is a pointer can it be restricted?
char* CNN_ArgDataTypeUns ( int  DataSize,
int  Pointer,
int  Restrict 
)

Returns an unsigned C type for an argument given it's size in byte

Parameters
DataSizeArgument size in byte (1,2 or 4)
PointerIs this argument a pointer
RestrictIn case this argument is a pointer can it be restricted?
KernelOper_T CNN_CompositeKernel ( KernelOper_T  K1,
KernelOper_T  K2,
KernelOper_T  K3 
)

For merged CNN layers retrieves composite Layer operation from individual operations.

Parameters
K1First CNN operation
K2Second CNN operation or KOP_NONE
K3Third CNN operation or KOP_NONE
char* CNN_FindMatchingKernel ( KernelOper_T  KerOper1,
KernelOper_T  KerOper2,
int  ParallelOutFeat,
int  I1Size,
int  I2Size,
int  I3Size,
int  I4Size,
int  OSize,
int  FX,
int  FY,
int  DX,
int  DY,
int  SX,
int  SY,
int *  NeedFx,
int *  NeedFy,
int *  NeedDx,
int *  NeedDy,
int *  NeedSx,
int *  NeedSy,
int *  ArgCount 
)

Look into KernelLibs operation descriptor, return best match if any. When a basic kernel can perform 2 sucessive operations the 2nd operation can be specified.

Parameters
KerOper1Primary operation
KerOper2Optional operation to be performed on the output of the primary one
ParallelOutFeatChoose a kernel using channel centric parallelization, otherwise feature centric parallelization
I1SizeSize in byte of the first input operand, 0 if not relevant. Order assumption: In,Filter,Bias,Out
I2SizeSize in byte of the second input operand, 0 if not relevant
I3SizeSize in byte of the third input operand, 0 if not relevant
I4SizeSize in byte of the fourth input operand, 0 if not relevant
OSizeSize in byte of the output input operand, 0 if not relevant
FXIf this operation is a filter, Filter X dimension, 0: not relevant, -1: All value are matching, >0 a specific dimension
FYIf this operation is a filter, Filter Y dimension, 0: not relevant, -1: All value are matching, -2 all values but equal to FX, >0 a specific dimension
DXIf this operation is a filter, Filter dilation for X dimension, 0: not relevant, -1: All value are matching, >0 a specific dimension
DYIf this operation is a filter, Filter dilation for Y dimension, 0: not relevant, -1: All value are matching, -2 all values but equal to FX, >0 a specific dimension
SXIf this operation is a filter, Filter Stride for X dimension, 0: not relevant, -1: All value are matching, >0 a specific dimension
SYIf this operation is a filter, Filter Stride for Y dimension, 0: not relevant, -1: All value are matching, -2 all values but equal to FX, >0 a specific dimension
NeedFxFX should be explictly passed to the basic kernel
NeedFyFY should be explictly passed to the basic kernel
NeedDxDX should be explictly passed to the basic kernel
NeedDyDY should be explictly passed to the basic kernel
NeedSxSX should be explictly passed to the basic kernel
NeedSySY should be explictly passed to the basic kernel
ArgCountNunber of arguments of the basic kernel implementing this CNN operation
void CNN_InitGenCtrl ( CNN_GenControl_T Ctrl)

Initializes a CNN Generator control descriptor, all fields are set to default

Parameters
CtrlAddress of a CNN generator control descriptor
char* CNN_KernelOperImage ( KernelOper_T  Op)

Returns CNN Oper Name

Parameters
OpA CNN operation
CNN_LayerOp_T* CNN_Match ( KernelOper_T KerOper1,
KernelOper_T KerOper2,
int  ParFeat,
int *  OpType,
int  Fx,
int  Fy,
int  Dx,
int  Dy,
int  Sx,
int  Sy 
)

Create a CNN matching condition for a Basic Kernel

Parameters
KerOper1List of N_Oper1 primary CNN operation matching
KerOper2Number of N_Oper2 secondary CNN operation matching
ParFeatIf basic kernel evaluates channels in parallel
OpTypeOperand's type size: In1,In2,In3,Out usually (In,Filter,Bias,Out). 0 to ignore otherwise size in bytes
FxFilter X dimension, 0 if don't care, -1 if match all input
FyFilter Y dimension, 0 if don't care, -1 if match all input, -2 match all input by equal to Fx
DxFilter X dilation, 0 if don't care, -1 if match all input
DyFilter Y dilation, 0 if don't care, -1 if match all input, -2 match all input by equal to Dx
SxFilter X stride, 0 if don't care, -1 if match all input
SyFilter Y stride, 0 if don't care, -1 if match all input, -2 match all input by equal to Sx
KernelOper_T* CNN_OperList ( int  N,
  ... 
)

Create a list of N CNN operation

Parameters
NNumber of CNN operations
void CNN_SetGenCtrl ( CNN_GenControl_T Ctrl,
char *  Name,
void *  Val 
)

Overides default behaviour of a CNN Generator. Set one CNN generator control descriptor field described by it's name to Val Name is case insensitive, list of names TileOrientation Controls tiling orientation. -1: use default, TILE_HOR or TILE_VER ParallelFeatures Controls parallelization strategy. -1: use default, 0: Each output feature is evaluated in parallel, 1: several output features are evalauted in parallel ForcedDPConv Controls double precision option for convolution: -1: use default, 0: Disable double precision, 1: Enable double precision UseHwCE Controls HWCE usage: -1: use default, 0: Disable HWCE, 1: Enable HWCE and use it if possible PadType Controls padding strategy: left/right/balanced_left/balanced_right EnableIm2Col Controls if Matrix Multiply based convolution should be used when possibleValue, an integer or a string. Use APT_OPT_ON, AT_OPT_OFF, AT_OPT_VAL(Val)

Parameters
CtrlAddress of a CNN generator control descriptor
NameField name, case insensitive
void CNN_SetGenCtrlList ( CNN_GenControl_T Ctrl,
  ... 
)

Overides default behaviour of a CNN Generator. Set list of CNN generator control descriptor fields (Name, Val) stops when Name = 0

Parameters
CtrlAddress of a CNN generator control descriptor
int* CNN_Type ( int  I1,
int  I2,
int  I3,
int  I4,
int  O 
)

Create a CNN type size vector(4). Usually the 4 operands are In,Filter,Bias,Out. Byte size currently limited to 4Output operand type size in byte, 0 to ignore

Parameters
I1First operand type size in byte, 0 to ignore
I2Second operand type size in byte, 0 to ignore
I3Third operand type size in byte, 0 to ignore
I4Fourth operand type size in byte, 0 to ignore
CNNGraph_T* CNNGraph ( )

Returns the defined graph

char* CNNGraphName ( )

Returns the name of the defined graph

void CommitGraphArgsAndLocals ( )
CNNGraph_T* CreateGraph ( char *  GraphName,
CKernel_Arg_T **  CArgs,
CKernel_Arg_T **  Locals 
)

Declare a new CNN Graph and open it

Parameters
GraphNameCNN Graph name
CArgsC arguments of this CNN graph
LocalsLocal arguments of this CNN graph
ArgBindingDescr_T* GArg ( char *  ArgName)

Binds a given Graph node arg, simplified form

Parameters
ArgNameArgument name, should be in internal or external graph variables
int GenerateCodeForCNNGraph ( CNNGraph_T Graph,
int  Declare,
unsigned int  TensorDumpFilter,
char *  L2_DumpBuffer,
unsigned int  L2_DumpBufferSize,
FILE *  Fi 
)

Generate code for the CNN Graph if any

Parameters
GraphPointer to the CNN graph
Declareif 1 declare graph related entry points, if 0 generate bodies
TensorDumpFilterAutomatic dump control
L2_DumpBufferL2 Dump Buffer if needed (tensor trace)
L2_DumpBufferSizeSize of the L2 Buffer
FiFile where to dump generated code
ArgBindingDescr_T* GNodeArg ( GraghNodeArgT  Type,
char *  ArgName,
char *  AliasedArgName 
)

Binds a given Graph node arg to a user kernel kernel argument

Parameters
TypeDirection: GNA_IN, GNA_OUT or GNA_INOUT
ArgNameArgument name, should be in internal or external graph variables and a user kernel kernel argument
AliasedArgNameIn case Direction is GNA_INOUT output ArgName is aliased to input AliasedArgName
ArgBindingDescr_T* GNodeArgImmOper ( GraghNodeArgT  Type,
char *  ArgName,
char *  AliasedArgName,
char  Oper,
int  Value 
)

Binds a given Graph node arg applying an immediate operation to it

Parameters
TypeDirection: GNA_IN, GNA_OUT or GNA_INOUT
ArgNameArgument name, should be in internal or external graph variables
AliasedArgNameIn case Direction is GNA_INOUT output ArgName is aliased to input AliasedArgName
OperOffset operation to be applied
ValueOffset value
ArgBindingDescr_T* GNodeCArg ( char *  ArgName)

Binds a given Graph node arg to a user kernel kernel C argument

Parameters
ArgNameArgument name, should be an external graph variable and a user kernel C argument