DEVICE_IMPL_OP_OPTILING

Function

Generates a registration class for tiling offload in the tiling offload scenario, and calls member functions of the registration class to register the tiling functions to be offloaded.

Prototype

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
namespace optiling {
using SinkTilingFunc = std::function<ge::graphStatus(gert::TilingContext *context)>;

class DeviceOpImplRegisterImpl;
// Developers only need to focus on the tiling member function.
class DeviceOpImplRegister {
public:
  DeviceOpImplRegister(const char *opType);
  ~DeviceOpImplRegister();
  DeviceOpImplRegister(DeviceOpImplRegister &&other) noexcept;
  DeviceOpImplRegister(const DeviceOpImplRegister &other);
  DeviceOpImplRegister &operator=(const DeviceOpImplRegister &) = delete;
  DeviceOpImplRegister &operator=(DeviceOpImplRegister &&) = delete;
  DeviceOpImplRegister &Tiling(SinkTilingFunc func);

// ...
};
}  // namespace optiling

#define DEVICE_IMPL_OP_OPTILING(optype)                                                                      \
  static optiling::DeviceOpImplRegister VAR_UNUSED g_deviceOpImplRegister##optype =                                    \
      optiling::DeviceOpImplRegister(#optype)
#endif

Parameters

Table 1 DEVICE_IMPL_OP_OPTILING parameter

Parameter

Input/Output

Description

optype

Input

Operator type for which the tiling function needs to be registered.

Table 2 Parameter of the tiling member function

Parameter

Input/Output

Description

func

Input

Tiling function to be registered. This function accepts a TilingContext as the input and returns a ge::graphStatus.

Returns

None

Restrictions

None

Example

1
DEVICE_IMPL_OP_OPTILING(TestOptype).Tiling(TestTilingFunc); // Register the tiling function and its operator type with the tiling offload.