1// This file is MACHINE GENERATED! Do not edit.
2
3#ifndef TENSORFLOW_CC_OPS_NN_OPS_INTERNAL_H_
4#define TENSORFLOW_CC_OPS_NN_OPS_INTERNAL_H_
5
6// This file is MACHINE GENERATED! Do not edit.
7
8#include "tensorflow/cc/framework/ops.h"
9#include "tensorflow/cc/framework/scope.h"
10#include "tensorflow/core/framework/tensor.h"
11#include "tensorflow/core/framework/tensor_shape.h"
12#include "tensorflow/core/framework/types.h"
13#include "tensorflow/core/lib/gtl/array_slice.h"
14
15namespace tensorflow {
16namespace ops {
17namespace internal {
18// NOTE: This namespace has internal TensorFlow details that
19// are not part of TensorFlow's public API.
20
21/// @defgroup nn_ops_internal Nn Ops Internal
22/// @{
23
24/// Computes gradients of the average pooling function.
25///
26/// Args:
27/// * scope: A Scope object
28/// * orig_input_shape: 1-D. Shape of the original input to `avg_pool`.
29/// * grad: 4-D with shape `[batch, height, width, channels]`. Gradients w.r.t.
30/// the output of `avg_pool`.
31/// * ksize: The size of the sliding window for each dimension of the input.
32/// * strides: The stride of the sliding window for each dimension of the input.
33/// * padding: The type of padding algorithm to use.
34///
35/// Optional attributes (see `Attrs`):
36/// * data_format: Specify the data format of the input and output data. With the
37/// default format "NHWC", the data is stored in the order of:
38/// [batch, in_height, in_width, in_channels].
39/// Alternatively, the format could be "NCHW", the data storage order of:
40/// [batch, in_channels, in_height, in_width].
41///
42/// Returns:
43/// * `Output`: 4-D. Gradients w.r.t. the input of `avg_pool`.
44class AvgPoolGrad {
45 public:
46 /// Optional attribute setters for AvgPoolGrad
47 struct Attrs {
48 /// Specify the data format of the input and output data. With the
49 /// default format "NHWC", the data is stored in the order of:
50 /// [batch, in_height, in_width, in_channels].
51 /// Alternatively, the format could be "NCHW", the data storage order of:
52 /// [batch, in_channels, in_height, in_width].
53 ///
54 /// Defaults to "NHWC"
55 TF_MUST_USE_RESULT Attrs DataFormat(StringPiece x) {
56 Attrs ret = *this;
57 ret.data_format_ = x;
58 return ret;
59 }
60
61 StringPiece data_format_ = "NHWC";
62 };
63 AvgPoolGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input
64 orig_input_shape, ::tensorflow::Input grad, const
65 gtl::ArraySlice<int>& ksize, const gtl::ArraySlice<int>& strides,
66 StringPiece padding);
67 AvgPoolGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input
68 orig_input_shape, ::tensorflow::Input grad, const
69 gtl::ArraySlice<int>& ksize, const gtl::ArraySlice<int>& strides,
70 StringPiece padding, const AvgPoolGrad::Attrs& attrs);
71 operator ::tensorflow::Output() const { return output; }
72 operator ::tensorflow::Input() const { return output; }
73 ::tensorflow::Node* node() const { return output.node(); }
74
75 static Attrs DataFormat(StringPiece x) {
76 return Attrs().DataFormat(x);
77 }
78
79 Operation operation;
80 ::tensorflow::Output output;
81};
82
83/// Computes gradients for the exponential linear (Elu) operation.
84///
85/// Args:
86/// * scope: A Scope object
87/// * gradients: The backpropagated gradients to the corresponding Elu operation.
88/// * outputs: The outputs of the corresponding Elu operation.
89///
90/// Returns:
91/// * `Output`: The gradients: `gradients * (outputs + 1)` if outputs < 0,
92/// `gradients` otherwise.
93class EluGrad {
94 public:
95 EluGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input gradients,
96 ::tensorflow::Input outputs);
97 operator ::tensorflow::Output() const { return backprops; }
98 operator ::tensorflow::Input() const { return backprops; }
99 ::tensorflow::Node* node() const { return backprops.node(); }
100
101 Operation operation;
102 ::tensorflow::Output backprops;
103};
104
105/// Computes gradient of the FractionalAvgPool function.
106///
107/// Unlike FractionalMaxPoolGrad, we don't need to find arg_max for
108/// FractionalAvgPoolGrad, we just need to evenly back-propagate each element of
109/// out_backprop to those indices that form the same pooling cell. Therefore, we
110/// just need to know the shape of original input tensor, instead of the whole
111/// tensor.
112///
113/// Args:
114/// * scope: A Scope object
115/// * orig_input_tensor_shape: Original input tensor shape for `fractional_avg_pool`
116/// * out_backprop: 4-D with shape `[batch, height, width, channels]`. Gradients
117/// w.r.t. the output of `fractional_avg_pool`.
118/// * row_pooling_sequence: row pooling sequence, form pooling region with
119/// col_pooling_sequence.
120/// * col_pooling_sequence: column pooling sequence, form pooling region with
121/// row_pooling sequence.
122///
123/// Optional attributes (see `Attrs`):
124/// * overlapping: When set to True, it means when pooling, the values at the boundary
125/// of adjacent pooling cells are used by both cells. For example:
126///
127/// `index 0 1 2 3 4`
128///
129/// `value 20 5 16 3 7`
130///
131/// If the pooling sequence is [0, 2, 4], then 16, at index 2 will be used twice.
132/// The result would be [41/3, 26/3] for fractional avg pooling.
133///
134/// Returns:
135/// * `Output`: 4-D. Gradients w.r.t. the input of `fractional_avg_pool`.
136class FractionalAvgPoolGrad {
137 public:
138 /// Optional attribute setters for FractionalAvgPoolGrad
139 struct Attrs {
140 /// When set to True, it means when pooling, the values at the boundary
141 /// of adjacent pooling cells are used by both cells. For example:
142 ///
143 /// `index 0 1 2 3 4`
144 ///
145 /// `value 20 5 16 3 7`
146 ///
147 /// If the pooling sequence is [0, 2, 4], then 16, at index 2 will be used twice.
148 /// The result would be [41/3, 26/3] for fractional avg pooling.
149 ///
150 /// Defaults to false
151 TF_MUST_USE_RESULT Attrs Overlapping(bool x) {
152 Attrs ret = *this;
153 ret.overlapping_ = x;
154 return ret;
155 }
156
157 bool overlapping_ = false;
158 };
159 FractionalAvgPoolGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input
160 orig_input_tensor_shape, ::tensorflow::Input
161 out_backprop, ::tensorflow::Input row_pooling_sequence,
162 ::tensorflow::Input col_pooling_sequence);
163 FractionalAvgPoolGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input
164 orig_input_tensor_shape, ::tensorflow::Input
165 out_backprop, ::tensorflow::Input row_pooling_sequence,
166 ::tensorflow::Input col_pooling_sequence, const
167 FractionalAvgPoolGrad::Attrs& attrs);
168 operator ::tensorflow::Output() const { return output; }
169 operator ::tensorflow::Input() const { return output; }
170 ::tensorflow::Node* node() const { return output.node(); }
171
172 static Attrs Overlapping(bool x) {
173 return Attrs().Overlapping(x);
174 }
175
176 Operation operation;
177 ::tensorflow::Output output;
178};
179
180/// Computes gradient of the FractionalMaxPool function.
181///
182/// Args:
183/// * scope: A Scope object
184/// * orig_input: Original input for `fractional_max_pool`
185/// * orig_output: Original output for `fractional_max_pool`
186/// * out_backprop: 4-D with shape `[batch, height, width, channels]`. Gradients
187/// w.r.t. the output of `fractional_max_pool`.
188/// * row_pooling_sequence: row pooling sequence, form pooling region with
189/// col_pooling_sequence.
190/// * col_pooling_sequence: column pooling sequence, form pooling region with
191/// row_pooling sequence.
192///
193/// Optional attributes (see `Attrs`):
194/// * overlapping: When set to True, it means when pooling, the values at the boundary
195/// of adjacent pooling cells are used by both cells. For example:
196///
197/// `index 0 1 2 3 4`
198///
199/// `value 20 5 16 3 7`
200///
201/// If the pooling sequence is [0, 2, 4], then 16, at index 2 will be used twice.
202/// The result would be [20, 16] for fractional max pooling.
203///
204/// Returns:
205/// * `Output`: 4-D. Gradients w.r.t. the input of `fractional_max_pool`.
206class FractionalMaxPoolGrad {
207 public:
208 /// Optional attribute setters for FractionalMaxPoolGrad
209 struct Attrs {
210 /// When set to True, it means when pooling, the values at the boundary
211 /// of adjacent pooling cells are used by both cells. For example:
212 ///
213 /// `index 0 1 2 3 4`
214 ///
215 /// `value 20 5 16 3 7`
216 ///
217 /// If the pooling sequence is [0, 2, 4], then 16, at index 2 will be used twice.
218 /// The result would be [20, 16] for fractional max pooling.
219 ///
220 /// Defaults to false
221 TF_MUST_USE_RESULT Attrs Overlapping(bool x) {
222 Attrs ret = *this;
223 ret.overlapping_ = x;
224 return ret;
225 }
226
227 bool overlapping_ = false;
228 };
229 FractionalMaxPoolGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input
230 orig_input, ::tensorflow::Input orig_output,
231 ::tensorflow::Input out_backprop, ::tensorflow::Input
232 row_pooling_sequence, ::tensorflow::Input
233 col_pooling_sequence);
234 FractionalMaxPoolGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input
235 orig_input, ::tensorflow::Input orig_output,
236 ::tensorflow::Input out_backprop, ::tensorflow::Input
237 row_pooling_sequence, ::tensorflow::Input
238 col_pooling_sequence, const FractionalMaxPoolGrad::Attrs&
239 attrs);
240 operator ::tensorflow::Output() const { return output; }
241 operator ::tensorflow::Input() const { return output; }
242 ::tensorflow::Node* node() const { return output.node(); }
243
244 static Attrs Overlapping(bool x) {
245 return Attrs().Overlapping(x);
246 }
247
248 Operation operation;
249 ::tensorflow::Output output;
250};
251
252/// Solves a batch of isotonic regression problems.
253///
254/// Args:
255/// * scope: A Scope object
256/// * input: A (batch_size, dim)-tensor holding a batch of inputs.
257///
258/// Optional attributes (see `Attrs`):
259/// * output_dtype: Dtype of output.
260///
261/// Returns:
262/// * `Output` output: A (batch_size, dim)-tensor holding the per-batch element solutions.
263/// * `Output` segments: An int32 (batch_size, dim)-tensor with the segments.
264class IsotonicRegression {
265 public:
266 /// Optional attribute setters for IsotonicRegression
267 struct Attrs {
268 /// Dtype of output.
269 ///
270 /// Defaults to DT_FLOAT
271 TF_MUST_USE_RESULT Attrs OutputDtype(DataType x) {
272 Attrs ret = *this;
273 ret.output_dtype_ = x;
274 return ret;
275 }
276
277 DataType output_dtype_ = DT_FLOAT;
278 };
279 IsotonicRegression(const ::tensorflow::Scope& scope, ::tensorflow::Input input);
280 IsotonicRegression(const ::tensorflow::Scope& scope, ::tensorflow::Input input,
281 const IsotonicRegression::Attrs& attrs);
282
283 static Attrs OutputDtype(DataType x) {
284 return Attrs().OutputDtype(x);
285 }
286
287 Operation operation;
288 ::tensorflow::Output output;
289 ::tensorflow::Output segments;
290};
291
292/// Gradients for Local Response Normalization.
293///
294/// Args:
295/// * scope: A Scope object
296/// * input_grads: 4-D with shape `[batch, height, width, channels]`.
297/// * input_image: 4-D with shape `[batch, height, width, channels]`.
298/// * output_image: 4-D with shape `[batch, height, width, channels]`.
299///
300/// Optional attributes (see `Attrs`):
301/// * depth_radius: A depth radius.
302/// * bias: An offset (usually > 0 to avoid dividing by 0).
303/// * alpha: A scale factor, usually positive.
304/// * beta: An exponent.
305///
306/// Returns:
307/// * `Output`: The gradients for LRN.
308class LRNGrad {
309 public:
310 /// Optional attribute setters for LRNGrad
311 struct Attrs {
312 /// A depth radius.
313 ///
314 /// Defaults to 5
315 TF_MUST_USE_RESULT Attrs DepthRadius(int64 x) {
316 Attrs ret = *this;
317 ret.depth_radius_ = x;
318 return ret;
319 }
320
321 /// An offset (usually > 0 to avoid dividing by 0).
322 ///
323 /// Defaults to 1
324 TF_MUST_USE_RESULT Attrs Bias(float x) {
325 Attrs ret = *this;
326 ret.bias_ = x;
327 return ret;
328 }
329
330 /// A scale factor, usually positive.
331 ///
332 /// Defaults to 1
333 TF_MUST_USE_RESULT Attrs Alpha(float x) {
334 Attrs ret = *this;
335 ret.alpha_ = x;
336 return ret;
337 }
338
339 /// An exponent.
340 ///
341 /// Defaults to 0.5
342 TF_MUST_USE_RESULT Attrs Beta(float x) {
343 Attrs ret = *this;
344 ret.beta_ = x;
345 return ret;
346 }
347
348 int64 depth_radius_ = 5;
349 float bias_ = 1.0f;
350 float alpha_ = 1.0f;
351 float beta_ = 0.5f;
352 };
353 LRNGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input input_grads,
354 ::tensorflow::Input input_image, ::tensorflow::Input output_image);
355 LRNGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input input_grads,
356 ::tensorflow::Input input_image, ::tensorflow::Input output_image,
357 const LRNGrad::Attrs& attrs);
358 operator ::tensorflow::Output() const { return output; }
359 operator ::tensorflow::Input() const { return output; }
360 ::tensorflow::Node* node() const { return output.node(); }
361
362 static Attrs DepthRadius(int64 x) {
363 return Attrs().DepthRadius(x);
364 }
365 static Attrs Bias(float x) {
366 return Attrs().Bias(x);
367 }
368 static Attrs Alpha(float x) {
369 return Attrs().Alpha(x);
370 }
371 static Attrs Beta(float x) {
372 return Attrs().Beta(x);
373 }
374
375 Operation operation;
376 ::tensorflow::Output output;
377};
378
379/// Computes rectified linear: `max(features, features * alpha)`.
380///
381/// Args:
382/// * scope: A Scope object
383///
384/// Returns:
385/// * `Output`: The activations tensor.
386class LeakyRelu {
387 public:
388 /// Optional attribute setters for LeakyRelu
389 struct Attrs {
390 /// Defaults to 0.2
391 TF_MUST_USE_RESULT Attrs Alpha(float x) {
392 Attrs ret = *this;
393 ret.alpha_ = x;
394 return ret;
395 }
396
397 float alpha_ = 0.2f;
398 };
399 LeakyRelu(const ::tensorflow::Scope& scope, ::tensorflow::Input features);
400 LeakyRelu(const ::tensorflow::Scope& scope, ::tensorflow::Input features, const
401 LeakyRelu::Attrs& attrs);
402 operator ::tensorflow::Output() const { return activations; }
403 operator ::tensorflow::Input() const { return activations; }
404 ::tensorflow::Node* node() const { return activations.node(); }
405
406 static Attrs Alpha(float x) {
407 return Attrs().Alpha(x);
408 }
409
410 Operation operation;
411 ::tensorflow::Output activations;
412};
413
414/// Computes rectified linear gradients for a LeakyRelu operation.
415///
416/// Args:
417/// * scope: A Scope object
418/// * gradients: The backpropagated gradients to the corresponding LeakyRelu operation.
419/// * features: The features passed as input to the corresponding LeakyRelu operation,
420/// OR the outputs of that operation (both work equivalently).
421///
422/// Returns:
423/// * `Output`: `gradients * (features > 0) + alpha * gradients * (features <= 0)`.
424class LeakyReluGrad {
425 public:
426 /// Optional attribute setters for LeakyReluGrad
427 struct Attrs {
428 /// Defaults to 0.2
429 TF_MUST_USE_RESULT Attrs Alpha(float x) {
430 Attrs ret = *this;
431 ret.alpha_ = x;
432 return ret;
433 }
434
435 float alpha_ = 0.2f;
436 };
437 LeakyReluGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input gradients,
438 ::tensorflow::Input features);
439 LeakyReluGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input gradients,
440 ::tensorflow::Input features, const LeakyReluGrad::Attrs& attrs);
441 operator ::tensorflow::Output() const { return backprops; }
442 operator ::tensorflow::Input() const { return backprops; }
443 ::tensorflow::Node* node() const { return backprops.node(); }
444
445 static Attrs Alpha(float x) {
446 return Attrs().Alpha(x);
447 }
448
449 Operation operation;
450 ::tensorflow::Output backprops;
451};
452
453/// Computes gradients of the maxpooling function.
454///
455/// Args:
456/// * scope: A Scope object
457/// * orig_input: The original input tensor.
458/// * orig_output: The original output tensor.
459/// * grad: 4-D. Gradients w.r.t. the output of `max_pool`.
460/// * ksize: The size of the window for each dimension of the input tensor.
461/// * strides: The stride of the sliding window for each dimension of the
462/// input tensor.
463/// * padding: The type of padding algorithm to use.
464///
465/// Optional attributes (see `Attrs`):
466/// * data_format: Specify the data format of the input and output data. With the
467/// default format "NHWC", the data is stored in the order of:
468/// [batch, in_height, in_width, in_channels].
469/// Alternatively, the format could be "NCHW", the data storage order of:
470/// [batch, in_channels, in_height, in_width].
471///
472/// Returns:
473/// * `Output`: Gradients w.r.t. the input to `max_pool`.
474class MaxPoolGrad {
475 public:
476 /// Optional attribute setters for MaxPoolGrad
477 struct Attrs {
478 /// Defaults to []
479 TF_MUST_USE_RESULT Attrs ExplicitPaddings(const gtl::ArraySlice<int>& x) {
480 Attrs ret = *this;
481 ret.explicit_paddings_ = x;
482 return ret;
483 }
484
485 /// Specify the data format of the input and output data. With the
486 /// default format "NHWC", the data is stored in the order of:
487 /// [batch, in_height, in_width, in_channels].
488 /// Alternatively, the format could be "NCHW", the data storage order of:
489 /// [batch, in_channels, in_height, in_width].
490 ///
491 /// Defaults to "NHWC"
492 TF_MUST_USE_RESULT Attrs DataFormat(StringPiece x) {
493 Attrs ret = *this;
494 ret.data_format_ = x;
495 return ret;
496 }
497
498 gtl::ArraySlice<int> explicit_paddings_ = {};
499 StringPiece data_format_ = "NHWC";
500 };
501 MaxPoolGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input orig_input,
502 ::tensorflow::Input orig_output, ::tensorflow::Input grad, const
503 gtl::ArraySlice<int>& ksize, const gtl::ArraySlice<int>& strides,
504 StringPiece padding);
505 MaxPoolGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input orig_input,
506 ::tensorflow::Input orig_output, ::tensorflow::Input grad, const
507 gtl::ArraySlice<int>& ksize, const gtl::ArraySlice<int>& strides,
508 StringPiece padding, const MaxPoolGrad::Attrs& attrs);
509 operator ::tensorflow::Output() const { return output; }
510 operator ::tensorflow::Input() const { return output; }
511 ::tensorflow::Node* node() const { return output.node(); }
512
513 static Attrs ExplicitPaddings(const gtl::ArraySlice<int>& x) {
514 return Attrs().ExplicitPaddings(x);
515 }
516 static Attrs DataFormat(StringPiece x) {
517 return Attrs().DataFormat(x);
518 }
519
520 Operation operation;
521 ::tensorflow::Output output;
522};
523
524/// Computes gradients of the maxpooling function.
525///
526/// Args:
527/// * scope: A Scope object
528/// * input: The original input.
529/// * grad: 4-D with shape `[batch, height, width, channels]`. Gradients w.r.t. the
530/// output of `max_pool`.
531/// * argmax: The indices of the maximum values chosen for each output of `max_pool`.
532/// * ksize: The size of the window for each dimension of the input tensor.
533/// * strides: The stride of the sliding window for each dimension of the
534/// input tensor.
535/// * padding: The type of padding algorithm to use.
536///
537/// Optional attributes (see `Attrs`):
538/// * include_batch_in_index: Whether to include batch dimension in flattened index of `argmax`.
539///
540/// Returns:
541/// * `Output`: Gradients w.r.t. the input of `max_pool`.
542class MaxPoolGradWithArgmax {
543 public:
544 /// Optional attribute setters for MaxPoolGradWithArgmax
545 struct Attrs {
546 /// Whether to include batch dimension in flattened index of `argmax`.
547 ///
548 /// Defaults to false
549 TF_MUST_USE_RESULT Attrs IncludeBatchInIndex(bool x) {
550 Attrs ret = *this;
551 ret.include_batch_in_index_ = x;
552 return ret;
553 }
554
555 bool include_batch_in_index_ = false;
556 };
557 MaxPoolGradWithArgmax(const ::tensorflow::Scope& scope, ::tensorflow::Input
558 input, ::tensorflow::Input grad, ::tensorflow::Input
559 argmax, const gtl::ArraySlice<int>& ksize, const
560 gtl::ArraySlice<int>& strides, StringPiece padding);
561 MaxPoolGradWithArgmax(const ::tensorflow::Scope& scope, ::tensorflow::Input
562 input, ::tensorflow::Input grad, ::tensorflow::Input
563 argmax, const gtl::ArraySlice<int>& ksize, const
564 gtl::ArraySlice<int>& strides, StringPiece padding, const
565 MaxPoolGradWithArgmax::Attrs& attrs);
566 operator ::tensorflow::Output() const { return output; }
567 operator ::tensorflow::Input() const { return output; }
568 ::tensorflow::Node* node() const { return output.node(); }
569
570 static Attrs IncludeBatchInIndex(bool x) {
571 return Attrs().IncludeBatchInIndex(x);
572 }
573
574 Operation operation;
575 ::tensorflow::Output output;
576};
577
578/// TODO: add doc.
579///
580/// Args:
581/// * scope: A Scope object
582///
583/// Returns:
584/// * `Output` output
585/// * `Output` min_output
586/// * `Output` max_output
587class QuantizedConv2DAndRelu {
588 public:
589 /// Optional attribute setters for QuantizedConv2DAndRelu
590 struct Attrs {
591 /// Defaults to DT_QINT32
592 TF_MUST_USE_RESULT Attrs OutType(DataType x) {
593 Attrs ret = *this;
594 ret.out_type_ = x;
595 return ret;
596 }
597
598 /// Defaults to [1, 1, 1, 1]
599 TF_MUST_USE_RESULT Attrs Dilations(const gtl::ArraySlice<int>& x) {
600 Attrs ret = *this;
601 ret.dilations_ = x;
602 return ret;
603 }
604
605 /// Defaults to []
606 TF_MUST_USE_RESULT Attrs PaddingList(const gtl::ArraySlice<int>& x) {
607 Attrs ret = *this;
608 ret.padding_list_ = x;
609 return ret;
610 }
611
612 DataType out_type_ = DT_QINT32;
613 gtl::ArraySlice<int> dilations_ = Default_dilations();
614 gtl::ArraySlice<int> padding_list_ = {};
615 private:
616 static gtl::ArraySlice<int> Default_dilations() {
617 static const int kStorage[] = {1, 1, 1, 1};
618 return gtl::ArraySlice<int>(kStorage);
619 }
620 };
621 QuantizedConv2DAndRelu(const ::tensorflow::Scope& scope, ::tensorflow::Input
622 input, ::tensorflow::Input filter, ::tensorflow::Input
623 min_input, ::tensorflow::Input max_input,
624 ::tensorflow::Input min_filter, ::tensorflow::Input
625 max_filter, const gtl::ArraySlice<int>& strides,
626 StringPiece padding);
627 QuantizedConv2DAndRelu(const ::tensorflow::Scope& scope, ::tensorflow::Input
628 input, ::tensorflow::Input filter, ::tensorflow::Input
629 min_input, ::tensorflow::Input max_input,
630 ::tensorflow::Input min_filter, ::tensorflow::Input
631 max_filter, const gtl::ArraySlice<int>& strides,
632 StringPiece padding, const
633 QuantizedConv2DAndRelu::Attrs& attrs);
634
635 static Attrs OutType(DataType x) {
636 return Attrs().OutType(x);
637 }
638 static Attrs Dilations(const gtl::ArraySlice<int>& x) {
639 return Attrs().Dilations(x);
640 }
641 static Attrs PaddingList(const gtl::ArraySlice<int>& x) {
642 return Attrs().PaddingList(x);
643 }
644
645 Operation operation;
646 ::tensorflow::Output output;
647 ::tensorflow::Output min_output;
648 ::tensorflow::Output max_output;
649};
650
651/// TODO: add doc.
652///
653/// Args:
654/// * scope: A Scope object
655///
656/// Returns:
657/// * `Output` output
658/// * `Output` min_output
659/// * `Output` max_output
660class QuantizedConv2DAndReluAndRequantize {
661 public:
662 /// Optional attribute setters for QuantizedConv2DAndReluAndRequantize
663 struct Attrs {
664 /// Defaults to DT_QUINT8
665 TF_MUST_USE_RESULT Attrs OutType(DataType x) {
666 Attrs ret = *this;
667 ret.out_type_ = x;
668 return ret;
669 }
670
671 /// Defaults to [1, 1, 1, 1]
672 TF_MUST_USE_RESULT Attrs Dilations(const gtl::ArraySlice<int>& x) {
673 Attrs ret = *this;
674 ret.dilations_ = x;
675 return ret;
676 }
677
678 /// Defaults to []
679 TF_MUST_USE_RESULT Attrs PaddingList(const gtl::ArraySlice<int>& x) {
680 Attrs ret = *this;
681 ret.padding_list_ = x;
682 return ret;
683 }
684
685 DataType out_type_ = DT_QUINT8;
686 gtl::ArraySlice<int> dilations_ = Default_dilations();
687 gtl::ArraySlice<int> padding_list_ = {};
688 private:
689 static gtl::ArraySlice<int> Default_dilations() {
690 static const int kStorage[] = {1, 1, 1, 1};
691 return gtl::ArraySlice<int>(kStorage);
692 }
693 };
694 QuantizedConv2DAndReluAndRequantize(const ::tensorflow::Scope& scope,
695 ::tensorflow::Input input,
696 ::tensorflow::Input filter,
697 ::tensorflow::Input min_input,
698 ::tensorflow::Input max_input,
699 ::tensorflow::Input min_filter,
700 ::tensorflow::Input max_filter,
701 ::tensorflow::Input min_freezed_output,
702 ::tensorflow::Input max_freezed_output,
703 const gtl::ArraySlice<int>& strides,
704 StringPiece padding);
705 QuantizedConv2DAndReluAndRequantize(const ::tensorflow::Scope& scope,
706 ::tensorflow::Input input,
707 ::tensorflow::Input filter,
708 ::tensorflow::Input min_input,
709 ::tensorflow::Input max_input,
710 ::tensorflow::Input min_filter,
711 ::tensorflow::Input max_filter,
712 ::tensorflow::Input min_freezed_output,
713 ::tensorflow::Input max_freezed_output,
714 const gtl::ArraySlice<int>& strides,
715 StringPiece padding, const
716 QuantizedConv2DAndReluAndRequantize::Attrs&
717 attrs);
718
719 static Attrs OutType(DataType x) {
720 return Attrs().OutType(x);
721 }
722 static Attrs Dilations(const gtl::ArraySlice<int>& x) {
723 return Attrs().Dilations(x);
724 }
725 static Attrs PaddingList(const gtl::ArraySlice<int>& x) {
726 return Attrs().PaddingList(x);
727 }
728
729 Operation operation;
730 ::tensorflow::Output output;
731 ::tensorflow::Output min_output;
732 ::tensorflow::Output max_output;
733};
734
735/// TODO: add doc.
736///
737/// Args:
738/// * scope: A Scope object
739///
740/// Returns:
741/// * `Output` output
742/// * `Output` min_output
743/// * `Output` max_output
744class QuantizedConv2DAndRequantize {
745 public:
746 /// Optional attribute setters for QuantizedConv2DAndRequantize
747 struct Attrs {
748 /// Defaults to DT_QINT8
749 TF_MUST_USE_RESULT Attrs OutType(DataType x) {
750 Attrs ret = *this;
751 ret.out_type_ = x;
752 return ret;
753 }
754
755 /// Defaults to [1, 1, 1, 1]
756 TF_MUST_USE_RESULT Attrs Dilations(const gtl::ArraySlice<int>& x) {
757 Attrs ret = *this;
758 ret.dilations_ = x;
759 return ret;
760 }
761
762 /// Defaults to []
763 TF_MUST_USE_RESULT Attrs PaddingList(const gtl::ArraySlice<int>& x) {
764 Attrs ret = *this;
765 ret.padding_list_ = x;
766 return ret;
767 }
768
769 DataType out_type_ = DT_QINT8;
770 gtl::ArraySlice<int> dilations_ = Default_dilations();
771 gtl::ArraySlice<int> padding_list_ = {};
772 private:
773 static gtl::ArraySlice<int> Default_dilations() {
774 static const int kStorage[] = {1, 1, 1, 1};
775 return gtl::ArraySlice<int>(kStorage);
776 }
777 };
778 QuantizedConv2DAndRequantize(const ::tensorflow::Scope& scope,
779 ::tensorflow::Input input, ::tensorflow::Input
780 filter, ::tensorflow::Input min_input,
781 ::tensorflow::Input max_input, ::tensorflow::Input
782 min_filter, ::tensorflow::Input max_filter,
783 ::tensorflow::Input min_freezed_output,
784 ::tensorflow::Input max_freezed_output, const
785 gtl::ArraySlice<int>& strides, StringPiece
786 padding);
787 QuantizedConv2DAndRequantize(const ::tensorflow::Scope& scope,
788 ::tensorflow::Input input, ::tensorflow::Input
789 filter, ::tensorflow::Input min_input,
790 ::tensorflow::Input max_input, ::tensorflow::Input
791 min_filter, ::tensorflow::Input max_filter,
792 ::tensorflow::Input min_freezed_output,
793 ::tensorflow::Input max_freezed_output, const
794 gtl::ArraySlice<int>& strides, StringPiece
795 padding, const
796 QuantizedConv2DAndRequantize::Attrs& attrs);
797
798 static Attrs OutType(DataType x) {
799 return Attrs().OutType(x);
800 }
801 static Attrs Dilations(const gtl::ArraySlice<int>& x) {
802 return Attrs().Dilations(x);
803 }
804 static Attrs PaddingList(const gtl::ArraySlice<int>& x) {
805 return Attrs().PaddingList(x);
806 }
807
808 Operation operation;
809 ::tensorflow::Output output;
810 ::tensorflow::Output min_output;
811 ::tensorflow::Output max_output;
812};
813
814/// Computes QuantizedConv2D per channel.
815///
816/// Args:
817/// * scope: A Scope object
818/// * input: The original input tensor.
819/// * filter: The original filter tensor.
820/// * min_input: The minimum value of the input tensor
821/// * max_input: The maximum value of the input tensor.
822/// * min_filter: The minimum value of the filter tensor.
823/// * max_filter: The maximum value of the filter tensor.
824/// * strides: list of stride values.
825///
826/// Optional attributes (see `Attrs`):
827/// * out_type: The quantized type of output tensor that needs to be converted.
828/// * dilations: list of dilation values.
829///
830/// Returns:
831/// * `Output` output: The output tensor.
832/// * `Output` min_output: The minimum value of the final output tensor.
833/// * `Output` max_output: The maximum value of the final output tensor.
834class QuantizedConv2DPerChannel {
835 public:
836 /// Optional attribute setters for QuantizedConv2DPerChannel
837 struct Attrs {
838 /// The quantized type of output tensor that needs to be converted.
839 ///
840 /// Defaults to DT_QINT32
841 TF_MUST_USE_RESULT Attrs OutType(DataType x) {
842 Attrs ret = *this;
843 ret.out_type_ = x;
844 return ret;
845 }
846
847 /// list of dilation values.
848 ///
849 /// Defaults to [1, 1, 1, 1]
850 TF_MUST_USE_RESULT Attrs Dilations(const gtl::ArraySlice<int>& x) {
851 Attrs ret = *this;
852 ret.dilations_ = x;
853 return ret;
854 }
855
856 DataType out_type_ = DT_QINT32;
857 gtl::ArraySlice<int> dilations_ = Default_dilations();
858 private:
859 static gtl::ArraySlice<int> Default_dilations() {
860 static const int kStorage[] = {1, 1, 1, 1};
861 return gtl::ArraySlice<int>(kStorage);
862 }
863 };
864 QuantizedConv2DPerChannel(const ::tensorflow::Scope& scope, ::tensorflow::Input
865 input, ::tensorflow::Input filter,
866 ::tensorflow::Input min_input, ::tensorflow::Input
867 max_input, ::tensorflow::Input min_filter,
868 ::tensorflow::Input max_filter, const
869 gtl::ArraySlice<int>& strides, StringPiece padding);
870 QuantizedConv2DPerChannel(const ::tensorflow::Scope& scope, ::tensorflow::Input
871 input, ::tensorflow::Input filter,
872 ::tensorflow::Input min_input, ::tensorflow::Input
873 max_input, ::tensorflow::Input min_filter,
874 ::tensorflow::Input max_filter, const
875 gtl::ArraySlice<int>& strides, StringPiece padding,
876 const QuantizedConv2DPerChannel::Attrs& attrs);
877
878 static Attrs OutType(DataType x) {
879 return Attrs().OutType(x);
880 }
881 static Attrs Dilations(const gtl::ArraySlice<int>& x) {
882 return Attrs().Dilations(x);
883 }
884
885 Operation operation;
886 ::tensorflow::Output output;
887 ::tensorflow::Output min_output;
888 ::tensorflow::Output max_output;
889};
890
891/// TODO: add doc.
892///
893/// Args:
894/// * scope: A Scope object
895///
896/// Returns:
897/// * `Output` output
898/// * `Output` min_output
899/// * `Output` max_output
900class QuantizedConv2DWithBias {
901 public:
902 /// Optional attribute setters for QuantizedConv2DWithBias
903 struct Attrs {
904 /// Defaults to DT_QINT32
905 TF_MUST_USE_RESULT Attrs OutType(DataType x) {
906 Attrs ret = *this;
907 ret.out_type_ = x;
908 return ret;
909 }
910
911 /// Defaults to [1, 1, 1, 1]
912 TF_MUST_USE_RESULT Attrs Dilations(const gtl::ArraySlice<int>& x) {
913 Attrs ret = *this;
914 ret.dilations_ = x;
915 return ret;
916 }
917
918 /// Defaults to []
919 TF_MUST_USE_RESULT Attrs PaddingList(const gtl::ArraySlice<int>& x) {
920 Attrs ret = *this;
921 ret.padding_list_ = x;
922 return ret;
923 }
924
925 DataType out_type_ = DT_QINT32;
926 gtl::ArraySlice<int> dilations_ = Default_dilations();
927 gtl::ArraySlice<int> padding_list_ = {};
928 private:
929 static gtl::ArraySlice<int> Default_dilations() {
930 static const int kStorage[] = {1, 1, 1, 1};
931 return gtl::ArraySlice<int>(kStorage);
932 }
933 };
934 QuantizedConv2DWithBias(const ::tensorflow::Scope& scope, ::tensorflow::Input
935 input, ::tensorflow::Input filter, ::tensorflow::Input
936 bias, ::tensorflow::Input min_input,
937 ::tensorflow::Input max_input, ::tensorflow::Input
938 min_filter, ::tensorflow::Input max_filter, const
939 gtl::ArraySlice<int>& strides, StringPiece padding);
940 QuantizedConv2DWithBias(const ::tensorflow::Scope& scope, ::tensorflow::Input
941 input, ::tensorflow::Input filter, ::tensorflow::Input
942 bias, ::tensorflow::Input min_input,
943 ::tensorflow::Input max_input, ::tensorflow::Input
944 min_filter, ::tensorflow::Input max_filter, const
945 gtl::ArraySlice<int>& strides, StringPiece padding,
946 const QuantizedConv2DWithBias::Attrs& attrs);
947
948 static Attrs OutType(DataType x) {
949 return Attrs().OutType(x);
950 }
951 static Attrs Dilations(const gtl::ArraySlice<int>& x) {
952 return Attrs().Dilations(x);
953 }
954 static Attrs PaddingList(const gtl::ArraySlice<int>& x) {
955 return Attrs().PaddingList(x);
956 }
957
958 Operation operation;
959 ::tensorflow::Output output;
960 ::tensorflow::Output min_output;
961 ::tensorflow::Output max_output;
962};
963
964/// TODO: add doc.
965///
966/// Args:
967/// * scope: A Scope object
968///
969/// Returns:
970/// * `Output` output
971/// * `Output` min_output
972/// * `Output` max_output
973class QuantizedConv2DWithBiasAndRelu {
974 public:
975 /// Optional attribute setters for QuantizedConv2DWithBiasAndRelu
976 struct Attrs {
977 /// Defaults to DT_QINT32
978 TF_MUST_USE_RESULT Attrs OutType(DataType x) {
979 Attrs ret = *this;
980 ret.out_type_ = x;
981 return ret;
982 }
983
984 /// Defaults to [1, 1, 1, 1]
985 TF_MUST_USE_RESULT Attrs Dilations(const gtl::ArraySlice<int>& x) {
986 Attrs ret = *this;
987 ret.dilations_ = x;
988 return ret;
989 }
990
991 /// Defaults to []
992 TF_MUST_USE_RESULT Attrs PaddingList(const gtl::ArraySlice<int>& x) {
993 Attrs ret = *this;
994 ret.padding_list_ = x;
995 return ret;
996 }
997
998 DataType out_type_ = DT_QINT32;
999 gtl::ArraySlice<int> dilations_ = Default_dilations();
1000 gtl::ArraySlice<int> padding_list_ = {};
1001 private:
1002 static gtl::ArraySlice<int> Default_dilations() {
1003 static const int kStorage[] = {1, 1, 1, 1};
1004 return gtl::ArraySlice<int>(kStorage);
1005 }
1006 };
1007 QuantizedConv2DWithBiasAndRelu(const ::tensorflow::Scope& scope,
1008 ::tensorflow::Input input, ::tensorflow::Input
1009 filter, ::tensorflow::Input bias,
1010 ::tensorflow::Input min_input,
1011 ::tensorflow::Input max_input,
1012 ::tensorflow::Input min_filter,
1013 ::tensorflow::Input max_filter, const
1014 gtl::ArraySlice<int>& strides, StringPiece
1015 padding);
1016 QuantizedConv2DWithBiasAndRelu(const ::tensorflow::Scope& scope,
1017 ::tensorflow::Input input, ::tensorflow::Input
1018 filter, ::tensorflow::Input bias,
1019 ::tensorflow::Input min_input,
1020 ::tensorflow::Input max_input,
1021 ::tensorflow::Input min_filter,
1022 ::tensorflow::Input max_filter, const
1023 gtl::ArraySlice<int>& strides, StringPiece
1024 padding, const
1025 QuantizedConv2DWithBiasAndRelu::Attrs& attrs);
1026
1027 static Attrs OutType(DataType x) {
1028 return Attrs().OutType(x);
1029 }
1030 static Attrs Dilations(const gtl::ArraySlice<int>& x) {
1031 return Attrs().Dilations(x);
1032 }
1033 static Attrs PaddingList(const gtl::ArraySlice<int>& x) {
1034 return Attrs().PaddingList(x);
1035 }
1036
1037 Operation operation;
1038 ::tensorflow::Output output;
1039 ::tensorflow::Output min_output;
1040 ::tensorflow::Output max_output;
1041};
1042
1043/// TODO: add doc.
1044///
1045/// Args:
1046/// * scope: A Scope object
1047///
1048/// Returns:
1049/// * `Output` output
1050/// * `Output` min_output
1051/// * `Output` max_output
1052class QuantizedConv2DWithBiasAndReluAndRequantize {
1053 public:
1054 /// Optional attribute setters for QuantizedConv2DWithBiasAndReluAndRequantize
1055 struct Attrs {
1056 /// Defaults to DT_QUINT8
1057 TF_MUST_USE_RESULT Attrs OutType(DataType x) {
1058 Attrs ret = *this;
1059 ret.out_type_ = x;
1060 return ret;
1061 }
1062
1063 /// Defaults to [1, 1, 1, 1]
1064 TF_MUST_USE_RESULT Attrs Dilations(const gtl::ArraySlice<int>& x) {
1065 Attrs ret = *this;
1066 ret.dilations_ = x;
1067 return ret;
1068 }
1069
1070 /// Defaults to []
1071 TF_MUST_USE_RESULT Attrs PaddingList(const gtl::ArraySlice<int>& x) {
1072 Attrs ret = *this;
1073 ret.padding_list_ = x;
1074 return ret;
1075 }
1076
1077 DataType out_type_ = DT_QUINT8;
1078 gtl::ArraySlice<int> dilations_ = Default_dilations();
1079 gtl::ArraySlice<int> padding_list_ = {};
1080 private:
1081 static gtl::ArraySlice<int> Default_dilations() {
1082 static const int kStorage[] = {1, 1, 1, 1};
1083 return gtl::ArraySlice<int>(kStorage);
1084 }
1085 };
1086 QuantizedConv2DWithBiasAndReluAndRequantize(const ::tensorflow::Scope& scope,
1087 ::tensorflow::Input input,
1088 ::tensorflow::Input filter,
1089 ::tensorflow::Input bias,
1090 ::tensorflow::Input min_input,
1091 ::tensorflow::Input max_input,
1092 ::tensorflow::Input min_filter,
1093 ::tensorflow::Input max_filter,
1094 ::tensorflow::Input
1095 min_freezed_output,
1096 ::tensorflow::Input
1097 max_freezed_output, const
1098 gtl::ArraySlice<int>& strides,
1099 StringPiece padding);
1100 QuantizedConv2DWithBiasAndReluAndRequantize(const ::tensorflow::Scope& scope,
1101 ::tensorflow::Input input,
1102 ::tensorflow::Input filter,
1103 ::tensorflow::Input bias,
1104 ::tensorflow::Input min_input,
1105 ::tensorflow::Input max_input,
1106 ::tensorflow::Input min_filter,
1107 ::tensorflow::Input max_filter,
1108 ::tensorflow::Input
1109 min_freezed_output,
1110 ::tensorflow::Input
1111 max_freezed_output, const
1112 gtl::ArraySlice<int>& strides,
1113 StringPiece padding, const
1114 QuantizedConv2DWithBiasAndReluAndRequantize::Attrs&
1115 attrs);
1116
1117 static Attrs OutType(DataType x) {
1118 return Attrs().OutType(x);
1119 }
1120 static Attrs Dilations(const gtl::ArraySlice<int>& x) {
1121 return Attrs().Dilations(x);
1122 }
1123 static Attrs PaddingList(const gtl::ArraySlice<int>& x) {
1124 return Attrs().PaddingList(x);
1125 }
1126
1127 Operation operation;
1128 ::tensorflow::Output output;
1129 ::tensorflow::Output min_output;
1130 ::tensorflow::Output max_output;
1131};
1132
1133/// TODO: add doc.
1134///
1135/// Args:
1136/// * scope: A Scope object
1137///
1138/// Returns:
1139/// * `Output` output
1140/// * `Output` min_output
1141/// * `Output` max_output
1142class QuantizedConv2DWithBiasAndRequantize {
1143 public:
1144 /// Optional attribute setters for QuantizedConv2DWithBiasAndRequantize
1145 struct Attrs {
1146 /// Defaults to DT_QINT8
1147 TF_MUST_USE_RESULT Attrs OutType(DataType x) {
1148 Attrs ret = *this;
1149 ret.out_type_ = x;
1150 return ret;
1151 }
1152
1153 /// Defaults to [1, 1, 1, 1]
1154 TF_MUST_USE_RESULT Attrs Dilations(const gtl::ArraySlice<int>& x) {
1155 Attrs ret = *this;
1156 ret.dilations_ = x;
1157 return ret;
1158 }
1159
1160 /// Defaults to []
1161 TF_MUST_USE_RESULT Attrs PaddingList(const gtl::ArraySlice<int>& x) {
1162 Attrs ret = *this;
1163 ret.padding_list_ = x;
1164 return ret;
1165 }
1166
1167 DataType out_type_ = DT_QINT8;
1168 gtl::ArraySlice<int> dilations_ = Default_dilations();
1169 gtl::ArraySlice<int> padding_list_ = {};
1170 private:
1171 static gtl::ArraySlice<int> Default_dilations() {
1172 static const int kStorage[] = {1, 1, 1, 1};
1173 return gtl::ArraySlice<int>(kStorage);
1174 }
1175 };
1176 QuantizedConv2DWithBiasAndRequantize(const ::tensorflow::Scope& scope,
1177 ::tensorflow::Input input,
1178 ::tensorflow::Input filter,
1179 ::tensorflow::Input bias,
1180 ::tensorflow::Input min_input,
1181 ::tensorflow::Input max_input,
1182 ::tensorflow::Input min_filter,
1183 ::tensorflow::Input max_filter,
1184 ::tensorflow::Input min_freezed_output,
1185 ::tensorflow::Input max_freezed_output,
1186 const gtl::ArraySlice<int>& strides,
1187 StringPiece padding);
1188 QuantizedConv2DWithBiasAndRequantize(const ::tensorflow::Scope& scope,
1189 ::tensorflow::Input input,
1190 ::tensorflow::Input filter,
1191 ::tensorflow::Input bias,
1192 ::tensorflow::Input min_input,
1193 ::tensorflow::Input max_input,
1194 ::tensorflow::Input min_filter,
1195 ::tensorflow::Input max_filter,
1196 ::tensorflow::Input min_freezed_output,
1197 ::tensorflow::Input max_freezed_output,
1198 const gtl::ArraySlice<int>& strides,
1199 StringPiece padding, const
1200 QuantizedConv2DWithBiasAndRequantize::Attrs&
1201 attrs);
1202
1203 static Attrs OutType(DataType x) {
1204 return Attrs().OutType(x);
1205 }
1206 static Attrs Dilations(const gtl::ArraySlice<int>& x) {
1207 return Attrs().Dilations(x);
1208 }
1209 static Attrs PaddingList(const gtl::ArraySlice<int>& x) {
1210 return Attrs().PaddingList(x);
1211 }
1212
1213 Operation operation;
1214 ::tensorflow::Output output;
1215 ::tensorflow::Output min_output;
1216 ::tensorflow::Output max_output;
1217};
1218
1219/// TODO: add doc.
1220///
1221/// Args:
1222/// * scope: A Scope object
1223///
1224/// Returns:
1225/// * `Output` output
1226/// * `Output` min_output
1227/// * `Output` max_output
1228class QuantizedConv2DWithBiasSignedSumAndReluAndRequantize {
1229 public:
1230 /// Optional attribute setters for QuantizedConv2DWithBiasSignedSumAndReluAndRequantize
1231 struct Attrs {
1232 /// Defaults to DT_QUINT8
1233 TF_MUST_USE_RESULT Attrs OutType(DataType x) {
1234 Attrs ret = *this;
1235 ret.out_type_ = x;
1236 return ret;
1237 }
1238
1239 /// Defaults to [1, 1, 1, 1]
1240 TF_MUST_USE_RESULT Attrs Dilations(const gtl::ArraySlice<int>& x) {
1241 Attrs ret = *this;
1242 ret.dilations_ = x;
1243 return ret;
1244 }
1245
1246 /// Defaults to []
1247 TF_MUST_USE_RESULT Attrs PaddingList(const gtl::ArraySlice<int>& x) {
1248 Attrs ret = *this;
1249 ret.padding_list_ = x;
1250 return ret;
1251 }
1252
1253 DataType out_type_ = DT_QUINT8;
1254 gtl::ArraySlice<int> dilations_ = Default_dilations();
1255 gtl::ArraySlice<int> padding_list_ = {};
1256 private:
1257 static gtl::ArraySlice<int> Default_dilations() {
1258 static const int kStorage[] = {1, 1, 1, 1};
1259 return gtl::ArraySlice<int>(kStorage);
1260 }
1261 };
1262 QuantizedConv2DWithBiasSignedSumAndReluAndRequantize(const ::tensorflow::Scope&
1263 scope, ::tensorflow::Input
1264 input, ::tensorflow::Input
1265 filter,
1266 ::tensorflow::Input bias,
1267 ::tensorflow::Input
1268 min_input,
1269 ::tensorflow::Input
1270 max_input,
1271 ::tensorflow::Input
1272 min_filter,
1273 ::tensorflow::Input
1274 max_filter,
1275 ::tensorflow::Input
1276 min_freezed_output,
1277 ::tensorflow::Input
1278 max_freezed_output,
1279 ::tensorflow::Input
1280 summand,
1281 ::tensorflow::Input
1282 min_summand,
1283 ::tensorflow::Input
1284 max_summand, const
1285 gtl::ArraySlice<int>&
1286 strides, StringPiece
1287 padding);
1288 QuantizedConv2DWithBiasSignedSumAndReluAndRequantize(const ::tensorflow::Scope&
1289 scope, ::tensorflow::Input
1290 input, ::tensorflow::Input
1291 filter,
1292 ::tensorflow::Input bias,
1293 ::tensorflow::Input
1294 min_input,
1295 ::tensorflow::Input
1296 max_input,
1297 ::tensorflow::Input
1298 min_filter,
1299 ::tensorflow::Input
1300 max_filter,
1301 ::tensorflow::Input
1302 min_freezed_output,
1303 ::tensorflow::Input
1304 max_freezed_output,
1305 ::tensorflow::Input
1306 summand,
1307 ::tensorflow::Input
1308 min_summand,
1309 ::tensorflow::Input
1310 max_summand, const
1311 gtl::ArraySlice<int>&
1312 strides, StringPiece
1313 padding, const
1314 QuantizedConv2DWithBiasSignedSumAndReluAndRequantize::Attrs&
1315 attrs);
1316
1317 static Attrs OutType(DataType x) {
1318 return Attrs().OutType(x);
1319 }
1320 static Attrs Dilations(const gtl::ArraySlice<int>& x) {
1321 return Attrs().Dilations(x);
1322 }
1323 static Attrs PaddingList(const gtl::ArraySlice<int>& x) {
1324 return Attrs().PaddingList(x);
1325 }
1326
1327 Operation operation;
1328 ::tensorflow::Output output;
1329 ::tensorflow::Output min_output;
1330 ::tensorflow::Output max_output;
1331};
1332
1333/// TODO: add doc.
1334///
1335/// Args:
1336/// * scope: A Scope object
1337///
1338/// Returns:
1339/// * `Output` output
1340/// * `Output` min_output
1341/// * `Output` max_output
1342class QuantizedConv2DWithBiasSumAndRelu {
1343 public:
1344 /// Optional attribute setters for QuantizedConv2DWithBiasSumAndRelu
1345 struct Attrs {
1346 /// Defaults to DT_QINT32
1347 TF_MUST_USE_RESULT Attrs OutType(DataType x) {
1348 Attrs ret = *this;
1349 ret.out_type_ = x;
1350 return ret;
1351 }
1352
1353 /// Defaults to [1, 1, 1, 1]
1354 TF_MUST_USE_RESULT Attrs Dilations(const gtl::ArraySlice<int>& x) {
1355 Attrs ret = *this;
1356 ret.dilations_ = x;
1357 return ret;
1358 }
1359
1360 /// Defaults to []
1361 TF_MUST_USE_RESULT Attrs PaddingList(const gtl::ArraySlice<int>& x) {
1362 Attrs ret = *this;
1363 ret.padding_list_ = x;
1364 return ret;
1365 }
1366
1367 DataType out_type_ = DT_QINT32;
1368 gtl::ArraySlice<int> dilations_ = Default_dilations();
1369 gtl::ArraySlice<int> padding_list_ = {};
1370 private:
1371 static gtl::ArraySlice<int> Default_dilations() {
1372 static const int kStorage[] = {1, 1, 1, 1};
1373 return gtl::ArraySlice<int>(kStorage);
1374 }
1375 };
1376 QuantizedConv2DWithBiasSumAndRelu(const ::tensorflow::Scope& scope,
1377 ::tensorflow::Input input,
1378 ::tensorflow::Input filter,
1379 ::tensorflow::Input bias, ::tensorflow::Input
1380 min_input, ::tensorflow::Input max_input,
1381 ::tensorflow::Input min_filter,
1382 ::tensorflow::Input max_filter,
1383 ::tensorflow::Input summand, const
1384 gtl::ArraySlice<int>& strides, StringPiece
1385 padding);
1386 QuantizedConv2DWithBiasSumAndRelu(const ::tensorflow::Scope& scope,
1387 ::tensorflow::Input input,
1388 ::tensorflow::Input filter,
1389 ::tensorflow::Input bias, ::tensorflow::Input
1390 min_input, ::tensorflow::Input max_input,
1391 ::tensorflow::Input min_filter,
1392 ::tensorflow::Input max_filter,
1393 ::tensorflow::Input summand, const
1394 gtl::ArraySlice<int>& strides, StringPiece
1395 padding, const
1396 QuantizedConv2DWithBiasSumAndRelu::Attrs&
1397 attrs);
1398
1399 static Attrs OutType(DataType x) {
1400 return Attrs().OutType(x);
1401 }
1402 static Attrs Dilations(const gtl::ArraySlice<int>& x) {
1403 return Attrs().Dilations(x);
1404 }
1405 static Attrs PaddingList(const gtl::ArraySlice<int>& x) {
1406 return Attrs().PaddingList(x);
1407 }
1408
1409 Operation operation;
1410 ::tensorflow::Output output;
1411 ::tensorflow::Output min_output;
1412 ::tensorflow::Output max_output;
1413};
1414
1415/// TODO: add doc.
1416///
1417/// Args:
1418/// * scope: A Scope object
1419///
1420/// Returns:
1421/// * `Output` output
1422/// * `Output` min_output
1423/// * `Output` max_output
1424class QuantizedConv2DWithBiasSumAndReluAndRequantize {
1425 public:
1426 /// Optional attribute setters for QuantizedConv2DWithBiasSumAndReluAndRequantize
1427 struct Attrs {
1428 /// Defaults to DT_QUINT8
1429 TF_MUST_USE_RESULT Attrs OutType(DataType x) {
1430 Attrs ret = *this;
1431 ret.out_type_ = x;
1432 return ret;
1433 }
1434
1435 /// Defaults to [1, 1, 1, 1]
1436 TF_MUST_USE_RESULT Attrs Dilations(const gtl::ArraySlice<int>& x) {
1437 Attrs ret = *this;
1438 ret.dilations_ = x;
1439 return ret;
1440 }
1441
1442 /// Defaults to []
1443 TF_MUST_USE_RESULT Attrs PaddingList(const gtl::ArraySlice<int>& x) {
1444 Attrs ret = *this;
1445 ret.padding_list_ = x;
1446 return ret;
1447 }
1448
1449 DataType out_type_ = DT_QUINT8;
1450 gtl::ArraySlice<int> dilations_ = Default_dilations();
1451 gtl::ArraySlice<int> padding_list_ = {};
1452 private:
1453 static gtl::ArraySlice<int> Default_dilations() {
1454 static const int kStorage[] = {1, 1, 1, 1};
1455 return gtl::ArraySlice<int>(kStorage);
1456 }
1457 };
1458 QuantizedConv2DWithBiasSumAndReluAndRequantize(const ::tensorflow::Scope&
1459 scope, ::tensorflow::Input
1460 input, ::tensorflow::Input
1461 filter, ::tensorflow::Input
1462 bias, ::tensorflow::Input
1463 min_input, ::tensorflow::Input
1464 max_input, ::tensorflow::Input
1465 min_filter, ::tensorflow::Input
1466 max_filter, ::tensorflow::Input
1467 min_freezed_output,
1468 ::tensorflow::Input
1469 max_freezed_output,
1470 ::tensorflow::Input summand,
1471 ::tensorflow::Input min_summand,
1472 ::tensorflow::Input max_summand,
1473 const gtl::ArraySlice<int>&
1474 strides, StringPiece padding);
1475 QuantizedConv2DWithBiasSumAndReluAndRequantize(const ::tensorflow::Scope&
1476 scope, ::tensorflow::Input
1477 input, ::tensorflow::Input
1478 filter, ::tensorflow::Input
1479 bias, ::tensorflow::Input
1480 min_input, ::tensorflow::Input
1481 max_input, ::tensorflow::Input
1482 min_filter, ::tensorflow::Input
1483 max_filter, ::tensorflow::Input
1484 min_freezed_output,
1485 ::tensorflow::Input
1486 max_freezed_output,
1487 ::tensorflow::Input summand,
1488 ::tensorflow::Input min_summand,
1489 ::tensorflow::Input max_summand,
1490 const gtl::ArraySlice<int>&
1491 strides, StringPiece padding,
1492 const
1493 QuantizedConv2DWithBiasSumAndReluAndRequantize::Attrs&
1494 attrs);
1495
1496 static Attrs OutType(DataType x) {
1497 return Attrs().OutType(x);
1498 }
1499 static Attrs Dilations(const gtl::ArraySlice<int>& x) {
1500 return Attrs().Dilations(x);
1501 }
1502 static Attrs PaddingList(const gtl::ArraySlice<int>& x) {
1503 return Attrs().PaddingList(x);
1504 }
1505
1506 Operation operation;
1507 ::tensorflow::Output output;
1508 ::tensorflow::Output min_output;
1509 ::tensorflow::Output max_output;
1510};
1511
1512/// Computes quantized depthwise Conv2D.
1513///
1514/// Args:
1515/// * scope: A Scope object
1516/// * input: The original input tensor.
1517/// * filter: The original filter tensor.
1518/// * min_input: The float value that the minimum quantized input value represents.
1519/// * max_input: The float value that the maximum quantized input value represents.
1520/// * min_filter: The float value that the minimum quantized filter value represents.
1521/// * max_filter: The float value that the maximum quantized filter value represents.
1522/// * strides: List of stride values.
1523///
1524/// Optional attributes (see `Attrs`):
1525/// * out_type: The type of the output.
1526/// * dilations: List of dilation values.
1527///
1528/// Returns:
1529/// * `Output` output: The output tensor.
1530/// * `Output` min_output: The float value that the minimum quantized output value represents.
1531/// * `Output` max_output: The float value that the maximum quantized output value represents.
1532class QuantizedDepthwiseConv2D {
1533 public:
1534 /// Optional attribute setters for QuantizedDepthwiseConv2D
1535 struct Attrs {
1536 /// The type of the output.
1537 ///
1538 /// Defaults to DT_QINT32
1539 TF_MUST_USE_RESULT Attrs OutType(DataType x) {
1540 Attrs ret = *this;
1541 ret.out_type_ = x;
1542 return ret;
1543 }
1544
1545 /// List of dilation values.
1546 ///
1547 /// Defaults to [1, 1, 1, 1]
1548 TF_MUST_USE_RESULT Attrs Dilations(const gtl::ArraySlice<int>& x) {
1549 Attrs ret = *this;
1550 ret.dilations_ = x;
1551 return ret;
1552 }
1553
1554 DataType out_type_ = DT_QINT32;
1555 gtl::ArraySlice<int> dilations_ = Default_dilations();
1556 private:
1557 static gtl::ArraySlice<int> Default_dilations() {
1558 static const int kStorage[] = {1, 1, 1, 1};
1559 return gtl::ArraySlice<int>(kStorage);
1560 }
1561 };
1562 QuantizedDepthwiseConv2D(const ::tensorflow::Scope& scope, ::tensorflow::Input
1563 input, ::tensorflow::Input filter, ::tensorflow::Input
1564 min_input, ::tensorflow::Input max_input,
1565 ::tensorflow::Input min_filter, ::tensorflow::Input
1566 max_filter, const gtl::ArraySlice<int>& strides,
1567 StringPiece padding);
1568 QuantizedDepthwiseConv2D(const ::tensorflow::Scope& scope, ::tensorflow::Input
1569 input, ::tensorflow::Input filter, ::tensorflow::Input
1570 min_input, ::tensorflow::Input max_input,
1571 ::tensorflow::Input min_filter, ::tensorflow::Input
1572 max_filter, const gtl::ArraySlice<int>& strides,
1573 StringPiece padding, const
1574 QuantizedDepthwiseConv2D::Attrs& attrs);
1575
1576 static Attrs OutType(DataType x) {
1577 return Attrs().OutType(x);
1578 }
1579 static Attrs Dilations(const gtl::ArraySlice<int>& x) {
1580 return Attrs().Dilations(x);
1581 }
1582
1583 Operation operation;
1584 ::tensorflow::Output output;
1585 ::tensorflow::Output min_output;
1586 ::tensorflow::Output max_output;
1587};
1588
1589/// Computes quantized depthwise Conv2D with Bias.
1590///
1591/// Args:
1592/// * scope: A Scope object
1593/// * input: The original input tensor.
1594/// * filter: The original filter tensor.
1595/// * bias: The original bias tensor.
1596/// * min_input: The float value that the minimum quantized input value represents.
1597/// * max_input: The float value that the maximum quantized input value represents.
1598/// * min_filter: The float value that the minimum quantized filter value represents.
1599/// * max_filter: The float value that the maximum quantized filter value represents.
1600/// * strides: List of stride values.
1601///
1602/// Optional attributes (see `Attrs`):
1603/// * out_type: The type of the output.
1604/// * dilations: List of dilation values.
1605///
1606/// Returns:
1607/// * `Output` output: The output tensor.
1608/// * `Output` min_output: The float value that the minimum quantized output value represents.
1609/// * `Output` max_output: The float value that the maximum quantized output value represents.
1610class QuantizedDepthwiseConv2DWithBias {
1611 public:
1612 /// Optional attribute setters for QuantizedDepthwiseConv2DWithBias
1613 struct Attrs {
1614 /// The type of the output.
1615 ///
1616 /// Defaults to DT_QINT32
1617 TF_MUST_USE_RESULT Attrs OutType(DataType x) {
1618 Attrs ret = *this;
1619 ret.out_type_ = x;
1620 return ret;
1621 }
1622
1623 /// List of dilation values.
1624 ///
1625 /// Defaults to [1, 1, 1, 1]
1626 TF_MUST_USE_RESULT Attrs Dilations(const gtl::ArraySlice<int>& x) {
1627 Attrs ret = *this;
1628 ret.dilations_ = x;
1629 return ret;
1630 }
1631
1632 DataType out_type_ = DT_QINT32;
1633 gtl::ArraySlice<int> dilations_ = Default_dilations();
1634 private:
1635 static gtl::ArraySlice<int> Default_dilations() {
1636 static const int kStorage[] = {1, 1, 1, 1};
1637 return gtl::ArraySlice<int>(kStorage);
1638 }
1639 };
1640 QuantizedDepthwiseConv2DWithBias(const ::tensorflow::Scope& scope,
1641 ::tensorflow::Input input, ::tensorflow::Input
1642 filter, ::tensorflow::Input bias,
1643 ::tensorflow::Input min_input,
1644 ::tensorflow::Input max_input,
1645 ::tensorflow::Input min_filter,
1646 ::tensorflow::Input max_filter, const
1647 gtl::ArraySlice<int>& strides, StringPiece
1648 padding);
1649 QuantizedDepthwiseConv2DWithBias(const ::tensorflow::Scope& scope,
1650 ::tensorflow::Input input, ::tensorflow::Input
1651 filter, ::tensorflow::Input bias,
1652 ::tensorflow::Input min_input,
1653 ::tensorflow::Input max_input,
1654 ::tensorflow::Input min_filter,
1655 ::tensorflow::Input max_filter, const
1656 gtl::ArraySlice<int>& strides, StringPiece
1657 padding, const
1658 QuantizedDepthwiseConv2DWithBias::Attrs&
1659 attrs);
1660
1661 static Attrs OutType(DataType x) {
1662 return Attrs().OutType(x);
1663 }
1664 static Attrs Dilations(const gtl::ArraySlice<int>& x) {
1665 return Attrs().Dilations(x);
1666 }
1667
1668 Operation operation;
1669 ::tensorflow::Output output;
1670 ::tensorflow::Output min_output;
1671 ::tensorflow::Output max_output;
1672};
1673
1674/// Computes quantized depthwise Conv2D with Bias and Relu.
1675///
1676/// Args:
1677/// * scope: A Scope object
1678/// * input: The original input tensor.
1679/// * filter: The original filter tensor.
1680/// * bias: The original bias tensor.
1681/// * min_input: The float value that the minimum quantized input value represents.
1682/// * max_input: The float value that the maximum quantized input value represents.
1683/// * min_filter: The float value that the minimum quantized filter value represents.
1684/// * max_filter: The float value that the maximum quantized filter value represents.
1685/// * strides: List of stride values.
1686///
1687/// Optional attributes (see `Attrs`):
1688/// * out_type: The type of the output.
1689/// * dilations: List of dilation values.
1690///
1691/// Returns:
1692/// * `Output` output: The output tensor.
1693/// * `Output` min_output: The float value that the minimum quantized output value represents.
1694/// * `Output` max_output: The float value that the maximum quantized output value represents.
1695class QuantizedDepthwiseConv2DWithBiasAndRelu {
1696 public:
1697 /// Optional attribute setters for QuantizedDepthwiseConv2DWithBiasAndRelu
1698 struct Attrs {
1699 /// The type of the output.
1700 ///
1701 /// Defaults to DT_QINT32
1702 TF_MUST_USE_RESULT Attrs OutType(DataType x) {
1703 Attrs ret = *this;
1704 ret.out_type_ = x;
1705 return ret;
1706 }
1707
1708 /// List of dilation values.
1709 ///
1710 /// Defaults to [1, 1, 1, 1]
1711 TF_MUST_USE_RESULT Attrs Dilations(const gtl::ArraySlice<int>& x) {
1712 Attrs ret = *this;
1713 ret.dilations_ = x;
1714 return ret;
1715 }
1716
1717 /// Defaults to []
1718 TF_MUST_USE_RESULT Attrs PaddingList(const gtl::ArraySlice<int>& x) {
1719 Attrs ret = *this;
1720 ret.padding_list_ = x;
1721 return ret;
1722 }
1723
1724 DataType out_type_ = DT_QINT32;
1725 gtl::ArraySlice<int> dilations_ = Default_dilations();
1726 gtl::ArraySlice<int> padding_list_ = {};
1727 private:
1728 static gtl::ArraySlice<int> Default_dilations() {
1729 static const int kStorage[] = {1, 1, 1, 1};
1730 return gtl::ArraySlice<int>(kStorage);
1731 }
1732 };
1733 QuantizedDepthwiseConv2DWithBiasAndRelu(const ::tensorflow::Scope& scope,
1734 ::tensorflow::Input input,
1735 ::tensorflow::Input filter,
1736 ::tensorflow::Input bias,
1737 ::tensorflow::Input min_input,
1738 ::tensorflow::Input max_input,
1739 ::tensorflow::Input min_filter,
1740 ::tensorflow::Input max_filter, const
1741 gtl::ArraySlice<int>& strides,
1742 StringPiece padding);
1743 QuantizedDepthwiseConv2DWithBiasAndRelu(const ::tensorflow::Scope& scope,
1744 ::tensorflow::Input input,
1745 ::tensorflow::Input filter,
1746 ::tensorflow::Input bias,
1747 ::tensorflow::Input min_input,
1748 ::tensorflow::Input max_input,
1749 ::tensorflow::Input min_filter,
1750 ::tensorflow::Input max_filter, const
1751 gtl::ArraySlice<int>& strides,
1752 StringPiece padding, const
1753 QuantizedDepthwiseConv2DWithBiasAndRelu::Attrs&
1754 attrs);
1755
1756 static Attrs OutType(DataType x) {
1757 return Attrs().OutType(x);
1758 }
1759 static Attrs Dilations(const gtl::ArraySlice<int>& x) {
1760 return Attrs().Dilations(x);
1761 }
1762 static Attrs PaddingList(const gtl::ArraySlice<int>& x) {
1763 return Attrs().PaddingList(x);
1764 }
1765
1766 Operation operation;
1767 ::tensorflow::Output output;
1768 ::tensorflow::Output min_output;
1769 ::tensorflow::Output max_output;
1770};
1771
1772/// Computes quantized depthwise Conv2D with Bias, Relu and Requantize.
1773///
1774/// Args:
1775/// * scope: A Scope object
1776/// * input: The original input tensor.
1777/// * filter: The original filter tensor.
1778/// * bias: The original bias tensor.
1779/// * min_input: The float value that the minimum quantized input value represents.
1780/// * max_input: The float value that the maximum quantized input value represents.
1781/// * min_filter: The float value that the minimum quantized filter value represents.
1782/// * max_filter: The float value that the maximum quantized filter value represents.
1783/// * min_freezed_output: The minimum float value of the output tensor.
1784/// * max_freezed_output: The maximum float value of the output tensor.
1785/// * strides: List of stride values.
1786///
1787/// Optional attributes (see `Attrs`):
1788/// * out_type: The type of the output.
1789/// * dilations: List of dilation values.
1790///
1791/// Returns:
1792/// * `Output` output: The output tensor.
1793/// * `Output` min_output: The float value that the minimum quantized output value represents.
1794/// * `Output` max_output: The float value that the maximum quantized output value represents.
1795class QuantizedDepthwiseConv2DWithBiasAndReluAndRequantize {
1796 public:
1797 /// Optional attribute setters for QuantizedDepthwiseConv2DWithBiasAndReluAndRequantize
1798 struct Attrs {
1799 /// The type of the output.
1800 ///
1801 /// Defaults to DT_QUINT8
1802 TF_MUST_USE_RESULT Attrs OutType(DataType x) {
1803 Attrs ret = *this;
1804 ret.out_type_ = x;
1805 return ret;
1806 }
1807
1808 /// List of dilation values.
1809 ///
1810 /// Defaults to [1, 1, 1, 1]
1811 TF_MUST_USE_RESULT Attrs Dilations(const gtl::ArraySlice<int>& x) {
1812 Attrs ret = *this;
1813 ret.dilations_ = x;
1814 return ret;
1815 }
1816
1817 /// Defaults to []
1818 TF_MUST_USE_RESULT Attrs PaddingList(const gtl::ArraySlice<int>& x) {
1819 Attrs ret = *this;
1820 ret.padding_list_ = x;
1821 return ret;
1822 }
1823
1824 DataType out_type_ = DT_QUINT8;
1825 gtl::ArraySlice<int> dilations_ = Default_dilations();
1826 gtl::ArraySlice<int> padding_list_ = {};
1827 private:
1828 static gtl::ArraySlice<int> Default_dilations() {
1829 static const int kStorage[] = {1, 1, 1, 1};
1830 return gtl::ArraySlice<int>(kStorage);
1831 }
1832 };
1833 QuantizedDepthwiseConv2DWithBiasAndReluAndRequantize(const ::tensorflow::Scope&
1834 scope, ::tensorflow::Input
1835 input, ::tensorflow::Input
1836 filter,
1837 ::tensorflow::Input bias,
1838 ::tensorflow::Input
1839 min_input,
1840 ::tensorflow::Input
1841 max_input,
1842 ::tensorflow::Input
1843 min_filter,
1844 ::tensorflow::Input
1845 max_filter,
1846 ::tensorflow::Input
1847 min_freezed_output,
1848 ::tensorflow::Input
1849 max_freezed_output, const
1850 gtl::ArraySlice<int>&
1851 strides, StringPiece
1852 padding);
1853 QuantizedDepthwiseConv2DWithBiasAndReluAndRequantize(const ::tensorflow::Scope&
1854 scope, ::tensorflow::Input
1855 input, ::tensorflow::Input
1856 filter,
1857 ::tensorflow::Input bias,
1858 ::tensorflow::Input
1859 min_input,
1860 ::tensorflow::Input
1861 max_input,
1862 ::tensorflow::Input
1863 min_filter,
1864 ::tensorflow::Input
1865 max_filter,
1866 ::tensorflow::Input
1867 min_freezed_output,
1868 ::tensorflow::Input
1869 max_freezed_output, const
1870 gtl::ArraySlice<int>&
1871 strides, StringPiece
1872 padding, const
1873 QuantizedDepthwiseConv2DWithBiasAndReluAndRequantize::Attrs&
1874 attrs);
1875
1876 static Attrs OutType(DataType x) {
1877 return Attrs().OutType(x);
1878 }
1879 static Attrs Dilations(const gtl::ArraySlice<int>& x) {
1880 return Attrs().Dilations(x);
1881 }
1882 static Attrs PaddingList(const gtl::ArraySlice<int>& x) {
1883 return Attrs().PaddingList(x);
1884 }
1885
1886 Operation operation;
1887 ::tensorflow::Output output;
1888 ::tensorflow::Output min_output;
1889 ::tensorflow::Output max_output;
1890};
1891
1892/// Performs a quantized matrix multiplication of `a` by the matrix `b` with bias
1893/// add.
1894///
1895/// The inputs must be two-dimensional matrices and 1D bias vector. And the inner
1896/// dimension of `a` (after being transposed if `transpose_a` is non-zero) must
1897/// match the outer dimension of `b` (after being transposed if `transposed_b` is
1898/// non-zero). Then do broadcast add operation with bias values on the matrix
1899/// multiplication result. The bias size must match inner dimension of `b`.
1900///
1901/// Args:
1902/// * scope: A Scope object
1903/// * a: A matrix to be multiplied. Must be a two-dimensional tensor of type `quint8`.
1904/// * b: A matrix to be multiplied and must be a two-dimensional tensor of type `qint8`.
1905/// * bias: A 1D bias tensor with size matching inner dimension of `b` (after being
1906/// transposed if `transposed_b` is non-zero).
1907/// * min_a: The float value that the lowest quantized `a` value represents.
1908/// * max_a: The float value that the highest quantized `a` value represents.
1909/// * min_b: The float value that the lowest quantized `b` value represents.
1910/// * max_b: The float value that the highest quantized `b` value represents.
1911///
1912/// Optional attributes (see `Attrs`):
1913/// * transpose_a: If true, `a` is transposed before multiplication.
1914/// * transpose_b: If true, `b` is transposed before multiplication.
1915/// * input_quant_mode: Input data quantization mode. Either MIN_FIRST(default) or SCALED.
1916///
1917/// Returns:
1918/// * `Output` out
1919/// * `Output` min_out: The float value that the lowest quantized output value represents.
1920/// * `Output` max_out: The float value that the highest quantized output value represents.
1921class QuantizedMatMulWithBias {
1922 public:
1923 /// Optional attribute setters for QuantizedMatMulWithBias
1924 struct Attrs {
1925 /// Defaults to DT_QINT32
1926 TF_MUST_USE_RESULT Attrs Toutput(DataType x) {
1927 Attrs ret = *this;
1928 ret.Toutput_ = x;
1929 return ret;
1930 }
1931
1932 /// If true, `a` is transposed before multiplication.
1933 ///
1934 /// Defaults to false
1935 TF_MUST_USE_RESULT Attrs TransposeA(bool x) {
1936 Attrs ret = *this;
1937 ret.transpose_a_ = x;
1938 return ret;
1939 }
1940
1941 /// If true, `b` is transposed before multiplication.
1942 ///
1943 /// Defaults to false
1944 TF_MUST_USE_RESULT Attrs TransposeB(bool x) {
1945 Attrs ret = *this;
1946 ret.transpose_b_ = x;
1947 return ret;
1948 }
1949
1950 /// Input data quantization mode. Either MIN_FIRST(default) or SCALED.
1951 ///
1952 /// Defaults to "MIN_FIRST"
1953 TF_MUST_USE_RESULT Attrs InputQuantMode(StringPiece x) {
1954 Attrs ret = *this;
1955 ret.input_quant_mode_ = x;
1956 return ret;
1957 }
1958
1959 DataType Toutput_ = DT_QINT32;
1960 bool transpose_a_ = false;
1961 bool transpose_b_ = false;
1962 StringPiece input_quant_mode_ = "MIN_FIRST";
1963 };
1964 QuantizedMatMulWithBias(const ::tensorflow::Scope& scope, ::tensorflow::Input
1965 a, ::tensorflow::Input b, ::tensorflow::Input bias,
1966 ::tensorflow::Input min_a, ::tensorflow::Input max_a,
1967 ::tensorflow::Input min_b, ::tensorflow::Input max_b);
1968 QuantizedMatMulWithBias(const ::tensorflow::Scope& scope, ::tensorflow::Input
1969 a, ::tensorflow::Input b, ::tensorflow::Input bias,
1970 ::tensorflow::Input min_a, ::tensorflow::Input max_a,
1971 ::tensorflow::Input min_b, ::tensorflow::Input max_b,
1972 const QuantizedMatMulWithBias::Attrs& attrs);
1973
1974 static Attrs Toutput(DataType x) {
1975 return Attrs().Toutput(x);
1976 }
1977 static Attrs TransposeA(bool x) {
1978 return Attrs().TransposeA(x);
1979 }
1980 static Attrs TransposeB(bool x) {
1981 return Attrs().TransposeB(x);
1982 }
1983 static Attrs InputQuantMode(StringPiece x) {
1984 return Attrs().InputQuantMode(x);
1985 }
1986
1987 Operation operation;
1988 ::tensorflow::Output out;
1989 ::tensorflow::Output min_out;
1990 ::tensorflow::Output max_out;
1991};
1992
1993/// TODO: add doc.
1994///
1995/// Args:
1996/// * scope: A Scope object
1997///
1998/// Returns:
1999/// * `Output`: The out tensor.
2000class QuantizedMatMulWithBiasAndDequantize {
2001 public:
2002 /// Optional attribute setters for QuantizedMatMulWithBiasAndDequantize
2003 struct Attrs {
2004 /// Defaults to false
2005 TF_MUST_USE_RESULT Attrs TransposeA(bool x) {
2006 Attrs ret = *this;
2007 ret.transpose_a_ = x;
2008 return ret;
2009 }
2010
2011 /// Defaults to false
2012 TF_MUST_USE_RESULT Attrs TransposeB(bool x) {
2013 Attrs ret = *this;
2014 ret.transpose_b_ = x;
2015 return ret;
2016 }
2017
2018 /// Defaults to "MIN_FIRST"
2019 TF_MUST_USE_RESULT Attrs InputQuantMode(StringPiece x) {
2020 Attrs ret = *this;
2021 ret.input_quant_mode_ = x;
2022 return ret;
2023 }
2024
2025 bool transpose_a_ = false;
2026 bool transpose_b_ = false;
2027 StringPiece input_quant_mode_ = "MIN_FIRST";
2028 };
2029 QuantizedMatMulWithBiasAndDequantize(const ::tensorflow::Scope& scope,
2030 ::tensorflow::Input a, ::tensorflow::Input
2031 b, ::tensorflow::Input bias,
2032 ::tensorflow::Input min_a,
2033 ::tensorflow::Input max_a,
2034 ::tensorflow::Input min_b,
2035 ::tensorflow::Input max_b,
2036 ::tensorflow::Input min_freezed_output,
2037 ::tensorflow::Input max_freezed_output,
2038 DataType Toutput);
2039 QuantizedMatMulWithBiasAndDequantize(const ::tensorflow::Scope& scope,
2040 ::tensorflow::Input a, ::tensorflow::Input
2041 b, ::tensorflow::Input bias,
2042 ::tensorflow::Input min_a,
2043 ::tensorflow::Input max_a,
2044 ::tensorflow::Input min_b,
2045 ::tensorflow::Input max_b,
2046 ::tensorflow::Input min_freezed_output,
2047 ::tensorflow::Input max_freezed_output,
2048 DataType Toutput, const
2049 QuantizedMatMulWithBiasAndDequantize::Attrs&
2050 attrs);
2051 operator ::tensorflow::Output() const { return out; }
2052 operator ::tensorflow::Input() const { return out; }
2053 ::tensorflow::Node* node() const { return out.node(); }
2054
2055 static Attrs TransposeA(bool x) {
2056 return Attrs().TransposeA(x);
2057 }
2058 static Attrs TransposeB(bool x) {
2059 return Attrs().TransposeB(x);
2060 }
2061 static Attrs InputQuantMode(StringPiece x) {
2062 return Attrs().InputQuantMode(x);
2063 }
2064
2065 Operation operation;
2066 ::tensorflow::Output out;
2067};
2068
2069/// Perform a quantized matrix multiplication of `a` by the matrix `b` with bias
2070/// add and relu fusion.
2071///
2072/// The inputs must be two-dimensional matrices and 1D bias vector. And the inner
2073/// dimension of `a` (after being transposed if `transpose_a` is non-zero) must
2074/// match the outer dimension of `b` (after being transposed if `transposed_b` is
2075/// non-zero). Then do broadcast add operation with bias values on the matrix
2076/// multiplication result. The bias size must match inner dimension of `b`. Then do
2077/// relu activation to get non-negative result.
2078///
2079/// Args:
2080/// * scope: A Scope object
2081/// * a: A matrix to be multiplied. Must be a two-dimensional tensor of type `quint8`.
2082/// * b: A matrix to be multiplied and must be a two-dimensional tensor of type `qint8`.
2083/// * bias: A 1D bias tensor with size matching with inner dimension of `b` (after being
2084/// transposed if `transposed_b` is non-zero).
2085/// * min_a: The float value that the lowest quantized `a` value represents.
2086/// * max_a: The float value that the highest quantized `a` value represents.
2087/// * min_b: The float value that the lowest quantized `b` value represents.
2088/// * max_b: The float value that the highest quantized `b` value represents.
2089///
2090/// Optional attributes (see `Attrs`):
2091/// * transpose_a: If true, `a` is transposed before multiplication.
2092/// * transpose_b: If true, `b` is transposed before multiplication.
2093/// * input_quant_mode: Input data quantization mode. Either MIN_FIRST(default) or SCALED.
2094///
2095/// Returns:
2096/// * `Output` out
2097/// * `Output` min_out: The float value that the lowest quantized output value represents.
2098/// * `Output` max_out: The float value that the highest quantized output value represents.
2099class QuantizedMatMulWithBiasAndRelu {
2100 public:
2101 /// Optional attribute setters for QuantizedMatMulWithBiasAndRelu
2102 struct Attrs {
2103 /// Defaults to DT_QINT32
2104 TF_MUST_USE_RESULT Attrs Toutput(DataType x) {
2105 Attrs ret = *this;
2106 ret.Toutput_ = x;
2107 return ret;
2108 }
2109
2110 /// If true, `a` is transposed before multiplication.
2111 ///
2112 /// Defaults to false
2113 TF_MUST_USE_RESULT Attrs TransposeA(bool x) {
2114 Attrs ret = *this;
2115 ret.transpose_a_ = x;
2116 return ret;
2117 }
2118
2119 /// If true, `b` is transposed before multiplication.
2120 ///
2121 /// Defaults to false
2122 TF_MUST_USE_RESULT Attrs TransposeB(bool x) {
2123 Attrs ret = *this;
2124 ret.transpose_b_ = x;
2125 return ret;
2126 }
2127
2128 /// Input data quantization mode. Either MIN_FIRST(default) or SCALED.
2129 ///
2130 /// Defaults to "MIN_FIRST"
2131 TF_MUST_USE_RESULT Attrs InputQuantMode(StringPiece x) {
2132 Attrs ret = *this;
2133 ret.input_quant_mode_ = x;
2134 return ret;
2135 }
2136
2137 DataType Toutput_ = DT_QINT32;
2138 bool transpose_a_ = false;
2139 bool transpose_b_ = false;
2140 StringPiece input_quant_mode_ = "MIN_FIRST";
2141 };
2142 QuantizedMatMulWithBiasAndRelu(const ::tensorflow::Scope& scope,
2143 ::tensorflow::Input a, ::tensorflow::Input b,
2144 ::tensorflow::Input bias, ::tensorflow::Input
2145 min_a, ::tensorflow::Input max_a,
2146 ::tensorflow::Input min_b, ::tensorflow::Input
2147 max_b);
2148 QuantizedMatMulWithBiasAndRelu(const ::tensorflow::Scope& scope,
2149 ::tensorflow::Input a, ::tensorflow::Input b,
2150 ::tensorflow::Input bias, ::tensorflow::Input
2151 min_a, ::tensorflow::Input max_a,
2152 ::tensorflow::Input min_b, ::tensorflow::Input
2153 max_b, const
2154 QuantizedMatMulWithBiasAndRelu::Attrs& attrs);
2155
2156 static Attrs Toutput(DataType x) {
2157 return Attrs().Toutput(x);
2158 }
2159 static Attrs TransposeA(bool x) {
2160 return Attrs().TransposeA(x);
2161 }
2162 static Attrs TransposeB(bool x) {
2163 return Attrs().TransposeB(x);
2164 }
2165 static Attrs InputQuantMode(StringPiece x) {
2166 return Attrs().InputQuantMode(x);
2167 }
2168
2169 Operation operation;
2170 ::tensorflow::Output out;
2171 ::tensorflow::Output min_out;
2172 ::tensorflow::Output max_out;
2173};
2174
2175/// Perform a quantized matrix multiplication of `a` by the matrix `b` with bias
2176/// add and relu and requantize fusion.
2177///
2178/// The inputs must be two-dimensional matrices and 1D bias vector. And the inner
2179/// dimension of `a` (after being transposed if `transpose_a` is non-zero) must
2180/// match the outer dimension of `b` (after being transposed if `transposed_b` is
2181/// non-zero). Then do broadcast add operation with bias values on the matrix
2182/// multiplication result. The bias size must match inner dimension of `b`. Then do
2183/// relu activation to get non-negative result. Then do requantize operation to get
2184/// final uint8 result.
2185///
2186/// Args:
2187/// * scope: A Scope object
2188/// * a: A matrix to be multiplied. Must be a two-dimensional tensor of type `quint8`.
2189/// * b: A matrix to be multiplied and must be a two-dimensional tensor of type `qint8`.
2190/// * bias: A 1D bias tensor with size matching with inner dimension of `b` (after being
2191/// transposed if `transposed_b` is non-zero).
2192/// * min_a: The float value that the lowest quantized `a` value represents.
2193/// * max_a: The float value that the highest quantized `a` value represents.
2194/// * min_b: The float value that the lowest quantized `b` value represents.
2195/// * max_b: The float value that the highest quantized `b` value represents.
2196/// * min_freezed_output: The float value that the highest quantized output value after requantize.
2197///
2198/// Optional attributes (see `Attrs`):
2199/// * transpose_a: If true, `a` is transposed before multiplication.
2200/// * transpose_b: If true, `b` is transposed before multiplication.
2201/// * input_quant_mode: Input data quantization mode. Either MIN_FIRST(default) or SCALED.
2202///
2203/// Returns:
2204/// * `Output` out
2205/// * `Output` min_out: The float value that the lowest quantized output value represents.
2206/// * `Output` max_out: The float value that the highest quantized output value represents.
2207class QuantizedMatMulWithBiasAndReluAndRequantize {
2208 public:
2209 /// Optional attribute setters for QuantizedMatMulWithBiasAndReluAndRequantize
2210 struct Attrs {
2211 /// Defaults to DT_QUINT8
2212 TF_MUST_USE_RESULT Attrs Toutput(DataType x) {
2213 Attrs ret = *this;
2214 ret.Toutput_ = x;
2215 return ret;
2216 }
2217
2218 /// If true, `a` is transposed before multiplication.
2219 ///
2220 /// Defaults to false
2221 TF_MUST_USE_RESULT Attrs TransposeA(bool x) {
2222 Attrs ret = *this;
2223 ret.transpose_a_ = x;
2224 return ret;
2225 }
2226
2227 /// If true, `b` is transposed before multiplication.
2228 ///
2229 /// Defaults to false
2230 TF_MUST_USE_RESULT Attrs TransposeB(bool x) {
2231 Attrs ret = *this;
2232 ret.transpose_b_ = x;
2233 return ret;
2234 }
2235
2236 /// Input data quantization mode. Either MIN_FIRST(default) or SCALED.
2237 ///
2238 /// Defaults to "MIN_FIRST"
2239 TF_MUST_USE_RESULT Attrs InputQuantMode(StringPiece x) {
2240 Attrs ret = *this;
2241 ret.input_quant_mode_ = x;
2242 return ret;
2243 }
2244
2245 DataType Toutput_ = DT_QUINT8;
2246 bool transpose_a_ = false;
2247 bool transpose_b_ = false;
2248 StringPiece input_quant_mode_ = "MIN_FIRST";
2249 };
2250 QuantizedMatMulWithBiasAndReluAndRequantize(const ::tensorflow::Scope& scope,
2251 ::tensorflow::Input a,
2252 ::tensorflow::Input b,
2253 ::tensorflow::Input bias,
2254 ::tensorflow::Input min_a,
2255 ::tensorflow::Input max_a,
2256 ::tensorflow::Input min_b,
2257 ::tensorflow::Input max_b,
2258 ::tensorflow::Input
2259 min_freezed_output,
2260 ::tensorflow::Input
2261 max_freezed_output);
2262 QuantizedMatMulWithBiasAndReluAndRequantize(const ::tensorflow::Scope& scope,
2263 ::tensorflow::Input a,
2264 ::tensorflow::Input b,
2265 ::tensorflow::Input bias,
2266 ::tensorflow::Input min_a,
2267 ::tensorflow::Input max_a,
2268 ::tensorflow::Input min_b,
2269 ::tensorflow::Input max_b,
2270 ::tensorflow::Input
2271 min_freezed_output,
2272 ::tensorflow::Input
2273 max_freezed_output, const
2274 QuantizedMatMulWithBiasAndReluAndRequantize::Attrs&
2275 attrs);
2276
2277 static Attrs Toutput(DataType x) {
2278 return Attrs().Toutput(x);
2279 }
2280 static Attrs TransposeA(bool x) {
2281 return Attrs().TransposeA(x);
2282 }
2283 static Attrs TransposeB(bool x) {
2284 return Attrs().TransposeB(x);
2285 }
2286 static Attrs InputQuantMode(StringPiece x) {
2287 return Attrs().InputQuantMode(x);
2288 }
2289
2290 Operation operation;
2291 ::tensorflow::Output out;
2292 ::tensorflow::Output min_out;
2293 ::tensorflow::Output max_out;
2294};
2295
2296/// TODO: add doc.
2297///
2298/// Args:
2299/// * scope: A Scope object
2300///
2301/// Returns:
2302/// * `Output` out
2303/// * `Output` min_out
2304/// * `Output` max_out
2305class QuantizedMatMulWithBiasAndRequantize {
2306 public:
2307 /// Optional attribute setters for QuantizedMatMulWithBiasAndRequantize
2308 struct Attrs {
2309 /// Defaults to DT_QUINT8
2310 TF_MUST_USE_RESULT Attrs Toutput(DataType x) {
2311 Attrs ret = *this;
2312 ret.Toutput_ = x;
2313 return ret;
2314 }
2315
2316 /// Defaults to false
2317 TF_MUST_USE_RESULT Attrs TransposeA(bool x) {
2318 Attrs ret = *this;
2319 ret.transpose_a_ = x;
2320 return ret;
2321 }
2322
2323 /// Defaults to false
2324 TF_MUST_USE_RESULT Attrs TransposeB(bool x) {
2325 Attrs ret = *this;
2326 ret.transpose_b_ = x;
2327 return ret;
2328 }
2329
2330 /// Defaults to "MIN_FIRST"
2331 TF_MUST_USE_RESULT Attrs InputQuantMode(StringPiece x) {
2332 Attrs ret = *this;
2333 ret.input_quant_mode_ = x;
2334 return ret;
2335 }
2336
2337 DataType Toutput_ = DT_QUINT8;
2338 bool transpose_a_ = false;
2339 bool transpose_b_ = false;
2340 StringPiece input_quant_mode_ = "MIN_FIRST";
2341 };
2342 QuantizedMatMulWithBiasAndRequantize(const ::tensorflow::Scope& scope,
2343 ::tensorflow::Input a, ::tensorflow::Input
2344 b, ::tensorflow::Input bias,
2345 ::tensorflow::Input min_a,
2346 ::tensorflow::Input max_a,
2347 ::tensorflow::Input min_b,
2348 ::tensorflow::Input max_b,
2349 ::tensorflow::Input min_freezed_output,
2350 ::tensorflow::Input max_freezed_output);
2351 QuantizedMatMulWithBiasAndRequantize(const ::tensorflow::Scope& scope,
2352 ::tensorflow::Input a, ::tensorflow::Input
2353 b, ::tensorflow::Input bias,
2354 ::tensorflow::Input min_a,
2355 ::tensorflow::Input max_a,
2356 ::tensorflow::Input min_b,
2357 ::tensorflow::Input max_b,
2358 ::tensorflow::Input min_freezed_output,
2359 ::tensorflow::Input max_freezed_output,
2360 const
2361 QuantizedMatMulWithBiasAndRequantize::Attrs&
2362 attrs);
2363
2364 static Attrs Toutput(DataType x) {
2365 return Attrs().Toutput(x);
2366 }
2367 static Attrs TransposeA(bool x) {
2368 return Attrs().TransposeA(x);
2369 }
2370 static Attrs TransposeB(bool x) {
2371 return Attrs().TransposeB(x);
2372 }
2373 static Attrs InputQuantMode(StringPiece x) {
2374 return Attrs().InputQuantMode(x);
2375 }
2376
2377 Operation operation;
2378 ::tensorflow::Output out;
2379 ::tensorflow::Output min_out;
2380 ::tensorflow::Output max_out;
2381};
2382
2383/// Computes rectified linear 6 gradients for a Relu6 operation.
2384///
2385/// Args:
2386/// * scope: A Scope object
2387/// * gradients: The backpropagated gradients to the corresponding Relu6 operation.
2388/// * features: The features passed as input to the corresponding Relu6 operation, or
2389/// its output; using either one produces the same result.
2390///
2391/// Returns:
2392/// * `Output`: The gradients:
2393/// `gradients * (features > 0) * (features < 6)`.
2394class Relu6Grad {
2395 public:
2396 Relu6Grad(const ::tensorflow::Scope& scope, ::tensorflow::Input gradients,
2397 ::tensorflow::Input features);
2398 operator ::tensorflow::Output() const { return backprops; }
2399 operator ::tensorflow::Input() const { return backprops; }
2400 ::tensorflow::Node* node() const { return backprops.node(); }
2401
2402 Operation operation;
2403 ::tensorflow::Output backprops;
2404};
2405
2406/// Computes rectified linear gradients for a Relu operation.
2407///
2408/// Args:
2409/// * scope: A Scope object
2410/// * gradients: The backpropagated gradients to the corresponding Relu operation.
2411/// * features: The features passed as input to the corresponding Relu operation, OR
2412/// the outputs of that operation (both work equivalently).
2413///
2414/// Returns:
2415/// * `Output`: `gradients * (features > 0)`.
2416class ReluGrad {
2417 public:
2418 ReluGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input gradients,
2419 ::tensorflow::Input features);
2420 operator ::tensorflow::Output() const { return backprops; }
2421 operator ::tensorflow::Input() const { return backprops; }
2422 ::tensorflow::Node* node() const { return backprops.node(); }
2423
2424 Operation operation;
2425 ::tensorflow::Output backprops;
2426};
2427
2428/// Computes gradients for the scaled exponential linear (Selu) operation.
2429///
2430/// Args:
2431/// * scope: A Scope object
2432/// * gradients: The backpropagated gradients to the corresponding Selu operation.
2433/// * outputs: The outputs of the corresponding Selu operation.
2434///
2435/// Returns:
2436/// * `Output`: The gradients: `gradients * (outputs + scale * alpha)`
2437/// if outputs < 0, `scale * gradients` otherwise.
2438class SeluGrad {
2439 public:
2440 SeluGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input gradients,
2441 ::tensorflow::Input outputs);
2442 operator ::tensorflow::Output() const { return backprops; }
2443 operator ::tensorflow::Input() const { return backprops; }
2444 ::tensorflow::Node* node() const { return backprops.node(); }
2445
2446 Operation operation;
2447 ::tensorflow::Output backprops;
2448};
2449
2450/// Computes softplus gradients for a softplus operation.
2451///
2452/// Args:
2453/// * scope: A Scope object
2454/// * gradients: The backpropagated gradients to the corresponding softplus operation.
2455/// * features: The features passed as input to the corresponding softplus operation.
2456///
2457/// Returns:
2458/// * `Output`: The gradients: `gradients / (1 + exp(-features))`.
2459class SoftplusGrad {
2460 public:
2461 SoftplusGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input gradients,
2462 ::tensorflow::Input features);
2463 operator ::tensorflow::Output() const { return backprops; }
2464 operator ::tensorflow::Input() const { return backprops; }
2465 ::tensorflow::Node* node() const { return backprops.node(); }
2466
2467 Operation operation;
2468 ::tensorflow::Output backprops;
2469};
2470
2471/// Computes softsign gradients for a softsign operation.
2472///
2473/// Args:
2474/// * scope: A Scope object
2475/// * gradients: The backpropagated gradients to the corresponding softsign operation.
2476/// * features: The features passed as input to the corresponding softsign operation.
2477///
2478/// Returns:
2479/// * `Output`: The gradients: `gradients / (1 + abs(features)) ** 2`.
2480class SoftsignGrad {
2481 public:
2482 SoftsignGrad(const ::tensorflow::Scope& scope, ::tensorflow::Input gradients,
2483 ::tensorflow::Input features);
2484 operator ::tensorflow::Output() const { return backprops; }
2485 operator ::tensorflow::Input() const { return backprops; }
2486 ::tensorflow::Node* node() const { return backprops.node(); }
2487
2488 Operation operation;
2489 ::tensorflow::Output backprops;
2490};
2491
2492} // namespace internal
2493} // namespace ops
2494} // namespace tensorflow
2495
2496#endif // TENSORFLOW_CC_OPS_NN_OPS_INTERNAL_H_
2497