LoadFromData

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

Atlas inference product

Atlas training product

Header File/Library File

  • Header file: #include <graph/kernel_launch_info.h>
  • Library file: libregister.so

Function Usage

Deserializes a serialized task. This API is mainly used in the GenerateTask function to deserialize a task constructed by the framework and its 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

KernelLaunchInfo serialization result.

Returns

Result of deserializing the input parameter data.

Restrictions

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());
  // Re-serialize the updated task and set it back to the tasks.
  tasks.back() = aicore_task.Serialize();
  return SUCCESS;
}