Skip to content

Commit 0b0e1e3

Browse files
yaroslavJaccovG
authored andcommitted
conv cs interface update
1 parent c9410cf commit 0b0e1e3

File tree

10 files changed

+448
-134
lines changed

10 files changed

+448
-134
lines changed

include/api/mli_ref_compiler_api.hpp

Lines changed: 47 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ class Conv2d_CS : public lib_mli::Conv2d_CS {
3535
* of all values in the related perception area of all channels of the input tensor.
3636
*
3737
* @deprected
38+
* Be carefull - you need to use another deprected method to set tiling - SetIterators
3839
* Be carefull - conv2d I/O tensors of rank 4 are deprecated - new interfaces use rank 5
40+
* Be carefull - this is the most deprecated Constructor
3941
*
4042
* @param pd [IN] Platform description
4143
* @param in [IN] input tensor (full shape, BHWCi layout)
@@ -51,6 +53,7 @@ class Conv2d_CS : public lib_mli::Conv2d_CS {
5153

5254
/**
5355
* @brief Constructor to create an Conv2d_CS compiler support object.
56+
* @deprecated
5457
*
5558
* This constructor can be used to create a Convolution 2D compiler support
5659
* object. This kernel computes each value of the output tensor as the result of convolution operation
@@ -75,36 +78,52 @@ class Conv2d_CS : public lib_mli::Conv2d_CS {
7578
* @brief Constructor to create an Conv2d_CS compiler support object.
7679
*
7780
* This constructor can be used to create a Convolution 2D compiler support
78-
* object. This kernel computes each value of the output tensor as the result of convolution operation
81+
* object. This kernel computes each value of the output as the result of convolution operation
7982
* of input with weights.
8083
*
8184
* @param pd [I] Platform description
8285
* @param input [I] Input TensorIterator (BHWGCi layout)
83-
* @param input_zp [I] input_zp TensorIterator
84-
* @param weights [I] weights TensorIterator (GKyKxCiCo layout)
85-
* @param weights_zp [I] weights_zp TensorIterator
86-
* @param cfg [I] Conv2DConfig structure
87-
* @param output [I] output TensorIterator (BHWGCo layout)
86+
* @param input_zp [I] Input zero point(s) TensorIterator
87+
* @param weights [I] Weights TensorIterator (GKyKxCiCo layout)
88+
* @param weights_zp [I] Weights zero point(s) TensorIterator
89+
* @param cfg [I] Conv2DConfig structure with conv parameters (stride, dilation, paddings)
90+
* @param output [I] Output TensorIterator (BHWGCo layout)
8891
*/
8992
Conv2d_CS(const lib_mli::PlatformDescription pd,
9093
const TensorIterator<NoBuffer, kConvIORank, kConvIterRank> &input,
9194
const TensorIterator<NoBuffer, kConvZPRank, kConvIterRank> &input_zp,
9295
const TensorIterator<NoBuffer, kConvWRank, kConvIterRank> &weights,
9396
const TensorIterator<NoBuffer, kConvZPRank, kConvIterRank> &weights_zp,
9497
const Conv2DConfig &cfg,
95-
const TensorIterator<NoBuffer, kConvIORank, kConvIterRank> &output) { NOT_IMPLEMENTED_METHOD; };
98+
const TensorIterator<NoBuffer, kConvIORank, kConvIterRank> &output);
9699

100+
/**
101+
* @deprecated
102+
*/
97103
mli_status EncodeWeights(Tensor<Buffer, kConvWRank> &weights,
98104
Buffer &encoded_weights,
99105
compression_mode_t mode = compression_mode_t::Uncompressed) override;
100106

107+
mli_status EncodeWeightsAndZeroPts(TensorIterator<Buffer, kConvWRank, kConvIterRank>& weights,
108+
TensorIterator<Buffer, kConvZPRank, kConvIterRank>& weights_zp,
109+
Buffer& encoded_weights) override;
110+
101111
unsigned GetEncodedWeightsSize() override;
102112

113+
/**
114+
* @deprecated
115+
*/
103116
mli_status EncodeInpZeroPts(Tensor<Buffer, kInpZPRank> &inpzeropts,
104117
Buffer &encoded_inpzeropts) override;
105118

119+
mli_status EncodeInpZeroPts(TensorIterator<Buffer, kConvZPRank, kConvZPIterRank>& input_zp,
120+
Buffer& encoded_inpzeropts) override;
121+
106122
unsigned GetEncodedInpZeroPtsSize() override;
107123

124+
/**
125+
* @deprecated
126+
*/
108127
mli_status EncodeWtsZeroPts(Tensor<Buffer, kConvZPRank> &wtszeropts,
109128
Buffer &encoded_wtszeropts) override;
110129

@@ -148,7 +167,8 @@ class Conv2d_CS : public lib_mli::Conv2d_CS {
148167

149168
/**
150169
* @deprecated
151-
* Be carefull - conv2d I/O tensors of rank 4 are deprecated - new interfaces use rank 5
170+
* Be carefull - conv2d I/O tensors of rank 4 are deprecated - new interfaces use rank 5
171+
* Be carefull - don't use this method with new Conv2d_CS ctors - only with deprecated ctor that takes tensors
152172
*/
153173
mli_status SetIterators(uint32_t output_total_size[4],
154174
uint32_t iteration_order[4],
@@ -191,6 +211,7 @@ class DepthwiseConv2d_CS : public lib_mli::DepthwiseConv2d_CS {
191211
* @deprecated
192212
* Be carefull - this ctor doesn't support tiling - only single tile size of provided tensors
193213
* Be carefull - depthwise conv2d I/O tensors of rank 4 are deprecated - new interfaces use rank 5
214+
* Be carefull - this is the most deprecated Constructor
194215
*/
195216
DepthwiseConv2d_CS(const lib_mli::PlatformDescription pd,
196217
const Tensor<NoBuffer, 4> &in,
@@ -200,6 +221,7 @@ class DepthwiseConv2d_CS : public lib_mli::DepthwiseConv2d_CS {
200221

201222
/**
202223
* @brief Constructor of the DepthwiseConv2d_CS object
224+
* @deprecated
203225
*/
204226
DepthwiseConv2d_CS(const lib_mli::PlatformDescription pd,
205227
const TensorIterator<NoBuffer, kDepthwiseIORank, kDepthwiseIterRank>& input,
@@ -229,19 +251,35 @@ class DepthwiseConv2d_CS : public lib_mli::DepthwiseConv2d_CS {
229251
const TensorIterator<NoBuffer, kDepthwiseWRank, kDepthwiseIterRank> &weights,
230252
const TensorIterator<NoBuffer, kDepthwiseZPRank, kDepthwiseIterRank> &weights_zp,
231253
const DwConv2DConfig &cfg,
232-
const TensorIterator<NoBuffer, kDepthwiseIORank, kDepthwiseIterRank> &output) { NOT_IMPLEMENTED_METHOD; };
254+
const TensorIterator<NoBuffer, kDepthwiseIORank, kDepthwiseIterRank> &output);
233255

256+
/**
257+
* @deprecated
258+
*/
234259
mli_status EncodeWeights(Tensor<Buffer, kDepthwiseWRank> &weights,
235260
Buffer &encoded_weights,
236261
compression_mode_t mode = compression_mode_t::Uncompressed) override;
237262

263+
mli_status EncodeWeightsAndZeroPts(TensorIterator<Buffer, kDepthwiseWRank, kDepthwiseIterRank>& weights,
264+
TensorIterator<Buffer, kDepthwiseZPRank, kDepthwiseIterRank>& weights_zp,
265+
Buffer& encoded_weights) override;
266+
238267
unsigned GetEncodedWeightsSize() override;
239268

269+
/**
270+
* @deprecated
271+
*/
240272
mli_status EncodeInpZeroPts(Tensor<Buffer, kDepthwiseZPRank> &inpzeropts,
241273
Buffer &encoded_inpzeropts) override;
242274

275+
mli_status EncodeInpZeroPts(TensorIterator<Buffer, kDepthwiseZPRank, kDepthwiseIterRank>& input_zp,
276+
Buffer& encoded_input_zp) override;
277+
243278
unsigned GetEncodedInpZeroPtsSize() override;
244279

280+
/**
281+
* @deprecated
282+
*/
245283
mli_status EncodeWtsZeroPts(Tensor<Buffer, kDepthwiseZPRank> &wtszeropts,
246284
Buffer &encoded_wtszeropts) override;
247285

include/mli_compiler_api.hpp

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,15 +126,15 @@ class Conv2d_CS : public CompilerGenericInterface {
126126
public:
127127
/**
128128
* @brief Method to encode the weights (coefficients)
129-
*
129+
* @deprecated
130130
* This method will read the weights buffer in a platform independent layout
131131
* and translate it into a buffer that can be easily read by the platform specific
132132
* kernel implementation.
133133
* This transformation may include compression
134134
* The content of the encode_weights buffer is opaque for the user.
135135
*
136-
* @param weights [I] tensor with the weights
137-
* @param buffer_t[I] buffer pointer where the encode function can write the encoded weights
136+
* @param weights [I] tensor with the weights
137+
* @param encoded_weights [I] buffer where the encode function write the encoded weights
138138
*
139139
* TODO: how to handle sliding in the output channel dimension? is this weights encoding for the complete 'thing' or just for this slide?
140140
*/
@@ -171,7 +171,7 @@ class Conv2d_CS : public CompilerGenericInterface {
171171

172172
/**
173173
* @brief Method to encode input zero-points (padding values)
174-
*
174+
* @deprecated
175175
* This method will read the input zero-points buffer in a platform independent layout
176176
* and translate it into a buffer that can be easily read by the platform specific
177177
* kernel implementation.
@@ -205,7 +205,7 @@ class Conv2d_CS : public CompilerGenericInterface {
205205

206206
/**
207207
* @brief Method to encode weights zero-points (padding values)
208-
*
208+
* @deprecated
209209
* This method will read the weights zero-points buffer in a platform independent layout
210210
* and translate it into a buffer that can be easily read by the platform specific
211211
* kernel implementation.
@@ -298,8 +298,9 @@ class Conv2d_CS : public CompilerGenericInterface {
298298
* NOTE: the use of this method is optional. if there is a single tile, and the .Update() is not used,
299299
* this data doesn't need to be set.
300300
* All the increments are following the output tile iterator.
301-
*
302301
* @deprecated
302+
* Be carefull - don't use this method with new Conv2d_CS ctors - only with deprecated ctor that takes tensors
303+
*
303304
* @param output_total_size[4] [I] total size in each dimension
304305
* @param iteration_order[4] [I] which dimension of the output to iterate first.
305306
* @param input_first_inc[4] [I] increment of the input buffer pointer for the first iteration in each dimension
@@ -444,6 +445,7 @@ class DepthwiseConv2d_CS : public CompilerGenericInterface {
444445

445446
/**
446447
* @brief Method to encode the weights (coefficients).
448+
* @deprecated
447449
* TODO: add description using conv2d_cs as a starting point
448450
*/
449451
virtual mli_status EncodeWeights(Tensor<Buffer, kDepthwiseWRank> &weights,
@@ -476,7 +478,7 @@ class DepthwiseConv2d_CS : public CompilerGenericInterface {
476478

477479
/**
478480
* @brief Method to encode input zero-points (padding values)
479-
*
481+
* @deprecated
480482
*/
481483
virtual mli_status EncodeInpZeroPts(Tensor<Buffer, kDepthwiseZPRank> &inpzeropts,
482484
Buffer &encoded_inpzeropts) = 0;
@@ -505,7 +507,7 @@ class DepthwiseConv2d_CS : public CompilerGenericInterface {
505507

506508
/**
507509
* @brief Method to encode weights zero-points
508-
*
510+
* @deprecated
509511
*/
510512
virtual mli_status EncodeWtsZeroPts(Tensor<Buffer, kDepthwiseZPRank> &wtszeropts,
511513
Buffer &encoded_wtszeropts) { return MLI_STATUS_OK; }

include/mli_kernels_factory.hpp

Lines changed: 61 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ class KernelsFactory {
104104
/**
105105
* @brief Convolution 2D kernel Compiler Support interface factory
106106
* method
107-
*
107+
* @deprecated
108+
*
108109
* @param kernel_buffer [I] Pointer to the pre-allocated memory to store
109110
* kernel Compiler Support object
110111
* @param input [I] TensorIterator object containing input Tensor shape and
@@ -127,6 +128,34 @@ class KernelsFactory {
127128
return nullptr;
128129
}
129130

131+
/**
132+
* @brief Convolution 2D kernel Compiler Support interface factory
133+
* method
134+
*
135+
* @param kernel_buffer [I] Pointer to the pre-allocated memory to store
136+
* kernel Compiler Support object
137+
* @param input [I] TensorIterator object containing input Tensor shape and
138+
* memory strides and IteratorCfg
139+
* @param input_zp [I] TensorIterator object containing input zp(s) array
140+
* @param weights [I] TensorIterator object containing weights Tensor shape
141+
* and memory strides and IteratorCfg
142+
* @param weights_zp [I] TensorIterator object containing weight zp(s) array
143+
* @param cfg [I] Kernel configuration structure
144+
* @param output [I] TensorIterator object containing output Tensor shape
145+
* and memory strides and IteratorCfg
146+
*
147+
* @return Convolution 2D kernel Compiler Support interface object
148+
*/
149+
virtual lib_mli::Conv2d_CS* Conv2d_CS(void* kernel_buffer,
150+
const TensorIterator<NoBuffer, kConvIORank, kConvIOIterRank>& input, // BHWGCi
151+
const TensorIterator<NoBuffer, kConvZPRank, kConvZPIterRank>& input_zp,
152+
const TensorIterator<NoBuffer, kConvWRank, kConvWIterRank>& weights, // GKyKxCiCo
153+
const TensorIterator<NoBuffer, kConvZPRank, kConvZPIterRank>& weights_zp, // Co tensor, GKyKxCiCo iterator
154+
const Conv2DConfig& cfg,
155+
const TensorIterator<NoBuffer, kConvIORank, kConvIOIterRank>& output) { // BHWGCo
156+
return nullptr;
157+
}
158+
130159
/**
131160
* @brief Convolution 2D kernel Compiler Support interface
132161
* to get the Alignment Restrictions in Input Tensor.
@@ -411,7 +440,7 @@ class KernelsFactory {
411440
* @deprecated
412441
* Be carefull - this factory method doesn't support tiling - only single tile size of provided tensors
413442
* Be carefull - depthwise conv2d I/O tensors of rank 4 are deprecated - new interfaces use rank 5
414-
*
443+
* Be carefull - this is the most deprecated factory method for DepthwiseConv2d_CS
415444
* @param kernel_buffer [I] Pointer to the pre-allocated memory to store
416445
* kernel Compiler Support object
417446
* @param in [I] Tensor object containing input Tensor shape and
@@ -436,6 +465,7 @@ class KernelsFactory {
436465
* @brief Depthwise Convolution 2D kernel Compiler Support interface factory
437466
* method
438467
*
468+
* @deprecated
439469
* @param kernel_buffer [I] Pointer to the pre-allocated memory to store
440470
* kernel Compiler Support object
441471
* @param input [I] TensorIterator object containing input Tensor shape and
@@ -458,6 +488,35 @@ class KernelsFactory {
458488
return nullptr;
459489
}
460490

491+
/**
492+
* @brief Depthwise Convolution 2D kernel Compiler Support interface factory
493+
* method
494+
*
495+
* @param kernel_buffer [I] Pointer to the pre-allocated memory to store
496+
* kernel Compiler Support object
497+
* @param input [I] TensorIterator object containing input Tensor shape and
498+
* memory strides and IteratorCfg
499+
* @param input_zp [I] TensorIterator object containing input zp(s) Tensor shape and
500+
* memory strides and IteratorCfg
501+
* @param weights [I] TensorIterator object containing weights Tensor shape
502+
* and memory strides and IteratorCfg
503+
* @param weights_zp [I] TensorIterator object containing weight zp(s) array
504+
* @param cfg [I] Kernel configuration structure
505+
* @param output [I] TensorIterator object containing output Tensor shape
506+
* and memory strides and IteratorCfg
507+
*
508+
* @return Depthwise Convolution 2D kernel Compiler Support interface object
509+
*/
510+
virtual lib_mli::DepthwiseConv2d_CS* DepthwiseConv2d_CS(void* kernel_buffer,
511+
const TensorIterator<NoBuffer, kDepthwiseIORank, kDepthwiseIterRank>& input, // BHWGC
512+
const TensorIterator<NoBuffer, kDepthwiseZPRank, kDepthwiseIterRank>& input_zp,
513+
const TensorIterator<NoBuffer, kDepthwiseWRank, kDepthwiseIterRank>& weights, // KiKoC
514+
const TensorIterator<NoBuffer, kDepthwiseZPRank, kDepthwiseIterRank>& weights_zp, // C
515+
const DwConv2DConfig& cfg,
516+
const TensorIterator<NoBuffer, kDepthwiseIORank, kDepthwiseIterRank>& output) { // BHWGC
517+
return nullptr;
518+
}
519+
461520
/**
462521
* @brief Depthwise Convolution 2D kernel Compiler Support interface
463522
* to get the Alignment Restrictions in Input Tensor.

0 commit comments

Comments
 (0)