File tree Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Expand file tree Collapse file tree 2 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -35,9 +35,12 @@ constexpr uint32_t kMaxRegisteredKernels = kMaxOperators * kMaxKernelsPerOp;
35
35
// require constructing them at init time. Since we don't care about the values
36
36
// until we add each entry to the table, allocate static zeroed memory instead
37
37
// and point the table at it.
38
+ struct alignas (Kernel) KernelBuffer {
39
+ uint8_t data[sizeof (Kernel)];
40
+ };
41
+
38
42
// @lint-ignore CLANGTIDY facebook-hte-CArray
39
- alignas (sizeof (Kernel)) uint8_t
40
- registered_kernels_data[kMaxRegisteredKernels * sizeof (Kernel)];
43
+ KernelBuffer registered_kernels_data[kMaxRegisteredKernels ];
41
44
42
45
// / Global table of registered kernels.
43
46
Kernel* registered_kernels = reinterpret_cast <Kernel*>(registered_kernels_data);
Original file line number Diff line number Diff line change @@ -123,15 +123,15 @@ struct KernelKey {
123
123
* for all input tensor dtypes and dim orders if the specialized kernel is not
124
124
* registered.
125
125
*/
126
- KernelKey () : is_fallback_( true ) {}
126
+ KernelKey () = default ;
127
127
128
128
/* *
129
129
* Creates a specialized (non-fallback) kernel key that matches a specific
130
130
* set of input tensor dtypes and dim orders. See the class comment for the
131
131
* expected format of `kernel_key_data`.
132
132
*/
133
133
/* implicit */ KernelKey(const char * kernel_key_data)
134
- : kernel_key_data_(kernel_key_data), is_fallback_( false ) {}
134
+ : kernel_key_data_(kernel_key_data) {}
135
135
136
136
bool operator ==(const KernelKey& other) const {
137
137
return this ->equals (other);
@@ -142,17 +142,17 @@ struct KernelKey {
142
142
}
143
143
144
144
bool equals (const KernelKey& other) const {
145
- if (is_fallback_ != other.is_fallback_ ) {
145
+ if (is_fallback () != other.is_fallback () ) {
146
146
return false ;
147
147
}
148
- if (is_fallback_ ) {
148
+ if (is_fallback () ) {
149
149
return true ;
150
150
}
151
151
return strcmp (kernel_key_data_, other.kernel_key_data_ ) == 0 ;
152
152
}
153
153
154
154
bool is_fallback () const {
155
- return is_fallback_ ;
155
+ return kernel_key_data_ == nullptr ;
156
156
}
157
157
158
158
const char * data () const {
@@ -168,7 +168,6 @@ struct KernelKey {
168
168
169
169
private:
170
170
const char * kernel_key_data_ = nullptr ;
171
- bool is_fallback_;
172
171
};
173
172
174
173
/* *
You can’t perform that action at this time.
0 commit comments