昇腾社区首页
中文
注册
开发者
下载

简介

OpTilingParseContextBuilder用于构建TilingParseContext。构造出的Context在算子TilingParse计算过程中作为输入,用于获取必要的算子输入输出数据。完成Parser计算后,结果会被写回到上下文中。

OpTilingParseContextBuilder继承关系图如下:

使用步骤如下:

  1. 构造ContextHolder。

    调用OpTilingParseContextBuilder接口,传入相应的输入数据,比如输入的InputTensorDesc、CompiledJson等,最终调用Build()接口构造一个ContextHolder<TilingParseContext>对象。

  2. 获取TilingParseContext。

    通过ContextHolder调用GetContext接口,获取TilingParseContext。

  3. 调用算子TilingParser函数TilingParserKernelFunc,将TilingParseContext作为函数入参,完成TilingParser计算,并写入计算的输出结果。
  4. 通过TilingParseContext的接口可以获取到CompiledInfo。
  5. 根据需要释放ContextHolder,释放完成后,此时Build构造出来的TilingParseContext中的数据指针均无效。

该类继承自OpContextBuilderBase类,在Build构建ContextHolder对象之前,需要调用OpContextBuilderBase的OpType、OpName、IONum或IOInstanceNum,以及AppendAttr接口,分别设置算子的类型、名称、输入输出个数、以及算子的属性。

需要包含的头文件

1
#include "base/context_builder/op_tiling_parse_context_builder.h"

Public成员函数

OpTilingParseContextBuilder()
~OpTilingParseContextBuilder() override
OpTilingParseContextBuilder &InputTensorDesc(size_t index, ge::DataType dtype, ge::Format origin_format,
                                             ge::Format storage_format,
                                             const gert::ExpandDimsType &expand_dims_type = {})
OpTilingParseContextBuilder &OutputTensorDesc(size_t index, ge::DataType dtype, ge::Format origin_format,
                                              ge::Format storage_format,
                                              const gert::ExpandDimsType &expand_dims_type = {})
OpTilingParseContextBuilder &CompiledJson(const ge::char_t *compiled_json)
OpTilingParseContextBuilder &CompiledInfo(const void *compile_info)
OpTilingParseContextBuilder &PlatformInfo(const void *platform_info)
ContextHolder<TilingParseContext> Build()