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
@@ -3810,10 +3815,9 @@ struct post_ops : public handle<dnnl_post_ops_t> {
3810
3815
"could not append a binary post-op");
3811
3816
}
3812
3817
3813
- 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,
3814
- const float* weights_data, const float* biases_data) {
3818
+ 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) {
3815
3819
error::wrap_c_api(dnnl_post_ops_append_dw_conv(get(),
3816
- in_h, in_w, ker_h, ker_w, str_h, str_w, in_dt, weights_data, biases_data ),
3820
+ in_h, in_w, ker_h, ker_w, str_h, str_w, in_dt),
3817
3821
"could not append dw conv");
3818
3822
}
3819
3823
@@ -3902,19 +3906,15 @@ struct post_ops : public handle<dnnl_post_ops_t> {
3902
3906
"could not get parameters of a binary post-op");
3903
3907
}
3904
3908
3905
- void append_depthwise(algorithm alg, const float* weights_data,
3906
- const float* biases_data) {
3907
- error::wrap_c_api(dnnl_post_ops_append_depthwise(get(),
3908
- convert_to_c(alg), weights_data, biases_data),
3909
+ void append_depthwise(algorithm alg, const std::array<size_t, 2>& offset) {
3910
+ error::wrap_c_api(dnnl_post_ops_append_depthwise(get(), convert_to_c(alg), offset.size(), offset.data()),
3909
3911
"could not append depthwise");
3910
3912
}
3911
3913
3912
- void append_quantization(algorithm alg,
3913
- const void* crop_low, const void* crop_high,
3914
- const void* input_scale, const void* input_shift,
3915
- const void* output_scale, const void* output_shift) {
3916
- error::wrap_c_api(dnnl_post_ops_append_quantization(get(), convert_to_c(alg), crop_low, crop_high,
3917
- input_scale, input_shift, output_scale, output_shift),
3914
+ void append_quantization(algorithm alg, const std::array<bool, 6>& per_channel, const std::array<bool, 6>& all_default,
3915
+ const std::array<size_t, 6>& offset) {
3916
+ error::wrap_c_api(dnnl_post_ops_append_quantization(get(), convert_to_c(alg), per_channel.size(), per_channel.data(),
3917
+ all_default.size(), all_default.data(), offset.size(), offset.data()),
3918
3918
"could not append quantization");
3919
3919
}
3920
3920
@@ -4129,66 +4129,21 @@ struct primitive_attr : public handle<dnnl_primitive_attr_t> {
4129
4129
"could not set zero points primitive attribute");
4130
4130
}
4131
4131
4132
- void get_output_compensations(int &mask, std::vector<int32_t> &compensations) const
4132
+ void set_output_compensations(dnnl_dim_t count, int mask)
4133
4133
{
4134
- int count, c_mask;
4135
- const int32_t *c_compensations;
4136
- error::wrap_c_api(dnnl_primitive_attr_get_output_compensations(get(),
4137
- &count, &c_mask, &c_compensations),
4138
- "could not get int output compensations");
4139
- compensations.resize(count);
4140
-
4141
- mask = c_mask;
4142
- for (int c = 0; c < count; ++c)
4143
- compensations[c] = c_compensations[c];
4144
- }
4145
-
4146
- void set_output_compensations(int mask, const std::vector<int32_t> &compensations)
4147
- {
4148
- error::wrap_c_api(dnnl_primitive_attr_set_output_compensations(get(),
4149
- (int)compensations.size(), mask, &compensations[0]),
4134
+ error::wrap_c_api(dnnl_primitive_attr_set_output_compensations(get(), count, mask),
4150
4135
"could not set int output compensations");
4151
4136
}
4152
4137
4153
- void get_input_zero_points(int &mask, std::vector<uint8_t> &zero_points) const
4138
+ void set_input_zero_points(dnnl_dim_t count, int mask)
4154
4139
{
4155
- int count, c_mask;
4156
- const uint8_t *c_zero_points;
4157
- error::wrap_c_api(dnnl_primitive_attr_get_input_zero_points(get(),
4158
- &count, &c_mask, &c_zero_points),
4159
- "could not get int input zero_points");
4160
- zero_points.resize(count);
4161
-
4162
- mask = c_mask;
4163
- for (int c = 0; c < count; ++c)
4164
- zero_points[c] = c_zero_points[c];
4165
- }
4166
-
4167
- void set_input_zero_points(int mask, const std::vector<uint8_t> &zero_points)
4168
- {
4169
- error::wrap_c_api(dnnl_primitive_attr_set_input_zero_points(get(),
4170
- (int)zero_points.size(), mask, &zero_points[0]),
4140
+ error::wrap_c_api(dnnl_primitive_attr_set_input_zero_points(get(), count, mask),
4171
4141
"could not set int input zero_points");
4172
4142
}
4173
4143
4174
- void get_weights_zero_points(int &mask, std::vector<int8_t> &zero_points) const
4175
- {
4176
- int count, c_mask;
4177
- const float *c_zero_points;
4178
- error::wrap_c_api(dnnl_primitive_attr_get_weights_zero_points(get(),
4179
- &count, &c_mask, &c_zero_points),
4180
- "could not get int weights zero_points");
4181
- zero_points.resize(count);
4182
-
4183
- mask = c_mask;
4184
- for (int c = 0; c < count; ++c)
4185
- zero_points[c] = c_zero_points[c];
4186
- }
4187
-
4188
- void set_weights_zero_points(int mask, const std::vector<float> &zero_points)
4144
+ void set_weights_zero_points(dnnl_dim_t count, int mask)
4189
4145
{
4190
- error::wrap_c_api(dnnl_primitive_attr_set_weights_zero_points(get(),
4191
- (int)zero_points.size(), mask, &zero_points[0]),
4146
+ error::wrap_c_api(dnnl_primitive_attr_set_weights_zero_points(get(), count, mask),
4192
4147
"could not set int weights zero_points");
4193
4148
}
4194
4149
0 commit comments