Overview

OpInferShapeRangeContextBuilder is used to construct InferShapeRangeContext. The constructed Context serves as an input parameter during operator ShapeRange inference to obtain necessary operator input and output data. After the inference is complete, the result is written back to the context.

The following figure shows the inheritance relationship of OpInferShapeRangeContextBuilder.

The procedure is as follows:

  1. Construct ContextHolder.

    Call the OpInferShapeRangeContextBuilder API to transfer the corresponding input and output data, such as the Shape range gert::Range<gert::Tensor> of the input Tensor as well as the output TensorDesc; and finally call the Build() API to construct a ContextHolder<InferShapeRangeContext> object.

  2. Obtain InferShapeRangeContext.

    Call the GetContext API through ContextHolder to obtain InferShapeRangeContext.

  3. Call the operator ShapeRange inference function InferShapeRangeKernelFunc, use InferShapeRangeContext as the function input parameter, complete ShapeRange inference, and write the inference result to the output.
  4. Use the GetOutputShapeRange API of InferShapeRangeContext to obtain the output shape range of the inference.
  5. Release ContextHolder as required. After the release is complete, the data pointers in InferShapeRangeContext 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_infer_shape_range_context_builder.h"

Public Member Functions

OpInferShapeRangeContextBuilder()
~OpInferShapeRangeContextBuilder() override
OpInferShapeRangeContextBuilder &OutputTensorDesc(size_t index, ge::DataType dtype, ge::Format origin_format, ge::Format storage_format)
OpInferShapeRangeContextBuilder &InputTensorsRange(const std::vector<gert::Range<gert::Tensor> *> &inputs)
ContextHolder<InferShapeRangeContext> Build()