ASCENDC_TPL_SEL_PARAM
Function
Automatically generates and configures a TilingKey during tiling template programming.
To use this API, you need to include the header file that contains the template argument declaration and template argument selection. For details, see Tiling Template Programming.
Prototype
1 2 3 4 5 6 |
#define ASCENDC_TPL_SEL_PARAM(context, ...) \ do { \ uint64_t key = GET_TPL_TILING_KEY({__VA_ARGS__}); \ context->SetTilingKey(key); \ } while(0) // context indicates the context in TilingFunc(gert::TilingContext *context). |
Parameters
|
Parameter |
Input/Output |
Description |
|---|---|---|
|
context |
Input |
Tiling function registration context. |
|
... |
Input |
Variable-length parameters, which are the specific values of template arguments. They should be passed in the same sequence as the template arguments in the header file that contains the template argument declaration and template argument selection. |
Returns
None
Restrictions
None
Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
#include "tiling_key_add_custom.h" static ge::graphStatus TilingFunc(gert::TilingContext *context) { TilingDataTemplate tiling; uint32_t totalLength = context->GetInputShape(0)->GetOriginShape().GetShapeSize(); ge::DataType dtype_x = context->GetInputDesc(0)->GetDataType(); ge::DataType dtype_y = context->GetInputDesc(1)->GetDataType(); ge::DataType dtype_z = context->GetOutputDesc(0)->GetDataType(); uint32_t D_T_X = static_cast<int>(dtype_x), D_T_Y = static_cast<int>(dtype_y), D_T_Z = static_cast<int>(dtype_z), TILE_NUM = 1, IS_SPLIT = 0; if (totalLength < MIN_LENGTH_FOR_SPLIT) { IS_SPLIT = 0; TILE_NUM = 1; } else { IS_SPLIT = 1; TILE_NUM = DEFAULT_TILE_NUM; } context->SetBlockDim(BLOCK_DIM); tiling.set_totalLength(totalLength); tiling.SaveToBuffer(context->GetRawTilingData()->GetData(), context->GetRawTilingData()->GetCapacity()); context->GetRawTilingData()->SetDataSize(tiling.GetDataSize()); ASCENDC_TPL_SEL_PARAM(context, D_T_X, D_T_Y, D_T_Z, TILE_NUM, IS_SPLIT); size_t *currentWorkspace = context->GetWorkspaceSizes(1); currentWorkspace[0] = 0; return ge::GRAPH_SUCCESS; } |
Parent topic: Tiling Template Programming