Исходный код СУБД RuDB — свободной СУБД с открытым исходным кодом на базе PostgreSQL
rudb
3 days ago bd039d1e92813358c5c5a1e346b49074baf513f2
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
 
#include "core/session/onnxruntime_cxx_api.h"
#include <vector>
 
#ifdef USE_CUDA
#include <cuda_runtime.h>
#endif
 
struct MyCustomKernel {
  MyCustomKernel(const OrtApi& ort_api, const OrtKernelInfo* info);
  void Compute(OrtKernelContext* context);
 
 private:
  const OrtApi& ort_;
};
 
struct MyCustomKernelSecondInputOnCpu {
  MyCustomKernelSecondInputOnCpu(const OrtKernelInfo* /*info*/, void* compute_stream)
      : compute_stream_(compute_stream) {
  }
 
  void Compute(OrtKernelContext* context);
 
 private:
  void* compute_stream_;
};
 
struct MyCustomOp : Ort::CustomOpBase<MyCustomOp, MyCustomKernel> {
  explicit MyCustomOp(const char* provider) : provider_(provider) {}
  void* CreateKernel(const OrtApi& api, const OrtKernelInfo* info) const { return new MyCustomKernel(api, info); };
  const char* GetName() const { return "Foo"; };
  const char* GetExecutionProviderType() const { return provider_; };
 
  size_t GetInputTypeCount() const { return 2; };
  ONNXTensorElementDataType GetInputType(size_t /*index*/) const {
    // Both the inputs need to be necessarily of float type
    return ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT;
  };
 
  size_t GetOutputTypeCount() const { return 1; };
  ONNXTensorElementDataType GetOutputType(size_t /*index*/) const { return ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT; };
 
 private:
  const char* provider_{"CPUExecutionProvider"};
};
 
struct MyCustomOpSecondInputOnCpu : Ort::CustomOpBase<MyCustomOpSecondInputOnCpu, MyCustomKernelSecondInputOnCpu> {
  explicit MyCustomOpSecondInputOnCpu(const char* provider, void* compute_stream)
      : provider_(provider), compute_stream_(compute_stream) {}
 
  void* CreateKernel(const OrtApi& /* api */, const OrtKernelInfo* info) const {
    return new MyCustomKernelSecondInputOnCpu(info, compute_stream_);
  };
 
  const char* GetName() const { return "Foo"; };
  const char* GetExecutionProviderType() const { return provider_; };
 
  size_t GetInputTypeCount() const { return 2; };
  ONNXTensorElementDataType GetInputType(size_t /*index*/) const {
    // Both the inputs need to be necessarily of float type
    return ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT;
  };
 
  OrtMemType GetInputMemoryType(size_t i) const {
    if (i == 1) {
      return OrtMemTypeCPUInput;
    }
    return OrtMemTypeDefault;
  };
 
  size_t GetOutputTypeCount() const { return 1; };
  ONNXTensorElementDataType GetOutputType(size_t /*index*/) const { return ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT; };
 
 private:
  const char* provider_{"CUDAExecutionProvider"};
  void* compute_stream_;
};
 
struct MyCustomKernelMultipleDynamicInputs {
  MyCustomKernelMultipleDynamicInputs(const OrtApi& ort_api, const OrtKernelInfo* /*info*/)
      : ort_(ort_api) {
  }
 
  void Compute(OrtKernelContext* context);
 
 private:
  const OrtApi& ort_;
};
 
struct MyCustomOpMultipleDynamicInputs : Ort::CustomOpBase<MyCustomOpMultipleDynamicInputs,
                                                           MyCustomKernelMultipleDynamicInputs> {
  explicit MyCustomOpMultipleDynamicInputs(const char* provider) : provider_(provider) {}
  void* CreateKernel(const OrtApi& api, const OrtKernelInfo* info) const {
    return new MyCustomKernelMultipleDynamicInputs(api, info);
  };
  const char* GetName() const { return "Foo"; };
  const char* GetExecutionProviderType() const { return provider_; };
 
  size_t GetInputTypeCount() const { return 2; };
  ONNXTensorElementDataType GetInputType(size_t /*index*/) const {
    // Both the inputs are dynamic typed (i.e.) they can be any type and need not be
    // homogeneous
    return ONNX_TENSOR_ELEMENT_DATA_TYPE_UNDEFINED;
  };
 
  size_t GetOutputTypeCount() const { return 1; };
  ONNXTensorElementDataType GetOutputType(size_t /*index*/) const { return ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT; };
 
 private:
  const char* provider_;
};
 
struct MyCustomKernelWithOptionalInput {
  MyCustomKernelWithOptionalInput(const OrtKernelInfo* /*info*/) {
  }
  void Compute(OrtKernelContext* context);
};
 
struct MyCustomOpWithOptionalInput : Ort::CustomOpBase<MyCustomOpWithOptionalInput, MyCustomKernelWithOptionalInput> {
  explicit MyCustomOpWithOptionalInput(const char* provider) : provider_(provider) {}
 
  void* CreateKernel(const OrtApi& /* api */, const OrtKernelInfo* info) const {
    return new MyCustomKernelWithOptionalInput(info);
  };
 
  const char* GetName() const { return "FooBar"; };
  const char* GetExecutionProviderType() const { return provider_; };
 
  size_t GetInputTypeCount() const { return 3; };
  ONNXTensorElementDataType GetInputType(size_t /*index*/) const { return ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT; };
  OrtCustomOpInputOutputCharacteristic GetInputCharacteristic(size_t index) const {
    // The second input (index == 1) is optional
    if (index == 1)
      return OrtCustomOpInputOutputCharacteristic::INPUT_OUTPUT_OPTIONAL;
 
    return OrtCustomOpInputOutputCharacteristic::INPUT_OUTPUT_REQUIRED;
  }
 
  size_t GetOutputTypeCount() const { return 1; };
  ONNXTensorElementDataType GetOutputType(size_t /*index*/) const { return ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT; };
  OrtCustomOpInputOutputCharacteristic GetOutputCharacteristic(size_t /*index*/) const {
    return OrtCustomOpInputOutputCharacteristic::INPUT_OUTPUT_REQUIRED;
  }
 
 private:
  const char* provider_;
};
 
// Custom kernel that outputs the lengths of all input strings.
struct MyCustomStringLengthsKernel {
  explicit MyCustomStringLengthsKernel(const OrtKernelInfo* /* info */) {}
 
  void Compute(OrtKernelContext* context);
};
 
// Utility function to be used when testing with MyCustomStringLengthsKernel.
// Creates an input tensor from the provided input string and adds it to `ort_inputs`.
// Also initializes the corresponding expected output and I/O names.
void AddInputForCustomStringLengthsKernel(std::string input_str, OrtAllocator* allocator,
                                          std::vector<Ort::Value>& ort_inputs, std::vector<std::string>& input_names,
                                          std::vector<std::string>& output_names,
                                          std::vector<std::vector<int64_t>>& expected_dims,
                                          std::vector<std::vector<int64_t>>& expected_outputs);
 
// Custom kernel that echos input arguments (shape [1]) in reversed order.
// Used to test variadic custom ops with heterogenous input types.
struct MyCustomEchoReversedArgsKernel {
  explicit MyCustomEchoReversedArgsKernel(const OrtKernelInfo* /* info */) {}
  void Compute(OrtKernelContext* context);
};
 
// Utility custom op class that can be configured with a kernel class (T) and input/output
// configurations.
template <typename T>
struct TemplatedCustomOp : Ort::CustomOpBase<TemplatedCustomOp<T>, T> {
  TemplatedCustomOp(const char* op_name, std::vector<ONNXTensorElementDataType> input_types,
                    std::vector<OrtCustomOpInputOutputCharacteristic> input_characs, int input_min_arity,
                    bool input_homogeneity, std::vector<ONNXTensorElementDataType> output_types,
                    std::vector<OrtCustomOpInputOutputCharacteristic> output_characs, int output_min_arity,
                    bool output_homogeneity)
      : op_name_(op_name),
        input_types_(std::move(input_types)),
        input_characs_(std::move(input_characs)),
        input_min_arity_(input_min_arity),
        input_homogeneity_(input_homogeneity),
        output_types_(std::move(output_types)),
        output_characs_(std::move(output_characs)),
        output_min_arity_(output_min_arity),
        output_homogeneity_(output_homogeneity) {}
 
  void* CreateKernel(const OrtApi& /* api */, const OrtKernelInfo* info) const {
    return new T(info);
  }
 
  const char* GetName() const noexcept { return op_name_; }
 
  size_t GetInputTypeCount() const noexcept { return input_types_.size(); }
 
  ONNXTensorElementDataType GetInputType(size_t index) const noexcept {
    return input_types_[index];
  }
 
  OrtCustomOpInputOutputCharacteristic GetInputCharacteristic(size_t index) const noexcept {
    return input_characs_[index];
  }
 
  int GetVariadicInputMinArity() const noexcept {
    return input_min_arity_;
  }
 
  bool GetVariadicInputHomogeneity() const noexcept {
    return input_homogeneity_;
  }
 
  size_t GetOutputTypeCount() const noexcept { return output_types_.size(); }
 
  ONNXTensorElementDataType GetOutputType(size_t index) const noexcept {
    return output_types_[index];
  }
 
  OrtCustomOpInputOutputCharacteristic GetOutputCharacteristic(size_t index) const noexcept {
    return output_characs_[index];
  }
 
  int GetVariadicOutputMinArity() const noexcept {
    return output_min_arity_;
  }
 
  bool GetVariadicOutputHomogeneity() const noexcept {
    return output_homogeneity_;
  }
 
 private:
  const char* op_name_;
 
  std::vector<ONNXTensorElementDataType> input_types_;
  std::vector<OrtCustomOpInputOutputCharacteristic> input_characs_;
  int input_min_arity_;
  bool input_homogeneity_;
 
  std::vector<ONNXTensorElementDataType> output_types_;
  std::vector<OrtCustomOpInputOutputCharacteristic> output_characs_;
  int output_min_arity_;
  bool output_homogeneity_;
};
 
struct MyCustomKernelWithAttributes {
  MyCustomKernelWithAttributes(const OrtKernelInfo* kernel_info) {
    Ort::ConstKernelInfo info{kernel_info};
    int_attr_ = info.GetAttribute<int64_t>("int_attr");
    float_attr_ = info.GetAttribute<float>("float_attr");
 
    ints_attr_ = info.GetAttributes<int64_t>("ints_attr");
    floats_attr_ = info.GetAttributes<float>("floats_attr");
 
    string_arr_ = info.GetAttribute<std::string>("string_attr");
  }
 
  void Compute(OrtKernelContext* context);
 
 private:
  int64_t int_attr_;
  float float_attr_;
 
  std::vector<int64_t> ints_attr_;
  std::vector<float> floats_attr_;
 
  std::string string_arr_;
};
 
struct MyCustomOpWithAttributes : Ort::CustomOpBase<MyCustomOpWithAttributes, MyCustomKernelWithAttributes> {
  explicit MyCustomOpWithAttributes(const char* provider) : provider_(provider) {}
 
  void* CreateKernel(const OrtApi&, const OrtKernelInfo* info) const {
    return new MyCustomKernelWithAttributes(info);
  };
 
  const char* GetName() const { return "FooBar_Attr"; };
  const char* GetExecutionProviderType() const { return provider_; };
 
  size_t GetInputTypeCount() const { return 1; };
  ONNXTensorElementDataType GetInputType(size_t /*index*/) const { return ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT; };
 
  size_t GetOutputTypeCount() const { return 1; };
  ONNXTensorElementDataType GetOutputType(size_t /*index*/) const { return ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT; };
 
 private:
  const char* provider_;
};
 
// Slice array of floats or doubles between [from, to) and save to output
struct SliceCustomOpKernel {
  SliceCustomOpKernel(const OrtKernelInfo* /*info*/) {
  }
 
  void Compute(OrtKernelContext* context);
};
 
struct SliceCustomOp : Ort::CustomOpBase<SliceCustomOp, SliceCustomOpKernel> {
  explicit SliceCustomOp(const char* provider) : provider_(provider) {}
  void* CreateKernel(const OrtApi&, const OrtKernelInfo* info) const {
    return new SliceCustomOpKernel(info);
  };
 
  const char* GetName() const { return "Slice"; };
  const char* GetExecutionProviderType() const { return provider_; };
 
  size_t GetInputTypeCount() const { return 3; };
  ONNXTensorElementDataType GetInputType(size_t index) const {
    if (index == 0)
      return ONNX_TENSOR_ELEMENT_DATA_TYPE_UNDEFINED;  // input array of float or double
    else if (index == 1)
      return ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64;  // slice from
 
    // index 2 (keep compiler happy on Linux)
    return ONNX_TENSOR_ELEMENT_DATA_TYPE_INT64;  // slice to
  };
 
  size_t GetOutputTypeCount() const { return 1; };
  ONNXTensorElementDataType GetOutputType(size_t /*index*/) const {
    return ONNX_TENSOR_ELEMENT_DATA_TYPE_UNDEFINED;
  }
 
 private:
  const char* provider_;
};
 
struct StandaloneCustomKernel {
  StandaloneCustomKernel(const OrtKernelInfo* info);
  ~StandaloneCustomKernel();
  void Compute(OrtKernelContext* context);
 
 private:
#if !defined(REDUCED_OPS_BUILD)
  void InitTopK();
  void InvokeTopK(OrtKernelContext* context);
 
  void InitGru();
  void InvokeGru(OrtKernelContext* context);
 
  void InitInvokeConv(OrtKernelContext* context);  // create Conv and invoke in Compute(...)
 
  Ort::Op op_topk_{nullptr};
  Ort::Op op_gru_{nullptr};
#endif
 
  Ort::KernelInfo info_copy_{nullptr};
  Ort::Op op_add_{nullptr};
};
 
struct StandaloneCustomOp : Ort::CustomOpBase<StandaloneCustomOp, StandaloneCustomKernel> {
  explicit StandaloneCustomOp(const char* provider) : provider_(provider) {}
 
  void* CreateKernel(const OrtApi&, const OrtKernelInfo* info) const { return new StandaloneCustomKernel(info); };
  const char* GetName() const { return "Foo"; };
  const char* GetExecutionProviderType() const { return provider_; };
 
  size_t GetInputTypeCount() const { return 2; };
  ONNXTensorElementDataType GetInputType(size_t /*index*/) const {
    return ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT;
  };
 
  size_t GetOutputTypeCount() const { return 1; };
  ONNXTensorElementDataType GetOutputType(size_t /*index*/) const { return ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT; };
 
 private:
  const char* provider_;
};
 
/////////////// structures to test multi-kernls-single-schema ///////////////
 
struct MulTopKernelFloat {
  MulTopKernelFloat(const OrtKernelInfo*) {};
  ~MulTopKernelFloat() = default;
  void Compute(OrtKernelContext*) {};
};
 
struct MulTopOpFloat : Ort::CustomOpBase<MulTopOpFloat, MulTopKernelFloat> {
  void* CreateKernel(const OrtApi&, const OrtKernelInfo* info) const { return new MulTopKernelFloat(info); }
  const char* GetName() const { return "MulTop"; }
  const char* GetExecutionProviderType() const { return "CPUExecutionProvider"; }
  size_t GetInputTypeCount() const { return 1; }
  ONNXTensorElementDataType GetInputType(size_t) const { return ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT; }
  size_t GetOutputTypeCount() const { return 1; }
  ONNXTensorElementDataType GetOutputType(size_t) const { return ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT; }
};
 
struct MulTopKernelInt32 {
  MulTopKernelInt32(const OrtKernelInfo*) {};
  ~MulTopKernelInt32() = default;
  void Compute(OrtKernelContext*) {};
};
 
struct MulTopOpInt32 : Ort::CustomOpBase<MulTopOpInt32, MulTopKernelInt32> {
  void* CreateKernel(const OrtApi&, const OrtKernelInfo* info) const { return new MulTopKernelInt32(info); }
  const char* GetName() const { return "MulTop"; }
  const char* GetExecutionProviderType() const { return "CPUExecutionProvider"; }
  size_t GetInputTypeCount() const { return 1; }
  ONNXTensorElementDataType GetInputType(size_t) const { return ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32; }
  size_t GetOutputTypeCount() const { return 1; }
  ONNXTensorElementDataType GetOutputType(size_t) const { return ONNX_TENSOR_ELEMENT_DATA_TYPE_INT32; }
};
 
struct MulTopKernelDouble {
  MulTopKernelDouble(const OrtKernelInfo*) {};
  ~MulTopKernelDouble() = default;
  void Compute(OrtKernelContext*) {};
};
 
// MulTopOpDouble and MulTopOpFloat has input count mismatch
struct MulTopOpDouble : Ort::CustomOpBase<MulTopOpDouble, MulTopKernelDouble> {
  void* CreateKernel(const OrtApi&, const OrtKernelInfo* info) const { return new MulTopKernelDouble(info); }
  const char* GetName() const { return "MulTop"; }
  const char* GetExecutionProviderType() const { return "CPUExecutionProvider"; }
  size_t GetInputTypeCount() const { return 2; }
  ONNXTensorElementDataType GetInputType(size_t) const { return ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE; }
  size_t GetOutputTypeCount() const { return 1; }
  ONNXTensorElementDataType GetOutputType(size_t) const { return ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE; }
};
 
struct MulTopKernelInt16 {
  MulTopKernelInt16(const OrtKernelInfo*) {};
  ~MulTopKernelInt16() = default;
  void Compute(OrtKernelContext*) {};
};
 
// MulTopOpInt16 and MulTopOpFloat has output count mismatch
struct MulTopOpInt16 : Ort::CustomOpBase<MulTopOpInt16, MulTopKernelInt16> {
  void* CreateKernel(const OrtApi&, const OrtKernelInfo* info) const { return new MulTopKernelInt16(info); }
  const char* GetName() const { return "MulTop"; }
  const char* GetExecutionProviderType() const { return "CPUExecutionProvider"; }
  size_t GetInputTypeCount() const { return 1; }
  ONNXTensorElementDataType GetInputType(size_t) const { return ONNX_TENSOR_ELEMENT_DATA_TYPE_INT16; }
  size_t GetOutputTypeCount() const { return 2; }
  ONNXTensorElementDataType GetOutputType(size_t) const { return ONNX_TENSOR_ELEMENT_DATA_TYPE_INT16; }
};
 
// MulTopKernelFloat16 and MulTopOpFloat has input characteristic mismatch
struct MulTopKernelFloat16 {
  MulTopKernelFloat16(const OrtKernelInfo*) {};
  ~MulTopKernelFloat16() = default;
  void Compute(OrtKernelContext*) {};
};
 
struct MulTopOpFloat16 : Ort::CustomOpBase<MulTopOpFloat16, MulTopKernelFloat16> {
  void* CreateKernel(const OrtApi&, const OrtKernelInfo* info) const { return new MulTopKernelFloat16(info); }
  const char* GetName() const { return "MulTop"; }
  const char* GetExecutionProviderType() const { return "CPUExecutionProvider"; }
  size_t GetInputTypeCount() const { return 1; }
  ONNXTensorElementDataType GetInputType(size_t) const { return ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT16; }
  size_t GetOutputTypeCount() const { return 1; }
  ONNXTensorElementDataType GetOutputType(size_t) const { return ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT16; }
  OrtCustomOpInputOutputCharacteristic GetInputCharacteristic(size_t) const {
    return OrtCustomOpInputOutputCharacteristic::INPUT_OUTPUT_OPTIONAL;
  }
};
 
//
// Example overriding an operator where type inference is required for the output so kernel matching works correctly
//
struct CustomCastKernel {
  CustomCastKernel(const OrtApi& /*ort_api*/, const OrtKernelInfo* /*info*/)
  /*: ort_(ort_api)*/ {
  }
 
  OrtStatusPtr ComputeV2(OrtKernelContext* context);
 
 private:
  // const OrtApi& ort_;
};
 
// Custom Cast op that takes float input and converts based on 'to' attribute.
// Example implementation only supports cast to double.
struct CustomCast : Ort::CustomOpBase<CustomCast, CustomCastKernel, true> {
  explicit CustomCast(const char* provider) : provider_(provider) {
    // if overriding an ONNX op you need to set the opset versions you are overriding
    start_ver_ = 7;  // should match minimum ONNX schema you implement
    // end_ver_ = ...; should match maximum ONNX schema you implement or unset for unlimited.
  }
 
  // static method used by Ort::CustomOpBase::SetShapeInferFn
  static OrtStatusPtr InferOutputShape(Ort::ShapeInferContext& context) {
    auto shape = context.GetInputShape(0);
 
    // infer output type based on 'to'.
    auto to = context.GetAttrInt("to");
    if (to != ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE) {
      return Ort::Status("Unexpected type", ORT_INVALID_ARGUMENT).release();
    }
 
    context.SetOutputShape(0, shape, ONNX_TENSOR_ELEMENT_DATA_TYPE_DOUBLE);
    return nullptr;
  }
 
  OrtStatusPtr CreateKernelV2(const OrtApi& api, const OrtKernelInfo* info, void** op_kernel) const {
    Ort::ConstKernelInfo ki(info);
    *op_kernel = new CustomCastKernel(api, info);
    return nullptr;
  };
 
  const char* GetName() const { return "Cast"; };
  const char* GetExecutionProviderType() const { return provider_; };
 
  size_t GetInputTypeCount() const { return 1; };
  ONNXTensorElementDataType GetInputType(size_t /*index*/) const {
    // example only accepts float input
    return ONNX_TENSOR_ELEMENT_DATA_TYPE_FLOAT;
  };
 
  size_t GetOutputTypeCount() const { return 1; };
  ONNXTensorElementDataType GetOutputType(size_t /*index*/) const { return ONNX_TENSOR_ELEMENT_DATA_TYPE_UNDEFINED; };
 
 private:
  const char* provider_{"CPUExecutionProvider"};
};