-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathCSupportedOperations.cc
More file actions
134 lines (129 loc) · 4.06 KB
/
CSupportedOperations.cc
File metadata and controls
134 lines (129 loc) · 4.06 KB
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
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the following additional limitation. Functionality enabled by the
* files subject to the Elastic License 2.0 may only be used in production when
* invoked by an Elasticsearch process with a license key installed that permits
* use of machine learning features. You may not use this file except in
* compliance with the Elastic License 2.0 and the foregoing additional
* limitation.
*/
#include "CSupportedOperations.h"
namespace ml {
namespace torch {
using namespace std::string_view_literals;
const CSupportedOperations::TStringViewSet CSupportedOperations::FORBIDDEN_OPERATIONS = {
// Arbitrary memory access — enables heap scanning, address leaks, and
// ROP chain construction.
"aten::as_strided"sv,
"aten::from_file"sv,
"aten::save"sv,
// After graph inlining, method and function calls should be resolved.
// Their presence indicates an opaque call that cannot be validated.
"prim::CallFunction"sv,
"prim::CallMethod"sv,
};
// Generated by dev-tools/extract_model_ops/extract_model_ops.py against PyTorch 2.7.1.
// Reference models: bert-base-uncased, roberta-base, distilbert-base-uncased,
// google/electra-small-discriminator, microsoft/mpnet-base,
// microsoft/deberta-base, facebook/dpr-ctx_encoder-single-nq-base,
// google/mobilebert-uncased, xlm-roberta-base, elastic/bge-m3,
// elastic/distilbert-base-{cased,uncased}-finetuned-conll03-english,
// elastic/eis-elser-v2, elastic/elser-v2, elastic/hugging-face-elser,
// elastic/multilingual-e5-small-optimized, elastic/splade-v3,
// elastic/test-elser-v2.
// Additional ops from Elasticsearch integration test models
// (PyTorchModelIT, TextExpansionQueryIT, TextEmbeddingQueryIT).
// Quantized operations from dynamically quantized variants of the above
// models (torch.quantization.quantize_dynamic on nn.Linear layers).
const CSupportedOperations::TStringViewSet CSupportedOperations::ALLOWED_OPERATIONS = {
// aten operations (core tensor computations)
"aten::Int"sv,
"aten::IntImplicit"sv,
"aten::ScalarImplicit"sv,
"aten::__and__"sv,
"aten::abs"sv,
"aten::add"sv,
"aten::add_"sv,
"aten::arange"sv,
"aten::bitwise_not"sv,
"aten::cat"sv,
"aten::chunk"sv,
"aten::clamp"sv,
"aten::contiguous"sv,
"aten::cumsum"sv,
"aten::div"sv,
"aten::div_"sv,
"aten::dropout"sv,
"aten::embedding"sv,
"aten::expand"sv,
"aten::full_like"sv,
"aten::gather"sv,
"aten::ge"sv,
"aten::gelu"sv,
"aten::hash"sv,
"aten::index"sv,
"aten::index_put_"sv,
"aten::layer_norm"sv,
"aten::len"sv,
"aten::linear"sv,
"aten::log"sv,
"aten::lt"sv,
"aten::manual_seed"sv,
"aten::masked_fill"sv,
"aten::matmul"sv,
"aten::max"sv,
"aten::mean"sv,
"aten::min"sv,
"aten::mul"sv,
"aten::mul_"sv,
"aten::ne"sv,
"aten::neg"sv,
"aten::new_ones"sv,
"aten::ones"sv,
"aten::pad"sv,
"aten::permute"sv,
"aten::pow"sv,
"aten::rand"sv,
"aten::relu"sv,
"aten::repeat"sv,
"aten::reshape"sv,
"aten::rsub"sv,
"aten::scaled_dot_product_attention"sv,
"aten::select"sv,
"aten::size"sv,
"aten::slice"sv,
"aten::softmax"sv,
"aten::sqrt"sv,
"aten::squeeze"sv,
"aten::str"sv,
"aten::sub"sv,
"aten::tanh"sv,
"aten::tensor"sv,
"aten::to"sv,
"aten::transpose"sv,
"aten::type_as"sv,
"aten::unsqueeze"sv,
"aten::view"sv,
"aten::where"sv,
"aten::zeros"sv,
// prim operations (TorchScript graph infrastructure)
"prim::Constant"sv,
"prim::DictConstruct"sv,
"prim::GetAttr"sv,
"prim::If"sv,
"prim::ListConstruct"sv,
"prim::ListUnpack"sv,
"prim::Loop"sv,
"prim::NumToTensor"sv,
"prim::TupleConstruct"sv,
"prim::TupleUnpack"sv,
"prim::device"sv,
"prim::dtype"sv,
"prim::max"sv,
"prim::min"sv,
// quantized operations (dynamically quantized models, e.g. ELSER v2)
"quantized::linear_dynamic"sv,
};
}
}