LoadFromData

Applicability

Product

Supported or Not

Atlas A3 training products/Atlas A3 inference products

Atlas A2 training products/Atlas A2 inference products

Atlas 200I/500 A2 inference products

Atlas inference products

Atlas training products

Header File

#include <graph/kernel_launch_info.h>

Function Usage

Deserializes a serialized task. This API is used to deserialize the task constructed by the framework in the GenerateTask function and modify the task parameters.

Prototype

1
static KernelLaunchInfo LoadFromData(const gert::ExeResGenerationContext *context, const std::vector<uint8_t> &data)

Parameters

Parameter

Input/Output

Description

context

Input

Input parameter of the GenerateTask function, which stores the basic information about the operator.

data

Input

Result after KernelLaunchInfo is serialized.

Returns

Deserialization result of the input parameter data.

Constraints

None

Examples

graphStatus Mc2GenTaskCallback(const gert::ExeResGenerationContext *context,
    std::vector<std::vector<uint8_t>> &tasks) {
   ....
  // Change ArgsFormat of the original AI Core task.
  auto aicore_task = KernelLaunchInfo::LoadFromData(context, tasks.back());
  // Obtain argsformat from the task.
  auto aicore_args_format_str = aicore_task.GetArgsFormat();
  auto aicore_args_format = ArgsFormatSerializer::Deserialize(aicore_args_format_str);
  size_t i = 0UL;
  // Find the position of the first input address.
  for (; i < aicore_args_format.size(); i++) {
    if (aicore_args_format[i].GetType() == ArgDescType::kIrInput ||
        aicore_args_format[i].GetType() == ArgDescType::kInputInstance) {
      break;
    }
  }
  // Insert a communication address before the input address.
  aicore_args_format.insert(aicore_args_format.begin() + i, ArgDescInfo::CreateHiddenInput(HiddenInputSubType::kHcom));
  // Serialize the modified argsformat and set it back to the task.
  aicore_task.SetArgsFormat(ArgsFormatSerializer::Serialize(aicore_args_format).GetString());
  // argsformat is reserialized and set in the task.
  tasks.back() = aicore_task.Serialize();
  return SUCCESS;
}