pjrt_sys/
structs.rs

1macro_rules! impl_new {
2    ($t:ident, $s:ident) => {
3        impl $crate::$t {
4            pub const STRUCT_SIZE: usize = $crate::$s as usize;
5
6            pub fn new() -> Self {
7                let mut t = $crate::$t::default();
8                t.struct_size = Self::STRUCT_SIZE;
9                t
10            }
11        }
12    };
13    ($t:ident) => {
14        impl $crate::$t {
15            pub fn new() -> Self {
16                $crate::$t::default()
17            }
18        }
19    };
20}
21
22impl_new!(PJRT_Extension_Base, PJRT_Extension_Base_STRUCT_SIZE);
23
24impl_new!(PJRT_Api_Version, PJRT_Api_Version_STRUCT_SIZE);
25
26impl_new!(PJRT_Error_Destroy_Args, PJRT_Error_Destroy_Args_STRUCT_SIZE);
27
28impl_new!(PJRT_Error_Message_Args, PJRT_Error_Message_Args_STRUCT_SIZE);
29
30impl_new!(PJRT_Error_GetCode_Args, PJRT_Error_GetCode_Args_STRUCT_SIZE);
31
32impl_new!(PJRT_NamedValue, PJRT_NamedValue_STRUCT_SIZE);
33
34impl_new!(
35    PJRT_Plugin_Initialize_Args,
36    PJRT_Plugin_Initialize_Args_STRUCT_SIZE
37);
38
39impl_new!(
40    PJRT_Plugin_Attributes_Args,
41    PJRT_Plugin_Attributes_Args_STRUCT_SIZE
42);
43
44impl_new!(PJRT_Event_Destroy_Args, PJRT_Event_Destroy_Args_STRUCT_SIZE);
45
46impl_new!(PJRT_Event_IsReady_Args, PJRT_Event_IsReady_Args_STRUCT_SIZE);
47
48impl_new!(PJRT_Event_Error_Args, PJRT_Event_Error_Args_STRUCT_SIZE);
49
50impl_new!(PJRT_Event_Await_Args, PJRT_Event_Await_Args_STRUCT_SIZE);
51
52impl_new!(PJRT_Event_OnReady_Args, PJRT_Event_OnReady_Args_STRUCT_SIZE);
53
54impl_new!(
55    PJRT_KeyValueGetCallback_Args,
56    PJRT_KeyValueGetCallback_Args_STRUCT_SIZE
57);
58
59impl_new!(
60    PJRT_KeyValuePutCallback_Args,
61    PJRT_KeyValuePutCallback_Args_STRUCT_SIZE
62);
63
64impl_new!(PJRT_Client_Create_Args, PJRT_Client_Create_Args_STRUCT_SIZE);
65
66impl_new!(
67    PJRT_Client_Destroy_Args,
68    PJRT_Client_Destroy_Args_STRUCT_SIZE
69);
70
71impl_new!(
72    PJRT_Client_PlatformName_Args,
73    PJRT_Client_PlatformName_Args_STRUCT_SIZE
74);
75
76impl_new!(
77    PJRT_Client_ProcessIndex_Args,
78    PJRT_Client_ProcessIndex_Args_STRUCT_SIZE
79);
80
81impl_new!(
82    PJRT_Client_PlatformVersion_Args,
83    PJRT_Client_PlatformVersion_Args_STRUCT_SIZE
84);
85
86impl_new!(
87    PJRT_Client_TopologyDescription_Args,
88    PJRT_Client_TopologyDescription_Args_STRUCT_SIZE
89);
90
91impl_new!(
92    PJRT_Client_Devices_Args,
93    PJRT_Client_Devices_Args_STRUCT_SIZE
94);
95
96impl_new!(
97    PJRT_Client_AddressableDevices_Args,
98    PJRT_Client_AddressableDevices_Args_STRUCT_SIZE
99);
100
101impl_new!(
102    PJRT_Client_LookupDevice_Args,
103    PJRT_Client_LookupDevice_Args_STRUCT_SIZE
104);
105
106impl_new!(
107    PJRT_Client_LookupAddressableDevice_Args,
108    PJRT_Client_LookupAddressableDevice_Args_STRUCT_SIZE
109);
110
111impl_new!(
112    PJRT_Client_AddressableMemories_Args,
113    PJRT_Client_AddressableMemories_Args_STRUCT_SIZE
114);
115
116impl_new!(PJRT_Program, PJRT_Program_STRUCT_SIZE);
117
118impl_new!(
119    PJRT_Client_Compile_Args,
120    PJRT_Client_Compile_Args_STRUCT_SIZE
121);
122
123impl_new!(
124    PJRT_Client_DefaultDeviceAssignment_Args,
125    PJRT_Client_DefaultDeviceAssignment_Args_STRUCT_SIZE
126);
127
128impl_new!(
129    PJRT_Buffer_MemoryLayout_Tiled,
130    PJRT_Buffer_MemoryLayout_Tiled_STRUCT_SIZE
131);
132
133impl_new!(
134    PJRT_Buffer_MemoryLayout_Strides,
135    PJRT_Buffer_MemoryLayout_Strides_STRUCT_SIZE
136);
137
138impl_new!(
139    PJRT_Buffer_MemoryLayout,
140    PJRT_Buffer_MemoryLayout_STRUCT_SIZE
141);
142
143impl_new!(
144    PJRT_Client_BufferFromHostBuffer_Args,
145    PJRT_Client_BufferFromHostBuffer_Args_STRUCT_SIZE
146);
147
148impl_new!(
149    PJRT_Client_CreateViewOfDeviceBuffer_Args,
150    PJRT_Client_CreateViewOfDeviceBuffer_Args_STRUCT_SIZE
151);
152
153impl_new!(
154    PJRT_DeviceDescription_Id_Args,
155    PJRT_DeviceDescription_Id_Args_STRUCT_SIZE
156);
157
158impl_new!(
159    PJRT_DeviceDescription_ProcessIndex_Args,
160    PJRT_DeviceDescription_ProcessIndex_Args_STRUCT_SIZE
161);
162
163impl_new!(
164    PJRT_DeviceDescription_Attributes_Args,
165    PJRT_DeviceDescription_Attributes_Args_STRUCT_SIZE
166);
167
168impl_new!(
169    PJRT_DeviceDescription_Kind_Args,
170    PJRT_DeviceDescription_Kind_Args_STRUCT_SIZE
171);
172
173impl_new!(
174    PJRT_DeviceDescription_DebugString_Args,
175    PJRT_DeviceDescription_DebugString_Args_STRUCT_SIZE
176);
177
178impl_new!(
179    PJRT_DeviceDescription_ToString_Args,
180    PJRT_DeviceDescription_ToString_Args_STRUCT_SIZE
181);
182
183impl_new!(
184    PJRT_Device_GetDescription_Args,
185    PJRT_Device_GetDescription_Args_STRUCT_SIZE
186);
187
188impl_new!(
189    PJRT_Device_IsAddressable_Args,
190    PJRT_Device_IsAddressable_Args_STRUCT_SIZE
191);
192
193impl_new!(
194    PJRT_Device_LocalHardwareId_Args,
195    PJRT_Device_LocalHardwareId_Args_STRUCT_SIZE
196);
197
198impl_new!(
199    PJRT_Device_AddressableMemories_Args,
200    PJRT_Device_AddressableMemories_Args_STRUCT_SIZE
201);
202
203impl_new!(
204    PJRT_Device_DefaultMemory_Args,
205    PJRT_Device_DefaultMemory_Args_STRUCT_SIZE
206);
207
208impl_new!(
209    PJRT_Device_MemoryStats_Args,
210    PJRT_Device_MemoryStats_Args_STRUCT_SIZE
211);
212
213impl_new!(PJRT_Memory_Id_Args, PJRT_Memory_Id_Args_STRUCT_SIZE);
214
215impl_new!(PJRT_Memory_Kind_Args, PJRT_Memory_Kind_Args_STRUCT_SIZE);
216
217impl_new!(
218    PJRT_Memory_Kind_Id_Args,
219    PJRT_Memory_Kind_Id_Args_STRUCT_SIZE
220);
221
222impl_new!(
223    PJRT_Memory_DebugString_Args,
224    PJRT_Memory_DebugString_Args_STRUCT_SIZE
225);
226
227impl_new!(
228    PJRT_Memory_ToString_Args,
229    PJRT_Memory_ToString_Args_STRUCT_SIZE
230);
231
232impl_new!(
233    PJRT_Memory_AddressableByDevices_Args,
234    PJRT_Memory_AddressableByDevices_Args_STRUCT_SIZE
235);
236
237impl_new!(
238    PJRT_ExecuteContext_Create_Args,
239    PJRT_ExecuteContext_Create_Args_STRUCT_SIZE
240);
241
242impl_new!(
243    PJRT_ExecuteContext_Destroy_Args,
244    PJRT_ExecuteContext_Destroy_Args_STRUCT_SIZE
245);
246
247impl_new!(
248    PJRT_Executable_Destroy_Args,
249    PJRT_Executable_Destroy_Args_STRUCT_SIZE
250);
251
252impl_new!(
253    PJRT_LoadedExecutable_Destroy_Args,
254    PJRT_LoadedExecutable_Destroy_Args_STRUCT_SIZE
255);
256
257impl_new!(
258    PJRT_LoadedExecutable_GetExecutable_Args,
259    PJRT_LoadedExecutable_GetExecutable_Args_STRUCT_SIZE
260);
261
262impl_new!(
263    PJRT_Executable_Name_Args,
264    PJRT_Executable_Name_Args_STRUCT_SIZE
265);
266
267impl_new!(
268    PJRT_Executable_NumReplicas_Args,
269    PJRT_Executable_NumReplicas_Args_STRUCT_SIZE
270);
271
272impl_new!(
273    PJRT_Executable_NumPartitions_Args,
274    PJRT_Executable_NumPartitions_Args_STRUCT_SIZE
275);
276
277impl_new!(
278    PJRT_LoadedExecutable_AddressableDevices_Args,
279    PJRT_LoadedExecutable_AddressableDevices_Args_STRUCT_SIZE
280);
281
282impl_new!(
283    PJRT_Executable_OptimizedProgram_Args,
284    PJRT_Executable_OptimizedProgram_Args_STRUCT_SIZE
285);
286
287impl_new!(
288    PJRT_LoadedExecutable_Delete_Args,
289    PJRT_LoadedExecutable_Delete_Args_STRUCT_SIZE
290);
291
292impl_new!(
293    PJRT_LoadedExecutable_IsDeleted_Args,
294    PJRT_LoadedExecutable_IsDeleted_Args_STRUCT_SIZE
295);
296
297impl_new!(PJRT_ExecuteOptions, PJRT_ExecuteOptions_STRUCT_SIZE);
298
299impl_new!(
300    PJRT_LoadedExecutable_Execute_Args,
301    PJRT_LoadedExecutable_Execute_Args_STRUCT_SIZE
302);
303
304impl_new!(
305    PJRT_Executable_NumOutputs_Args,
306    PJRT_Executable_NumOutputs_Args_STRUCT_SIZE
307);
308
309impl_new!(
310    PJRT_Executable_SizeOfGeneratedCodeInBytes_Args,
311    PJRT_Executable_SizeOfGeneratedCodeInBytes_Args_STRUCT_SIZE
312);
313
314impl_new!(
315    PJRT_Executable_Fingerprint_Args,
316    PJRT_Executable_Fingerprint_Args_STRUCT_SIZE
317);
318
319impl_new!(
320    PJRT_Executable_GetCostAnalysis_Args,
321    PJRT_Executable_GetCostAnalysis_Args_STRUCT_SIZE
322);
323
324impl_new!(
325    PJRT_Executable_GetCompiledMemoryStats_Args,
326    PJRT_Executable_GetCompiledMemoryStats_Args_STRUCT_SIZE
327);
328
329impl_new!(
330    PJRT_Executable_OutputElementTypes_Args,
331    PJRT_Executable_OutputElementTypes_Args_STRUCT_SIZE
332);
333
334impl_new!(
335    PJRT_Executable_OutputDimensions_Args,
336    PJRT_Executable_OutputDimensions_Args_STRUCT_SIZE
337);
338
339impl_new!(
340    PJRT_Executable_OutputMemoryKinds_Args,
341    PJRT_Executable_OutputMemoryKinds_Args_STRUCT_SIZE
342);
343
344impl_new!(
345    PJRT_Executable_Serialize_Args,
346    PJRT_Executable_Serialize_Args_STRUCT_SIZE
347);
348
349impl_new!(
350    PJRT_Executable_DeserializeAndLoad_Args,
351    PJRT_Executable_DeserializeAndLoad_Args_STRUCT_SIZE
352);
353
354impl_new!(
355    PJRT_LoadedExecutable_Fingerprint_Args,
356    PJRT_LoadedExecutable_Fingerprint_Args_STRUCT_SIZE
357);
358
359impl_new!(
360    PJRT_Buffer_Destroy_Args,
361    PJRT_Buffer_Destroy_Args_STRUCT_SIZE
362);
363
364impl_new!(
365    PJRT_Buffer_ElementType_Args,
366    PJRT_Buffer_ElementType_Args_STRUCT_SIZE
367);
368
369impl_new!(
370    PJRT_Buffer_Dimensions_Args,
371    PJRT_Buffer_Dimensions_Args_STRUCT_SIZE
372);
373
374impl_new!(
375    PJRT_Buffer_UnpaddedDimensions_Args,
376    PJRT_Buffer_UnpaddedDimensions_Args_STRUCT_SIZE
377);
378
379impl_new!(
380    PJRT_Buffer_DynamicDimensionIndices_Args,
381    PJRT_Buffer_DynamicDimensionIndices_Args_STRUCT_SIZE
382);
383
384impl_new!(
385    PJRT_Buffer_GetMemoryLayout_Args,
386    PJRT_Buffer_GetMemoryLayout_Args_STRUCT_SIZE
387);
388
389impl_new!(
390    PJRT_Buffer_ToHostBuffer_Args,
391    PJRT_Buffer_ToHostBuffer_Args_STRUCT_SIZE
392);
393
394impl_new!(
395    PJRT_Buffer_OnDeviceSizeInBytes_Args,
396    PJRT_Buffer_OnDeviceSizeInBytes_Args_STRUCT_SIZE
397);
398
399impl_new!(PJRT_Buffer_Delete_Args, PJRT_Buffer_Delete_Args_STRUCT_SIZE);
400
401impl_new!(
402    PJRT_Buffer_IsDeleted_Args,
403    PJRT_Buffer_IsDeleted_Args_STRUCT_SIZE
404);
405
406impl_new!(
407    PJRT_Buffer_CopyToDevice_Args,
408    PJRT_Buffer_CopyToDevice_Args_STRUCT_SIZE
409);
410
411impl_new!(
412    PJRT_Buffer_CopyToMemory_Args,
413    PJRT_Buffer_CopyToMemory_Args_STRUCT_SIZE
414);
415
416impl_new!(
417    PJRT_Buffer_IsOnCpu_Args,
418    PJRT_Buffer_IsOnCpu_Args_STRUCT_SIZE
419);
420
421impl_new!(PJRT_Buffer_Device_Args, PJRT_Buffer_Device_Args_STRUCT_SIZE);
422
423impl_new!(PJRT_Buffer_Memory_Args, PJRT_Buffer_Memory_Args_STRUCT_SIZE);
424
425impl_new!(
426    PJRT_Buffer_ReadyEvent_Args,
427    PJRT_Buffer_ReadyEvent_Args_STRUCT_SIZE
428);
429
430impl_new!(
431    PJRT_Buffer_UnsafePointer_Args,
432    PJRT_Buffer_UnsafePointer_Args_STRUCT_SIZE
433);
434
435impl_new!(
436    PJRT_Buffer_IncreaseExternalReferenceCount_Args,
437    PJRT_Buffer_IncreaseExternalReferenceCount_Args_STRUCT_SIZE
438);
439
440impl_new!(
441    PJRT_Buffer_DecreaseExternalReferenceCount_Args,
442    PJRT_Buffer_DecreaseExternalReferenceCount_Args_STRUCT_SIZE
443);
444
445impl_new!(
446    PJRT_Buffer_OpaqueDeviceMemoryDataPointer_Args,
447    PJRT_Buffer_OpaqueDeviceMemoryDataPointer_Args_STRUCT_SIZE
448);
449
450impl_new!(
451    PJRT_CopyToDeviceStream_Destroy_Args,
452    PJRT_CopyToDeviceStream_Destroy_Args_STRUCT_SIZE
453);
454
455impl_new!(
456    PJRT_CopyToDeviceStream_AddChunk_Args,
457    PJRT_CopyToDeviceStream_AddChunk_Args_STRUCT_SIZE
458);
459
460impl_new!(
461    PJRT_CopyToDeviceStream_TotalBytes_Args,
462    PJRT_CopyToDeviceStream_TotalBytes_Args_STRUCT_SIZE
463);
464
465impl_new!(
466    PJRT_CopyToDeviceStream_GranuleSize_Args,
467    PJRT_CopyToDeviceStream_GranuleSize_Args_STRUCT_SIZE
468);
469
470impl_new!(
471    PJRT_CopyToDeviceStream_CurrentBytes_Args,
472    PJRT_CopyToDeviceStream_CurrentBytes_Args_STRUCT_SIZE
473);
474
475impl_new!(
476    PJRT_TopologyDescription_Create_Args,
477    PJRT_TopologyDescription_Create_Args_STRUCT_SIZE
478);
479
480impl_new!(
481    PJRT_TopologyDescription_Destroy_Args,
482    PJRT_TopologyDescription_Destroy_Args_STRUCT_SIZE
483);
484
485impl_new!(
486    PJRT_TopologyDescription_PlatformVersion_Args,
487    PJRT_TopologyDescription_PlatformVersion_Args_STRUCT_SIZE
488);
489
490impl_new!(
491    PJRT_TopologyDescription_PlatformName_Args,
492    PJRT_TopologyDescription_PlatformName_Args_STRUCT_SIZE
493);
494
495impl_new!(
496    PJRT_TopologyDescription_GetDeviceDescriptions_Args,
497    PJRT_TopologyDescription_GetDeviceDescriptions_Args_STRUCT_SIZE
498);
499
500impl_new!(
501    PJRT_TopologyDescription_Serialize_Args,
502    PJRT_TopologyDescription_Serialize_Args_STRUCT_SIZE
503);
504
505impl_new!(
506    PJRT_TopologyDescription_Attributes_Args,
507    PJRT_TopologyDescription_Attributes_Args_STRUCT_SIZE
508);
509
510impl_new!(PJRT_Compile_Args, PJRT_Compile_Args_STRUCT_SIZE);