-
Notifications
You must be signed in to change notification settings - Fork 4
/
ze_graph_ext.h
691 lines (573 loc) · 36.4 KB
/
ze_graph_ext.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
/*
*
* Copyright (C) 2021-2023 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#ifndef _ZE_GRAPH_EXT_H
#define _ZE_GRAPH_EXT_H
#if defined(__cplusplus)
#pragma once
#endif
#include "ze_api.h"
#include "ze_graph_profiling_ext.h"
#ifndef ZE_GRAPH_EXT_NAME
#define ZE_GRAPH_EXT_NAME "ZE_extension_graph"
#endif
#if defined(__cplusplus)
extern "C" {
#endif
///////////////////////////////////////////////////////////////////////////////
/// @brief Supported Graph Extension versions
///
/// @details
/// - Graph extension versions contain major and minor attributes, use
/// ::ZE_MAJOR_VERSION and ::ZE_MINOR_VERSION
typedef enum _ze_graph_ext_version_t
{
ZE_GRAPH_EXT_VERSION_1_0 = ZE_MAKE_VERSION( 1, 0 ), ///< version 1.0
ZE_GRAPH_EXT_VERSION_1_1 = ZE_MAKE_VERSION( 1, 1 ), ///< version 1.1
ZE_GRAPH_EXT_VERSION_1_2 = ZE_MAKE_VERSION( 1, 2 ), ///< version 1.2
ZE_GRAPH_EXT_VERSION_1_3 = ZE_MAKE_VERSION( 1, 3 ), ///< version 1.3
ZE_GRAPH_EXT_VERSION_1_4 = ZE_MAKE_VERSION( 1, 4 ), ///< version 1.4
ZE_GRAPH_EXT_VERSION_1_5 = ZE_MAKE_VERSION( 1, 5 ), ///< version 1.5
ZE_GRAPH_EXT_VERSION_1_6 = ZE_MAKE_VERSION( 1, 6 ), ///< version 1.6
ZE_GRAPH_EXT_VERSION_1_7 = ZE_MAKE_VERSION( 1, 7 ), ///< version 1.7
ZE_GRAPH_EXT_VERSION_1_8 = ZE_MAKE_VERSION( 1, 8 ), ///< version 1.8
ZE_GRAPH_EXT_VERSION_1_9 = ZE_MAKE_VERSION( 1, 9 ), ///< version 1.9
ZE_GRAPH_EXT_VERSION_CURRENT = ZE_GRAPH_EXT_VERSION_1_9, ///< latest known version
ZE_GRAPH_EXT_VERSION_FORCE_UINT32 = 0x7fffffff
} ze_graph_ext_version_t;
///////////////////////////////////////////////////////////////////////////////
/// @brief Supported graph creation input formats
typedef enum _ze_graph_format_t
{
ZE_GRAPH_FORMAT_NATIVE = 0x1, ///< Format is pre-compiled blob (elf, flatbuffers)
ZE_GRAPH_FORMAT_NGRAPH_LITE = 0x2, ///< Format is ngraph lite IR
} ze_graph_format_t;
///////////////////////////////////////////////////////////////////////////////
/// @brief Compiler version information
typedef struct _ze_graph_compiler_version_info_t
{
uint16_t major;
uint16_t minor;
} ze_graph_compiler_version_info_t;
///////////////////////////////////////////////////////////////////////////////
/// @brief Defines structure types
typedef enum _ze_structure_type_graph_ext_t
{
ZE_STRUCTURE_TYPE_DEVICE_GRAPH_PROPERTIES = 0x1, ///< ::ze_device_graph_properties_t
ZE_STRUCTURE_TYPE_GRAPH_DESC_PROPERTIES = 0x2, ///< ::ze_graph_desc_t
ZE_STRUCTURE_TYPE_GRAPH_PROPERTIES = 0x3, ///< ::ze_graph_properties_t
ZE_STRUCTURE_TYPE_GRAPH_ARGUMENT_PROPERTIES = 0x4, ///< ::ze_graph_argument_properties_t
ZE_STRUCTURE_TYPE_GRAPH_ACTIVATION_KERNEL = 0x5, ///< ::ze_graph_activation_kernel_t
ZE_STRUCTURE_TYPE_GRAPH_ARGUMENT_METADATA = 0x6, ///< ::ze_graph_argument_metadata_t
ZE_STRUCTURE_TYPE_MUTABLE_GRAPH_ARGUMENT_EXP_DESC_DEPRECATED = 0x7, ///< ::ze_mutable_graph_argument_exp_desc_t
ZE_STRUCTURE_TYPE_MUTABLE_GRAPH_PROFILING_QUERY_EXP_DESC = 0x8 ///< ::ze_mutable_graph_profiling_query_exp_desc_t
} ze_structure_type_graph_ext_t;
///////////////////////////////////////////////////////////////////////////////
/// @brief Device graph properties
typedef struct _ze_device_graph_properties_t
{
ze_structure_type_graph_ext_t stype; ///< [in] type of this structure
void* pNext; ///< [in,out][optional] must be null or a pointer to an extension-specific
ze_graph_ext_version_t graphExtensionVersion; ///< [out] graph extension version
ze_graph_compiler_version_info_t compilerVersion; ///< [out] compiler version
ze_graph_format_t graphFormatsSupported; ///< [out] graph formats supported
uint32_t maxOVOpsetVersionSupported; ///< [out] max OV opset version supported by the compiler
} ze_device_graph_properties_t;
///////////////////////////////////////////////////////////////////////////////
/// @brief Graph argument properties
typedef enum _ze_graph_argument_precision_t
{
ZE_GRAPH_ARGUMENT_PRECISION_UNKNOWN = 0x00,
ZE_GRAPH_ARGUMENT_PRECISION_FP64 = 0x0F,
ZE_GRAPH_ARGUMENT_PRECISION_FP32 = 0x01,
ZE_GRAPH_ARGUMENT_PRECISION_FP16 = 0x02,
ZE_GRAPH_ARGUMENT_PRECISION_BF16 = 0x09,
ZE_GRAPH_ARGUMENT_PRECISION_UINT64 = 0x10,
ZE_GRAPH_ARGUMENT_PRECISION_UINT32 = 0x0A,
ZE_GRAPH_ARGUMENT_PRECISION_UINT16 = 0x03,
ZE_GRAPH_ARGUMENT_PRECISION_UINT8 = 0x04,
ZE_GRAPH_ARGUMENT_PRECISION_UINT4 = 0x0B,
ZE_GRAPH_ARGUMENT_PRECISION_INT64 = 0x011,
ZE_GRAPH_ARGUMENT_PRECISION_INT32 = 0x05,
ZE_GRAPH_ARGUMENT_PRECISION_INT16 = 0x06,
ZE_GRAPH_ARGUMENT_PRECISION_INT8 = 0x07,
ZE_GRAPH_ARGUMENT_PRECISION_INT4 = 0x0C,
ZE_GRAPH_ARGUMENT_PRECISION_BIN = 0x08,
ZE_GRAPH_ARGUMENT_PRECISION_DYNAMIC = 0x0D,
ZE_GRAPH_ARGUMENT_PRECISION_BOOLEAN = 0x0E,
} ze_graph_argument_precision_t;
///////////////////////////////////////////////////////////////////////////////
/// @brief Graph argument properties
typedef enum _ze_graph_argument_layout_t
{
ZE_GRAPH_ARGUMENT_LAYOUT_ANY = 0x00,
ZE_GRAPH_ARGUMENT_LAYOUT_NCHW,
ZE_GRAPH_ARGUMENT_LAYOUT_NHWC,
ZE_GRAPH_ARGUMENT_LAYOUT_NCDHW,
ZE_GRAPH_ARGUMENT_LAYOUT_NDHWC,
ZE_GRAPH_ARGUMENT_LAYOUT_OIHW = 0x40,
ZE_GRAPH_ARGUMENT_LAYOUT_C = 0x60,
ZE_GRAPH_ARGUMENT_LAYOUT_CHW = 0x80,
ZE_GRAPH_ARGUMENT_LAYOUT_HW = 0xC0,
ZE_GRAPH_ARGUMENT_LAYOUT_NC,
ZE_GRAPH_ARGUMENT_LAYOUT_CN,
ZE_GRAPH_ARGUMENT_LAYOUT_BLOCKED = 0xC8
} ze_graph_argument_layout_t;
///////////////////////////////////////////////////////////////////////////////
/// @brief Activation Shave Desc (passed through ze_graph_desc pNext)
typedef struct _ze_activation_kernel_desc_t
{
ze_structure_type_graph_ext_t stype; ///< [in] type of this structure
void* pNext; ///< [in,out][optional] must be null or a pointer to an extension-specific
size_t kernelDataSize; ///< [in] Size of kernel data buffer in bytes
const uint8_t* pKernelData; ///< [in] Pointer to kernel data buffer
} ze_activation_kernel_desc_t;
///////////////////////////////////////////////////////////////////////////////
/// @brief Graph descriptor
typedef struct _ze_graph_desc_t
{
ze_structure_type_graph_ext_t stype; ///< [in] type of this structure
void* pNext; ///< [in,out][optional] must be null or a pointer to an extension-specific
ze_graph_format_t format; ///< [in] Graph format passed in with input
size_t inputSize; ///< [in] Size of input buffer in bytes
const uint8_t* pInput; ///< [in] Pointer to input buffer
const char* pBuildFlags; ///< [in][optional] Null terminated string containing build flags. Options:
///< - '--inputs_precisions="<arg>:<precision> <arg2>:<precision> ..."'
///< '--outputs_precisions="<arg>:<precision> <arg2>:<precision> ..."'
///< - Set input and output arguments precision. Supported precisions:
///< FP64, FP32, FP16, BF16, U64, U32, U16, U8, U4, I64, I32, I16, I8, I4, BIN
///< - '--inputs_layouts="<arg>:<layout> <arg2>:<layout> ..."'
///< '--outputs_layouts="<arg>:<layout> <arg2>:<layout> ..."'
///< - Set input and output arguments layout. Supported layouts:
///< NCHW, NHWC, NCDHW, NDHWC, OIHW, C, CHW, HW, NC, CN
///< - '--config PARAM="VALUE" PARAM2="VALUE" ...'
///< - compile options string passed directly to compiler
} ze_graph_desc_t;
///////////////////////////////////////////////////////////////////////////////
/// @brief Example ze_graph_desc pBuildFlags
///
/// --inputs_precisions="in1:U8" --inputs_layouts="in1:NCHW" --outputs_precisions="out1:FP16 out2:FP16" --outputs_layouts="out1:NCHW out2:NCHW" --config PERFORMANCE_HINT="THROUGHPUT"
///
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// @brief Graph properties
typedef struct _ze_graph_properties_t
{
ze_structure_type_graph_ext_t stype; ///< [in] type of this structure
void* pNext; ///< [in,out][optional] must be null or a pointer to an extension-specific
uint32_t numGraphArgs; ///< [out] number of graph arguments
} ze_graph_properties_t;
///////////////////////////////////////////////////////////////////////////////
/// @brief Graph argument properties
typedef enum _ze_graph_argument_type_t
{
ZE_GRAPH_ARGUMENT_TYPE_INPUT,
ZE_GRAPH_ARGUMENT_TYPE_OUTPUT
} ze_graph_argument_type_t;
///////////////////////////////////////////////////////////////////////////////
#ifndef ZE_MAX_GRAPH_ARGUMENT_NAME
/// @brief Maximum device name string size
#define ZE_MAX_GRAPH_ARGUMENT_NAME 256
#endif // ZE_MAX_GRAPH_ARGUMENT_NAME
///////////////////////////////////////////////////////////////////////////////
#ifndef ZE_MAX_GRAPH_ARGUMENT_DIMENSIONS_SIZE
/// @brief Maximum device name string size
#define ZE_MAX_GRAPH_ARGUMENT_DIMENSIONS_SIZE 5
#endif // ZE_MAX_GRAPH_ARGUMENT_SIZE
///////////////////////////////////////////////////////////////////////////////
/// @brief Graph argument properties
typedef struct _ze_graph_argument_properties_t
{
ze_structure_type_graph_ext_t stype; ///< [in] type of this structure
void* pNext; ///< [in,out][optional] must be null or a pointer to an extension-specific
char name[ZE_MAX_GRAPH_ARGUMENT_NAME]; ///< [out] name from input IR
ze_graph_argument_type_t type; ///< [out] type of graph argument
uint32_t dims[ZE_MAX_GRAPH_ARGUMENT_DIMENSIONS_SIZE]; ///< [out] tensor dimensions upto 5D
ze_graph_argument_precision_t networkPrecision; ///< [out] precision from input IR
ze_graph_argument_layout_t networkLayout; ///< [out] layout from input IR
ze_graph_argument_precision_t devicePrecision; ///< [out] precision from compiled executable
ze_graph_argument_layout_t deviceLayout; ///< [out] layout from compiled executable
} ze_graph_argument_properties_t;
///////////////////////////////////////////////////////////////////////////////
typedef ze_result_t (ZE_APICALL *ze_pfnDeviceGetGraphProperties_ext_t)(
ze_device_handle_t hDevice, ///< [in] handle of the device
ze_device_graph_properties_t *pDeviceGraphProperties ///< [out] query result for graph properties of the device
);
///////////////////////////////////////////////////////////////////////////////
typedef ze_result_t (ZE_APICALL *ze_pfnGraphCreate_ext_t)(
ze_context_handle_t hContext, ///< [in] handle of the context
ze_device_handle_t hDevice, ///< [in] handle of the device
const ze_graph_desc_t* desc, ///< [in] pointer to graph descriptor
ze_graph_handle_t* phGraph ///< [out] pointer to handle of graph object created
);
///////////////////////////////////////////////////////////////////////////////
typedef ze_result_t (ZE_APICALL *ze_pfnGraphDestroy_ext_t)(
ze_graph_handle_t hGraph ///< [in][release] handle of graph object to destroy
);
//////////////////////////////////////////////////////////////////////////////
typedef ze_result_t (ZE_APICALL *ze_pfnGraphGetNativeBinary_ext_t)(
ze_graph_handle_t hGraph, ///< [in] handle of the graph object
size_t* pSize, ///< [in,out] size of native binary in bytes.
uint8_t* pGraphNativeBinary ///< [in,out][optional] byte pointer to native binary
);
///////////////////////////////////////////////////////////////////////////////
typedef ze_result_t (ZE_APICALL *ze_pfnGraphGetProperties_ext_t)(
ze_graph_handle_t hGraph, ///< [in] handle of the graph object
ze_graph_properties_t* pGraphProperties ///< [in,out] query result for graph properties.
);
///////////////////////////////////////////////////////////////////////////////
typedef ze_result_t (ZE_APICALL *ze_pfnGraphGetArgumentProperties_ext_t)(
ze_graph_handle_t hGraph, ///< [in] handle of the graph object
uint32_t argIndex, ///< [in] index of the argument to get properties
ze_graph_argument_properties_t* pGraphArgumentProperties ///< [in,out] query result for graph argument properties.
);
///////////////////////////////////////////////////////////////////////////////
typedef ze_result_t (ZE_APICALL *ze_pfnGraphSetArgumentValue_ext_t)(
ze_graph_handle_t hGraph, ///< [in] handle of the graph object
uint32_t argIndex, ///< [in] index of the argument
const void* pArgValue ///< [in] value to bind to the index
);
///////////////////////////////////////////////////////////////////////////////
typedef ze_result_t (ZE_APICALL *ze_pfnAppendGraphInitialize_ext_t)(
ze_command_list_handle_t hCommandList, ///< [in] handle of the command list
ze_graph_handle_t hGraph, ///< [in] handle of the graph
ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion
uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching
ze_event_handle_t* phWaitEvents ///< [in][optional] handle of the events to wait on before launching
);
///////////////////////////////////////////////////////////////////////////////
typedef ze_result_t (ZE_APICALL *ze_pfnAppendGraphExecute_ext_t)(
ze_command_list_handle_t hCommandList, ///< [in] handle of the command list
ze_graph_handle_t hGraph, ///< [in] handle of the graph
ze_graph_profiling_query_handle_t hProfilingQuery, ///< [in][optional] handle of profiling query
ze_event_handle_t hSignalEvent, ///< [in][optional] handle of the event to signal on completion
uint32_t numWaitEvents, ///< [in][optional] number of events to wait on before launching
ze_event_handle_t* phWaitEvents ///< [in][optional] handle of the events to wait on before launching
);
///////////////////////////////////////////////////////////////////////////////
/// @brief Extension version 1.1
///////////////////////////////////////////////////////////////////////////////
#ifndef ZE_MAX_GRAPH_TENSOR_REF_DIMS
/// @brief Maximum tensor reference dimensions size
#define ZE_MAX_GRAPH_TENSOR_REF_DIMS 8
#endif // ZE_MAX_GRAPH_TENSOR_REF_DIMS
///////////////////////////////////////////////////////////////////////////////
#ifndef ZE_MAX_GRAPH_TENSOR_NAMES_SIZE
/// @brief Maximum tensor names size
#define ZE_MAX_GRAPH_TENSOR_NAMES_SIZE 32
#endif // ZE_MAX_GRAPH_TENSOR_NAMES_SIZE
///////////////////////////////////////////////////////////////////////////////
/// @brief Graph argument properties
typedef enum _ze_graph_metadata_type
{
ZE_GRAPH_METADATA_TYPE_UNDEFINED = 0,
ZE_GRAPH_METADATA_TYPE_DYNAMIC = 1,
ZE_GRAPH_METADATA_TYPE_BOOLEAN = 2,
ZE_GRAPH_METADATA_TYPE_BF16 = 3,
ZE_GRAPH_METADATA_TYPE_F16 = 4,
ZE_GRAPH_METADATA_TYPE_F32 = 5,
ZE_GRAPH_METADATA_TYPE_F64 = 6,
ZE_GRAPH_METADATA_TYPE_I4 = 7,
ZE_GRAPH_METADATA_TYPE_I8 = 8,
ZE_GRAPH_METADATA_TYPE_I16 = 9,
ZE_GRAPH_METADATA_TYPE_I32 = 10,
ZE_GRAPH_METADATA_TYPE_I64 = 11,
ZE_GRAPH_METADATA_TYPE_U1 = 12,
ZE_GRAPH_METADATA_TYPE_U4 = 13,
ZE_GRAPH_METADATA_TYPE_U8 = 14,
ZE_GRAPH_METADATA_TYPE_U16 = 15,
ZE_GRAPH_METADATA_TYPE_U32 = 16,
ZE_GRAPH_METADATA_TYPE_U64 = 17
} ze_graph_metadata_type;
///////////////////////////////////////////////////////////////////////////////
/// @brief Graph argument metadata
typedef struct _ze_graph_argument_metadata_t
{
ze_structure_type_graph_ext_t stype; ///< [in] type of this structure
void* pNext; ///< [in,out][optional] must be null or a pointer to an extension-specific
ze_graph_argument_type_t type; ///< [out] type of argument
char friendly_name[ZE_MAX_GRAPH_ARGUMENT_NAME]; ///< [out] friendly name
ze_graph_metadata_type data_type; ///< [out] data type of argument
uint64_t shape[ZE_MAX_GRAPH_TENSOR_REF_DIMS]; ///< [out] tensor shape
uint32_t shape_size; ///< [out] size of shape array
char tensor_names[ZE_MAX_GRAPH_TENSOR_NAMES_SIZE][ZE_MAX_GRAPH_ARGUMENT_NAME]; ///< [out] tensor name array
uint32_t tensor_names_count; ///< [out] size of tensor name array
char input_name[ZE_MAX_GRAPH_ARGUMENT_NAME]; ///< [out] input name
} ze_graph_argument_metadata_t;
///////////////////////////////////////////////////////////////////////////////
typedef struct _ze_graph_argument_properties_2_t
{
ze_structure_type_graph_ext_t stype; ///< [in] type of this structure
void* pNext; ///< [in,out][optional] must be null or a pointer to an extension-specific
char name[ZE_MAX_GRAPH_ARGUMENT_NAME]; ///< [out] name from input IR
ze_graph_argument_type_t type; ///< [out] type of graph argument
uint32_t dims[ZE_MAX_GRAPH_ARGUMENT_DIMENSIONS_SIZE]; ///< [out] tensor dimensions upto 5D
ze_graph_argument_precision_t networkPrecision; ///< [out] precision from input IR
ze_graph_argument_layout_t networkLayout; ///< [out] layout from input IR
ze_graph_argument_precision_t devicePrecision; ///< [out] precision from compiled executable
ze_graph_argument_layout_t deviceLayout; ///< [out] layout from compiled executable
// version 2
float quantReverseScale; ///< [out] Quantized tensor reverse scale value for input argument
uint8_t quantZeroPoint; ///< [out] Quantized tesnor zero point value for input argument
} ze_graph_argument_properties_2_t;
///////////////////////////////////////////////////////////////////////////////
typedef ze_result_t (ZE_APICALL *ze_pfnGraphGetArgumentProperties_ext_2_t)(
ze_graph_handle_t hGraph, ///< [in] handle of the graph object
uint32_t argIndex, ///< [in] index of the argument to get properties
ze_graph_argument_properties_2_t* pGraphArgumentProperties ///< [in,out] query result for graph argument properties.
);
///////////////////////////////////////////////////////////////////////////////
typedef ze_result_t (ZE_APICALL *ze_pfnGraphGetArgumentMetadata_ext_t)(
ze_graph_handle_t hGraph, ///< [in] handle of the graph object
uint32_t argIndex, ///< [in] index of the argument to get metadata
ze_graph_argument_metadata_t* pGraphArgumentMetadata ///< [in,out] query result for graph argument metadata
);
///////////////////////////////////////////////////////////////////////////////
/// @brief Extension version 1.2
///////////////////////////////////////////////////////////////////////////////
typedef struct _ze_graph_argument_properties_3_t
{
ze_structure_type_graph_ext_t stype; ///< [in] type of this structure
void* pNext; ///< [in,out][optional] must be null or a pointer to an extension-specific
char name[ZE_MAX_GRAPH_ARGUMENT_NAME]; ///< [out] name from input IR
ze_graph_argument_type_t type; ///< [out] type of graph argument
uint32_t dims[ZE_MAX_GRAPH_ARGUMENT_DIMENSIONS_SIZE]; ///< [out] tensor dimensions upto 5D
ze_graph_argument_precision_t networkPrecision; ///< [out] precision from input IR
ze_graph_argument_layout_t networkLayout; ///< [out] layout from input IR
ze_graph_argument_precision_t devicePrecision; ///< [out] precision from compiled executable
ze_graph_argument_layout_t deviceLayout; ///< [out] layout from compiled executable
// version 2
float quantReverseScale; ///< [out] Quantized tensor reverse scale value for input argument
uint8_t quantZeroPoint; ///< [out] Quantized tesnor zero point value for input argument
// version 3
uint32_t dims_count; ///< [out] size of shape array
char debug_friendly_name[ZE_MAX_GRAPH_ARGUMENT_NAME]; ///< [out] debug friendly name
char associated_tensor_names[ZE_MAX_GRAPH_TENSOR_NAMES_SIZE][ZE_MAX_GRAPH_ARGUMENT_NAME]; ///< [out] tensor name array
uint32_t associated_tensor_names_count; ///< [out] size of tensor name array
} ze_graph_argument_properties_3_t;
///////////////////////////////////////////////////////////////////////////////
typedef ze_result_t (ZE_APICALL *ze_pfnGraphGetArgumentProperties_ext_3_t)(
ze_graph_handle_t hGraph, ///< [in] handle of the graph object
uint32_t argIndex, ///< [in] index of the argument to get properties
ze_graph_argument_properties_3_t* pGraphArgumentProperties ///< [in,out] query result for graph argument properties.
);
///////////////////////////////////////////////////////////////////////////////
/// @brief Extension version 1.3
///////////////////////////////////////////////////////////////////////////////
/// @brief Handle of driver's graph query network object
typedef struct _ze_graph_query_network_handle_t *ze_graph_query_network_handle_t;
typedef ze_result_t (ZE_APICALL *ze_pfnGraphQueryNetworkCreate_ext_t)(
ze_context_handle_t hContext, ///< [in] handle of the context object
ze_device_handle_t hDevice, ///< [in] handle of the device
const ze_graph_desc_t* desc, ///< [in] pointer to graph descriptor
ze_graph_query_network_handle_t* phGraphQueryNetwork ///< [out] pointer to handle of graph query network object created
);
typedef ze_result_t (ZE_APICALL *ze_pfnGraphQueryNetworkDestroy_ext_t)(
ze_graph_query_network_handle_t hGraphQueryNetwork ///< [in][release] handle of the graph query network
);
typedef ze_result_t (ZE_APICALL *ze_pfnGraphQueryNetworkGetSupportedLayers_ext_t)(
ze_graph_query_network_handle_t hGraphQueryNetwork, ///< [in] handle of the graph query network
size_t *pSize, ///< [in,out] size of supported layers string
char *pSupportedLayers ///< [in,out][optional] pointer to null-terminated string of the supported layers
);
///////////////////////////////////////////////////////////////////////////////
/// @brief Extension version 1.4
///////////////////////////////////////////////////////////////////////////////
typedef ze_result_t (ZE_APICALL *ze_pfnGraphBuildLogGetString_ext_t)(
ze_graph_handle_t hGraph, ///< [in] handle of the graph object
uint32_t* pSize, ///< [in,out] pointer to the size of the error message
char* pBuildLog ///< [in] pointer to buffer to return error message
);
///////////////////////////////////////////////////////////////////////////////
/// @brief Extension version 1.5
///////////////////////////////////////////////////////////////////////////////
/// @brief Bitfield of graph flags
typedef enum _ze_graph_flags_t
{
ZE_GRAPH_FLAG_NONE = 0x0,
ZE_GRAPH_FLAG_DISABLE_CACHING = 0x1, ///< Disable driver managed caching
ZE_GRAPH_FLAG_ENABLE_PROFILING = 0x2, ///< Enable layer and task level timings
} ze_graph_flags_t;
///////////////////////////////////////////////////////////////////////////////
/// @brief Graph descriptor
typedef struct _ze_graph_desc_2_t
{
ze_structure_type_graph_ext_t stype; ///< [in] type of this structure
void* pNext; ///< [in,out][optional] must be null or a pointer to an extension-specific
ze_graph_format_t format; ///< [in] Graph format passed in with input
size_t inputSize; ///< [in] Size of input buffer in bytes
const uint8_t* pInput; ///< [in] Pointer to input buffer
const char* pBuildFlags; ///< [in][optional] Null terminated string containing build flags. Options:
///< - '--inputs_precisions="<arg>:<precision> <arg2>:<precision> ..."'
///< '--outputs_precisions="<arg>:<precision> <arg2>:<precision> ..."'
///< - Set input and output arguments precision. Supported precisions:
///< FP64, FP32, FP16, BF16, U64, U32, U16, U8, U4, I64, I32, I16, I8, I4, BIN
///< - '--inputs_layouts="<arg>:<layout> <arg2>:<layout> ..."'
///< '--outputs_layouts="<arg>:<layout> <arg2>:<layout> ..."'
///< - Set input and output arguments layout. Supported layouts:
///< NCHW, NHWC, NCDHW, NDHWC, OIHW, C, CHW, HW, NC, CN
///< - '--config PARAM="VALUE" PARAM2="VALUE" ...'
///< - compile options string passed directly to compiler
uint32_t flags; ///< [in][optional] Graph creation flags
} ze_graph_desc_2_t;
///////////////////////////////////////////////////////////////////////////////
typedef ze_result_t (ZE_APICALL *ze_pfnGraphCreate_ext_2_t)(
ze_context_handle_t hContext, ///< [in] handle of the context
ze_device_handle_t hDevice, ///< [in] handle of the device
const ze_graph_desc_2_t* desc, ///< [in] pointer to graph descriptor
ze_graph_handle_t* phGraph ///< [out] pointer to handle of graph object created
);
typedef ze_result_t (ZE_APICALL *ze_pfnGraphQueryNetworkCreate_ext_2_t)(
ze_context_handle_t hContext, ///< [in] handle of the context object
ze_device_handle_t hDevice, ///< [in] handle of the device
const ze_graph_desc_2_t* desc, ///< [in] pointer to graph descriptor
ze_graph_query_network_handle_t* phGraphQueryNetwork ///< [out] pointer to handle of graph query network object created
);
///////////////////////////////////////////////////////////////////////////////
/// @brief Graph memory query types
typedef enum _ze_graph_memory_query_type_t
{
ZE_GRAPH_QUERY_MEMORY_DDR = 0x01, ///< DDR memory allocations
} ze_graph_memory_query_type_t;
///////////////////////////////////////////////////////////////////////////////
/// @brief Graph memory query
typedef struct _ze_graph_memory_query_t
{
uint64_t total; ///< total memory allowed per process for specified type (reported in bytes)
uint64_t allocated; ///< context's current total memory allocated for specified type (reported in bytes)
} ze_graph_memory_query_t;
///////////////////////////////////////////////////////////////////////////////
typedef ze_result_t (ZE_APICALL *ze_pfnGraphQueryContextMemory_ext_t)(
ze_context_handle_t hContext, ///< [in] handle of the context object
ze_graph_memory_query_type_t type, ///< [in] type of memory query
ze_graph_memory_query_t* query ///< [out] result of query
);
///////////////////////////////////////////////////////////////////////////////
/// @brief Extension version 1.6
///////////////////////////////////////////////////////////////////////////////
/// @brief Graph version information
typedef struct _ze_graph_version_info_t
{
uint32_t major;
uint32_t minor;
uint32_t patch;
} ze_graph_version_info_t;
///////////////////////////////////////////////////////////////////////////////
/// @brief Device graph properties
typedef struct _ze_device_graph_properties_2_t
{
ze_structure_type_graph_ext_t stype; ///< [in] type of this structure
void* pNext; ///< [in,out][optional] must be null or a pointer to an extension-specific
ze_graph_ext_version_t graphExtensionVersion; ///< [out] graph extension version
ze_graph_compiler_version_info_t compilerVersion; ///< [out] compiler version
ze_graph_format_t graphFormatsSupported; ///< [out] graph formats supported
uint32_t maxOVOpsetVersionSupported; ///< [out] max OV opset version supported by the compiler
ze_graph_version_info_t elfVersion; ///< [out] elf container version
ze_graph_version_info_t runtimeVersion; ///< [out] firmware runtime version
} ze_device_graph_properties_2_t;
///////////////////////////////////////////////////////////////////////////////
typedef ze_result_t (ZE_APICALL *ze_pfnDeviceGetGraphProperties_ext_2_t)(
ze_device_handle_t hDevice, ///< [in] handle of the device
ze_device_graph_properties_2_t *pDeviceGraphProperties ///< [out] query result for graph properties of the device
);
///////////////////////////////////////////////////////////////////////////////
/// @brief Extension version 1.7
///////////////////////////////////////////////////////////////////////////////
typedef ze_result_t (ZE_APICALL *ze_pfnGraphGetNativeBinary_ext_2_t)(
ze_graph_handle_t hGraph, ///< [in] handle of the graph object
size_t* pSize, ///< [out] size of native binary in bytes
const uint8_t** pGraphNativeBinary ///< [out] double pointer to view of native binary, driver owns the memory
);
///////////////////////////////////////////////////////////////////////////////
/// @brief Extension version 1.8
///////////////////////////////////////////////////////////////////////////////
/// @brief Stage required to initialize the graph
typedef enum _ze_graph_init_stage_t
{
ZE_GRAPH_STAGE_COMMAND_LIST_INITIALIZE = 0x1, ///< Call to pfnAppendGraphInitialize is required
ZE_GRAPH_STAGE_INITIALIZE = 0x2, ///< Call to pfnGraphInitialize is required
ZE_GRAPH_STAGE_FORCE_UINT32 = 0x7fffffff
} ze_graph_init_stage_t;
///////////////////////////////////////////////////////////////////////////////
/// @brief Graph properties
typedef struct _ze_graph_properties_2_t
{
ze_structure_type_graph_ext_t stype; ///< [in] type of this structure
void* pNext; ///< [in,out][optional] must be null or a pointer to an extension-specific
uint32_t numGraphArgs; ///< [out] number of graph arguments
ze_graph_init_stage_t initStageRequired; ///< [out] stage required to initialize the graph
} ze_graph_properties_2_t;
///////////////////////////////////////////////////////////////////////////////
typedef ze_result_t (ZE_APICALL *ze_pfnGraphGetProperties_ext_2_t)(
ze_graph_handle_t hGraph, ///< [in] handle of the graph object
ze_graph_properties_2_t* pGraphProperties ///< [in,out] query result for graph properties
);
///////////////////////////////////////////////////////////////////////////////
typedef ze_result_t (ZE_APICALL *ze_pfnGraphInitialize_ext_t)(
ze_graph_handle_t hGraph ///< [in] handle of the graph
);
///////////////////////////////////////////////////////////////////////////////
/// @brief Extension version 1.9
// Version 1.9 ze_graph_memory_query_t reports values in bytes on Linux and Windows (previously reported in KB on Windows)
///////////////////////////////////////////////////////////////////////////////
/// @brief Table of Graph functions pointers
typedef struct _ze_graph_dditable_ext_t
{
// version 1.0
ze_pfnGraphCreate_ext_t pfnCreate;
ze_pfnGraphDestroy_ext_t pfnDestroy;
ze_pfnGraphGetProperties_ext_t pfnGetProperties;
ze_pfnGraphGetArgumentProperties_ext_t pfnGetArgumentProperties;
ze_pfnGraphSetArgumentValue_ext_t pfnSetArgumentValue;
ze_pfnAppendGraphInitialize_ext_t pfnAppendGraphInitialize;
ze_pfnAppendGraphExecute_ext_t pfnAppendGraphExecute;
ze_pfnGraphGetNativeBinary_ext_t pfnGetNativeBinary;
ze_pfnDeviceGetGraphProperties_ext_t pfnDeviceGetGraphProperties;
// version 1.1
ze_pfnGraphGetArgumentMetadata_ext_t pfnGraphGetArgumentMetadata;
ze_pfnGraphGetArgumentProperties_ext_2_t pfnGetArgumentProperties2;
// version 1.2
ze_pfnGraphGetArgumentProperties_ext_3_t pfnGetArgumentProperties3;
// version 1.3
ze_pfnGraphQueryNetworkCreate_ext_t pfnQueryNetworkCreate;
ze_pfnGraphQueryNetworkDestroy_ext_t pfnQueryNetworkDestroy;
ze_pfnGraphQueryNetworkGetSupportedLayers_ext_t pfnQueryNetworkGetSupportedLayers;
// version 1.4
ze_pfnGraphBuildLogGetString_ext_t pfnBuildLogGetString;
// version 1.5
ze_pfnGraphCreate_ext_2_t pfnCreate2;
ze_pfnGraphQueryNetworkCreate_ext_2_t pfnQueryNetworkCreate2;
ze_pfnGraphQueryContextMemory_ext_t pfnQueryContextMemory;
// version 1.6
ze_pfnDeviceGetGraphProperties_ext_2_t pfnDeviceGetGraphProperties2;
// version 1.7
ze_pfnGraphGetNativeBinary_ext_2_t pfnGetNativeBinary2;
// version 1.8
ze_pfnGraphGetProperties_ext_2_t pfnGetProperties2;
ze_pfnGraphInitialize_ext_t pfnGraphInitialize;
} ze_graph_dditable_ext_t;
///////////////////////////////////////////////////////////////////////////////
/// @brief Mutable command lists NPU specific flags and structures
typedef enum _ze_mutable_command_npu_exp_flag_t
{
ZE_MUTABLE_COMMAND_EXP_FLAG_GRAPH_ARGUMENT = ZE_BIT(6), ///< graph argument
ZE_MUTABLE_COMMAND_EXP_FLAG_GRAPH_PROFILING_QUERY = ZE_BIT(7), ///< graph profiling query
} ze_mutable_command_npu_exp_flag_t;
///////////////////////////////////////////////////////////////////////////////
/// @brief Mutable graph profiling query descriptor
typedef struct _ze_mutable_graph_profiling_query_exp_desc_t
{
ze_structure_type_graph_ext_t stype; ///< [in] type of this structure
const void* pNext; ///< [in][optional] must be null or a pointer to an extension-specific
///< structure (i.e. contains stype and pNext).
uint64_t commandId; ///< [in] command identifier
ze_graph_profiling_query_handle_t hProfilingQuery; ///< [in] handle of profiling query
} ze_mutable_graph_profiling_query_exp_desc_t;
#if defined(__cplusplus)
} // extern "C"
#endif
#endif // _ZE_GRAPH_EXT_H