29
29
#include <memory>
30
30
#include <string>
31
31
#include <vector>
32
+ #include <array>
32
33
#include <unordered_map>
33
34
34
35
#include "oneapi/dnnl/dnnl.h"
@@ -148,6 +149,10 @@ struct primitive : public handle<dnnl_primitive_t> {
148
149
layer_normalization = dnnl_layer_normalization,
149
150
/// A group normalization primitive
150
151
group_normalization = dnnl_group_normalization,
152
+
153
+ depthwise = dnnl_depthwise,
154
+ quantization = dnnl_quantization,
155
+ binarization = dnnl_binarization,
151
156
};
152
157
153
158
using handle::handle;
@@ -168,7 +173,7 @@ struct primitive : public handle<dnnl_primitive_t> {
168
173
const std::vector<uint8_t> &cache_blob);
169
174
170
175
/// Constructs a primitive from a primitive descriptor.
171
- ///
176
+ ///src/common/deconvolution_pd.hpp
172
177
/// @param pd Primitive descriptor.
173
178
primitive(const primitive_desc &pd);
174
179
@@ -3816,10 +3821,9 @@ struct post_ops : public handle<dnnl_post_ops_t> {
3816
3821
"could not append a binary post-op");
3817
3822
}
3818
3823
3819
- void append_dw_conv(int in_h, int in_w, int ker_h, int ker_w, int str_h, int str_w, dnnl_data_type_t in_dt,
3820
- const float* weights_data, const float* biases_data) {
3824
+ void append_dw_conv(int in_h, int in_w, int ker_h, int ker_w, int str_h, int str_w, dnnl_data_type_t in_dt) {
3821
3825
error::wrap_c_api(dnnl_post_ops_append_dw_conv(get(),
3822
- in_h, in_w, ker_h, ker_w, str_h, str_w, in_dt, weights_data, biases_data ),
3826
+ in_h, in_w, ker_h, ker_w, str_h, str_w, in_dt),
3823
3827
"could not append dw conv");
3824
3828
}
3825
3829
@@ -3908,19 +3912,15 @@ struct post_ops : public handle<dnnl_post_ops_t> {
3908
3912
"could not get parameters of a binary post-op");
3909
3913
}
3910
3914
3911
- void append_depthwise(algorithm alg, const float* weights_data,
3912
- const float* biases_data) {
3913
- error::wrap_c_api(dnnl_post_ops_append_depthwise(get(),
3914
- convert_to_c(alg), weights_data, biases_data),
3915
+ void append_depthwise(algorithm alg, const std::array<size_t, 2>& offset) {
3916
+ error::wrap_c_api(dnnl_post_ops_append_depthwise(get(), convert_to_c(alg), offset.size(), offset.data()),
3915
3917
"could not append depthwise");
3916
3918
}
3917
3919
3918
- void append_quantization(algorithm alg,
3919
- const void* crop_low, const void* crop_high,
3920
- const void* input_scale, const void* input_shift,
3921
- const void* output_scale, const void* output_shift) {
3922
- error::wrap_c_api(dnnl_post_ops_append_quantization(get(), convert_to_c(alg), crop_low, crop_high,
3923
- input_scale, input_shift, output_scale, output_shift),
3920
+ void append_quantization(algorithm alg, const std::array<bool, 6>& per_channel, const std::array<bool, 6>& all_default,
3921
+ const std::array<size_t, 6>& offset) {
3922
+ error::wrap_c_api(dnnl_post_ops_append_quantization(get(), convert_to_c(alg), per_channel.size(), per_channel.data(),
3923
+ all_default.size(), all_default.data(), offset.size(), offset.data()),
3924
3924
"could not append quantization");
3925
3925
}
3926
3926
@@ -4135,66 +4135,21 @@ struct primitive_attr : public handle<dnnl_primitive_attr_t> {
4135
4135
"could not set zero points primitive attribute");
4136
4136
}
4137
4137
4138
- void get_output_compensations(int &mask, std::vector<int32_t> &compensations) const
4138
+ void set_output_compensations(dnnl_dim_t count, int mask)
4139
4139
{
4140
- int count, c_mask;
4141
- const int32_t *c_compensations;
4142
- error::wrap_c_api(dnnl_primitive_attr_get_output_compensations(get(),
4143
- &count, &c_mask, &c_compensations),
4144
- "could not get int output compensations");
4145
- compensations.resize(count);
4146
-
4147
- mask = c_mask;
4148
- for (int c = 0; c < count; ++c)
4149
- compensations[c] = c_compensations[c];
4150
- }
4151
-
4152
- void set_output_compensations(int mask, const std::vector<int32_t> &compensations)
4153
- {
4154
- error::wrap_c_api(dnnl_primitive_attr_set_output_compensations(get(),
4155
- (int)compensations.size(), mask, &compensations[0]),
4140
+ error::wrap_c_api(dnnl_primitive_attr_set_output_compensations(get(), count, mask),
4156
4141
"could not set int output compensations");
4157
4142
}
4158
4143
4159
- void get_input_zero_points(int &mask, std::vector<uint8_t> &zero_points) const
4144
+ void set_input_zero_points(dnnl_dim_t count, int mask)
4160
4145
{
4161
- int count, c_mask;
4162
- const uint8_t *c_zero_points;
4163
- error::wrap_c_api(dnnl_primitive_attr_get_input_zero_points(get(),
4164
- &count, &c_mask, &c_zero_points),
4165
- "could not get int input zero_points");
4166
- zero_points.resize(count);
4167
-
4168
- mask = c_mask;
4169
- for (int c = 0; c < count; ++c)
4170
- zero_points[c] = c_zero_points[c];
4171
- }
4172
-
4173
- void set_input_zero_points(int mask, const std::vector<uint8_t> &zero_points)
4174
- {
4175
- error::wrap_c_api(dnnl_primitive_attr_set_input_zero_points(get(),
4176
- (int)zero_points.size(), mask, &zero_points[0]),
4146
+ error::wrap_c_api(dnnl_primitive_attr_set_input_zero_points(get(), count, mask),
4177
4147
"could not set int input zero_points");
4178
4148
}
4179
4149
4180
- void get_weights_zero_points(int &mask, std::vector<int8_t> &zero_points) const
4181
- {
4182
- int count, c_mask;
4183
- const float *c_zero_points;
4184
- error::wrap_c_api(dnnl_primitive_attr_get_weights_zero_points(get(),
4185
- &count, &c_mask, &c_zero_points),
4186
- "could not get int weights zero_points");
4187
- zero_points.resize(count);
4188
-
4189
- mask = c_mask;
4190
- for (int c = 0; c < count; ++c)
4191
- zero_points[c] = c_zero_points[c];
4192
- }
4193
-
4194
- void set_weights_zero_points(int mask, const std::vector<float> &zero_points)
4150
+ void set_weights_zero_points(dnnl_dim_t count, int mask)
4195
4151
{
4196
- error::wrap_c_api(dnnl_primitive_attr_set_weights_zero_points(get(),
4197
- (int)zero_points.size(), mask, &zero_points[0]),
4152
+ error::wrap_c_api(dnnl_primitive_attr_set_weights_zero_points(get(), count, mask),
4198
4153
"could not set int weights zero_points");
4199
4154
}
4200
4155
0 commit comments