Overview
OpTilingContextBuilder is used to construct TilingContext. The constructed context serves as an input parameter during operator tiling computation to obtain necessary data like the operator input and output. After the tilling computation is complete, the result is written back to the context.
The following figure shows the inheritance relationship of OpTilingContextBuilder.
The procedure is as follows:
- Construct ContextHolder.
Call the OpTilingContextBuilder API to transfer the corresponding input data, such as the input Tensor and PlatformInfo; and finally call the Build() API to construct a ContextHolder<TilingContext> object.
- Obtain TilingContext.
Call the GetContext API through ContextHolder to obtain TilingContext.
- Call the operator tiling implementation function TilingKernelFunc and use TilingContext as the function input parameter to complete tiling computation. The operator writes the computation result to the output.
- Use the TilingContext API to obtain the Tiling computation result.
- Release ContextHolder as required. After the release is complete, the data pointers in TilingContext constructed using Build are invalid.
This class is inherited from the OpContextBuilderBase class. Before the ContextHolder object construction, it is necessary to call OpType, OpName, and IONum (or IOInstanceNum) of OpContextBuilderBase to respectively set the operator type, name, and numbers of inputs and outputs, and to call the AppendAttr API to set operator attributes.
Header Files to Be Included
1 | #include "base/context_builder/op_tiling_context_builder.h" |
Public Member Functions
OpTilingContextBuilder() ~OpTilingContextBuilder() override OpTilingContextBuilder &CompileInfo(const void *compile_info) OpTilingContextBuilder &PlatformInfo(const void *platform_info) OpTilingContextBuilder &Deterministic(int32_t deterministic) OpTilingContextBuilder &TilingData(const gert::TilingData *tiling_data, gert::Chain::Deleter deleter = nullptr) OpTilingContextBuilder &TilingDataSize(size_t tiling_data_size) OpTilingContextBuilder &Workspace(const gert::ContinuousVector *workspace) OpTilingContextBuilder &InputTensors(const std::vector<gert::Tensor *> &inputs) OpTilingContextBuilder &OutputTensors(const std::vector<gert::Tensor *> &outputs) ContextHolder<TilingContext> Build()