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"
@@ -146,6 +147,10 @@ struct primitive : public handle<dnnl_primitive_t> {
146
147
softmax = dnnl_softmax,
147
148
/// A layer normalization primitive.
148
149
layer_normalization = dnnl_layer_normalization,
150
+
151
+ depthwise = dnnl_depthwise,
152
+ quantization = dnnl_quantization,
153
+ binarization = dnnl_binarization,
149
154
};
150
155
151
156
using handle::handle;
@@ -166,7 +171,7 @@ struct primitive : public handle<dnnl_primitive_t> {
166
171
const std::vector<uint8_t> &cache_blob);
167
172
168
173
/// Constructs a primitive from a primitive descriptor.
169
- ///
174
+ ///src/common/deconvolution_pd.hpp
170
175
/// @param pd Primitive descriptor.
171
176
primitive(const primitive_desc &pd);
172
177
@@ -3594,10 +3599,9 @@ struct post_ops : public handle<dnnl_post_ops_t> {
3594
3599
"could not append a binary post-op");
3595
3600
}
3596
3601
3597
- 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,
3598
- const float* weights_data, const float* biases_data) {
3602
+ 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) {
3599
3603
error::wrap_c_api(dnnl_post_ops_append_dw_conv(get(),
3600
- in_h, in_w, ker_h, ker_w, str_h, str_w, in_dt, weights_data, biases_data ),
3604
+ in_h, in_w, ker_h, ker_w, str_h, str_w, in_dt),
3601
3605
"could not append dw conv");
3602
3606
}
3603
3607
@@ -3686,19 +3690,15 @@ struct post_ops : public handle<dnnl_post_ops_t> {
3686
3690
"could not get parameters of a binary post-op");
3687
3691
}
3688
3692
3689
- void append_depthwise(algorithm alg, const float* weights_data,
3690
- const float* biases_data) {
3691
- error::wrap_c_api(dnnl_post_ops_append_depthwise(get(),
3692
- convert_to_c(alg), weights_data, biases_data),
3693
+ void append_depthwise(algorithm alg, const std::array<size_t, 2>& offset) {
3694
+ error::wrap_c_api(dnnl_post_ops_append_depthwise(get(), convert_to_c(alg), offset.size(), offset.data()),
3693
3695
"could not append depthwise");
3694
3696
}
3695
3697
3696
- void append_quantization(algorithm alg,
3697
- const void* crop_low, const void* crop_high,
3698
- const void* input_scale, const void* input_shift,
3699
- const void* output_scale, const void* output_shift) {
3700
- error::wrap_c_api(dnnl_post_ops_append_quantization(get(), convert_to_c(alg), crop_low, crop_high,
3701
- input_scale, input_shift, output_scale, output_shift),
3698
+ void append_quantization(algorithm alg, const std::array<bool, 6>& per_channel, const std::array<bool, 6>& all_default,
3699
+ const std::array<size_t, 6>& offset) {
3700
+ error::wrap_c_api(dnnl_post_ops_append_quantization(get(), convert_to_c(alg), per_channel.size(), per_channel.data(),
3701
+ all_default.size(), all_default.data(), offset.size(), offset.data()),
3702
3702
"could not append quantization");
3703
3703
}
3704
3704
@@ -3811,66 +3811,21 @@ struct primitive_attr : public handle<dnnl_primitive_attr_t> {
3811
3811
"could not set zero points primitive attribute");
3812
3812
}
3813
3813
3814
- void get_output_compensations(int &mask, std::vector<int32_t> &compensations) const
3814
+ void set_output_compensations(dnnl_dim_t count, int mask)
3815
3815
{
3816
- int count, c_mask;
3817
- const int32_t *c_compensations;
3818
- error::wrap_c_api(dnnl_primitive_attr_get_output_compensations(get(),
3819
- &count, &c_mask, &c_compensations),
3820
- "could not get int output compensations");
3821
- compensations.resize(count);
3822
-
3823
- mask = c_mask;
3824
- for (int c = 0; c < count; ++c)
3825
- compensations[c] = c_compensations[c];
3826
- }
3827
-
3828
- void set_output_compensations(int mask, const std::vector<int32_t> &compensations)
3829
- {
3830
- error::wrap_c_api(dnnl_primitive_attr_set_output_compensations(get(),
3831
- (int)compensations.size(), mask, &compensations[0]),
3816
+ error::wrap_c_api(dnnl_primitive_attr_set_output_compensations(get(), count, mask),
3832
3817
"could not set int output compensations");
3833
3818
}
3834
3819
3835
- void get_input_zero_points(int &mask, std::vector<uint8_t> &zero_points) const
3820
+ void set_input_zero_points(dnnl_dim_t count, int mask)
3836
3821
{
3837
- int count, c_mask;
3838
- const uint8_t *c_zero_points;
3839
- error::wrap_c_api(dnnl_primitive_attr_get_input_zero_points(get(),
3840
- &count, &c_mask, &c_zero_points),
3841
- "could not get int input zero_points");
3842
- zero_points.resize(count);
3843
-
3844
- mask = c_mask;
3845
- for (int c = 0; c < count; ++c)
3846
- zero_points[c] = c_zero_points[c];
3847
- }
3848
-
3849
- void set_input_zero_points(int mask, const std::vector<uint8_t> &zero_points)
3850
- {
3851
- error::wrap_c_api(dnnl_primitive_attr_set_input_zero_points(get(),
3852
- (int)zero_points.size(), mask, &zero_points[0]),
3822
+ error::wrap_c_api(dnnl_primitive_attr_set_input_zero_points(get(), count, mask),
3853
3823
"could not set int input zero_points");
3854
3824
}
3855
3825
3856
- void get_weights_zero_points(int &mask, std::vector<int8_t> &zero_points) const
3857
- {
3858
- int count, c_mask;
3859
- const float *c_zero_points;
3860
- error::wrap_c_api(dnnl_primitive_attr_get_weights_zero_points(get(),
3861
- &count, &c_mask, &c_zero_points),
3862
- "could not get int weights 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_weights_zero_points(int mask, const std::vector<float> &zero_points)
3826
+ void set_weights_zero_points(dnnl_dim_t count, int mask)
3871
3827
{
3872
- error::wrap_c_api(dnnl_primitive_attr_set_weights_zero_points(get(),
3873
- (int)zero_points.size(), mask, &zero_points[0]),
3828
+ error::wrap_c_api(dnnl_primitive_attr_set_weights_zero_points(get(), count, mask),
3874
3829
"could not set int weights zero_points");
3875
3830
}
3876
3831
0 commit comments