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
@@ -3615,10 +3620,9 @@ struct post_ops : public handle<dnnl_post_ops_t> {
3615
3620
"could not append a binary post-op");
3616
3621
}
3617
3622
3618
- 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,
3619
- const float* weights_data, const float* biases_data) {
3623
+ 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) {
3620
3624
error::wrap_c_api(dnnl_post_ops_append_dw_conv(get(),
3621
- in_h, in_w, ker_h, ker_w, str_h, str_w, in_dt, weights_data, biases_data ),
3625
+ in_h, in_w, ker_h, ker_w, str_h, str_w, in_dt),
3622
3626
"could not append dw conv");
3623
3627
}
3624
3628
@@ -3707,19 +3711,15 @@ struct post_ops : public handle<dnnl_post_ops_t> {
3707
3711
"could not get parameters of a binary post-op");
3708
3712
}
3709
3713
3710
- void append_depthwise(algorithm alg, const float* weights_data,
3711
- const float* biases_data) {
3712
- error::wrap_c_api(dnnl_post_ops_append_depthwise(get(),
3713
- convert_to_c(alg), weights_data, biases_data),
3714
+ void append_depthwise(algorithm alg, const std::array<size_t, 2>& offset) {
3715
+ error::wrap_c_api(dnnl_post_ops_append_depthwise(get(), convert_to_c(alg), offset.size(), offset.data()),
3714
3716
"could not append depthwise");
3715
3717
}
3716
3718
3717
- void append_quantization(algorithm alg,
3718
- const void* crop_low, const void* crop_high,
3719
- const void* input_scale, const void* input_shift,
3720
- const void* output_scale, const void* output_shift) {
3721
- error::wrap_c_api(dnnl_post_ops_append_quantization(get(), convert_to_c(alg), crop_low, crop_high,
3722
- input_scale, input_shift, output_scale, output_shift),
3719
+ void append_quantization(algorithm alg, const std::array<bool, 6>& per_channel, const std::array<bool, 6>& all_default,
3720
+ const std::array<size_t, 6>& offset) {
3721
+ error::wrap_c_api(dnnl_post_ops_append_quantization(get(), convert_to_c(alg), per_channel.size(), per_channel.data(),
3722
+ all_default.size(), all_default.data(), offset.size(), offset.data()),
3723
3723
"could not append quantization");
3724
3724
}
3725
3725
@@ -3832,66 +3832,21 @@ struct primitive_attr : public handle<dnnl_primitive_attr_t> {
3832
3832
"could not set zero points primitive attribute");
3833
3833
}
3834
3834
3835
- void get_output_compensations(int &mask, std::vector<int32_t> &compensations) const
3835
+ void set_output_compensations(dnnl_dim_t count, int mask)
3836
3836
{
3837
- int count, c_mask;
3838
- const int32_t *c_compensations;
3839
- error::wrap_c_api(dnnl_primitive_attr_get_output_compensations(get(),
3840
- &count, &c_mask, &c_compensations),
3841
- "could not get int output compensations");
3842
- compensations.resize(count);
3843
-
3844
- mask = c_mask;
3845
- for (int c = 0; c < count; ++c)
3846
- compensations[c] = c_compensations[c];
3847
- }
3848
-
3849
- void set_output_compensations(int mask, const std::vector<int32_t> &compensations)
3850
- {
3851
- error::wrap_c_api(dnnl_primitive_attr_set_output_compensations(get(),
3852
- (int)compensations.size(), mask, &compensations[0]),
3837
+ error::wrap_c_api(dnnl_primitive_attr_set_output_compensations(get(), count, mask),
3853
3838
"could not set int output compensations");
3854
3839
}
3855
3840
3856
- void get_input_zero_points(int &mask, std::vector<uint8_t> &zero_points) const
3841
+ void set_input_zero_points(dnnl_dim_t count, int mask)
3857
3842
{
3858
- int count, c_mask;
3859
- const uint8_t *c_zero_points;
3860
- error::wrap_c_api(dnnl_primitive_attr_get_input_zero_points(get(),
3861
- &count, &c_mask, &c_zero_points),
3862
- "could not get int input zero_points");
3863
- zero_points.resize(count);
3864
-
3865
- mask = c_mask;
3866
- for (int c = 0; c < count; ++c)
3867
- zero_points[c] = c_zero_points[c];
3868
- }
3869
-
3870
- void set_input_zero_points(int mask, const std::vector<uint8_t> &zero_points)
3871
- {
3872
- error::wrap_c_api(dnnl_primitive_attr_set_input_zero_points(get(),
3873
- (int)zero_points.size(), mask, &zero_points[0]),
3843
+ error::wrap_c_api(dnnl_primitive_attr_set_input_zero_points(get(), count, mask),
3874
3844
"could not set int input zero_points");
3875
3845
}
3876
3846
3877
- void get_weights_zero_points(int &mask, std::vector<int8_t> &zero_points) const
3878
- {
3879
- int count, c_mask;
3880
- const float *c_zero_points;
3881
- error::wrap_c_api(dnnl_primitive_attr_get_weights_zero_points(get(),
3882
- &count, &c_mask, &c_zero_points),
3883
- "could not get int weights zero_points");
3884
- zero_points.resize(count);
3885
-
3886
- mask = c_mask;
3887
- for (int c = 0; c < count; ++c)
3888
- zero_points[c] = c_zero_points[c];
3889
- }
3890
-
3891
- void set_weights_zero_points(int mask, const std::vector<float> &zero_points)
3847
+ void set_weights_zero_points(dnnl_dim_t count, int mask)
3892
3848
{
3893
- error::wrap_c_api(dnnl_primitive_attr_set_weights_zero_points(get(),
3894
- (int)zero_points.size(), mask, &zero_points[0]),
3849
+ error::wrap_c_api(dnnl_primitive_attr_set_weights_zero_points(get(), count, mask),
3895
3850
"could not set int weights zero_points");
3896
3851
}
3897
3852
0 commit comments