Commit Graph

21 Commits

Author SHA1 Message Date
Dmitry Volodin
04ff97cbb6 fix typos in lite directory 2020-10-29 04:39:35 +03:00
Mihai Maruseac
1970c2158b [tflite]: Insert nullptr checks when obtaining tensors.
As part of ongoing refactoring, `tflite::GetInput`, `tflite::GetOutput`, `tflite::GetTemporary` and `tflite::GetIntermediates` will return `nullptr` in some cases. Hence, we insert the `nullptr` checks on all usages.

We also insert `nullptr` checks on usages of `tflite::GetVariableInput` and `tflite::GetOptionalInputTensor` but only in the cases where there is no obvious check that `nullptr` is acceptable (that is, we only insert the check for the output of these two functions if the tensor is accessed as if it is always not `nullptr`).

PiperOrigin-RevId: 332521299
Change-Id: I29af455bcb48d0b92e58132d951a3badbd772d56
2020-09-18 14:13:50 -07:00
Jared Duke
efb1af85b2 Stop linking Eigen multi-threaded conv when ruy is enabled
This codepath is unused when ruy is enabled, so stop linking it
into the kernel library.

PiperOrigin-RevId: 330617707
Change-Id: I0b583eff42a65f71d22ef500794fa74f30aa1b4e
2020-09-08 17:14:49 -07:00
Sachin Joglekar
430b00361b Audit and improve TfLiteType checks in kernels
PiperOrigin-RevId: 316720436
Change-Id: I2032e799ee6afa533b932385c2a70f7621f4ac1b
2020-06-16 11:31:02 -07:00
Karim Nosir
2a96849f47 Update source files with used includes.
PiperOrigin-RevId: 316589177
Change-Id: I0aba0ed1cf9ff478e7890fa53a7749bf844bd26d
2020-06-15 18:42:14 -07:00
TensorFlower Gardener
f72f233547 Merge pull request from psunn:int16_transpose_conv
PiperOrigin-RevId: 314541621
Change-Id: I684cba53a54b29188a5ee97bbcb80889c49ea5f5
2020-06-03 09:08:49 -07:00
Peng Sun
9f768faaa4 Merge remote-tracking branch 'upstream/master' into int16_transpose_conv
Add bias to int16_transpose_conv:
	tensorflow/lite/kernels/transpose_conv.cc
	tensorflow/lite/kernels/transpose_conv_test.cc
	tensorflow/lite/kernels/internal/reference/integer_ops/transpose_conv.h

Resolved Conflicts:
	tensorflow/lite/kernels/transpose_conv.cc
	tensorflow/lite/kernels/transpose_conv_test.cc
2020-04-28 09:24:28 +01:00
Peng Sun
43b8f6e710 PR : TransposeConv with Bias
Imported from GitHub PR https://github.com/tensorflow/tensorflow/pull/34903

### Description of issue:
For generating .tflite file with TFLiteConverter, when model contains
Conv2DTranspose layers, bias cannot fold into Operator TRANSPOSECONV.
It will result with extra Op ADD following Op TRANSPOSECONV.
But with other CONV-like layers (Conv2D, DepthwiseConv2D),
bias will be fold into CONV layer.
(check detailed TF issue: https://github.com/tensorflow/tensorflow/issues/34622)

### PR try to resolve it:
So we try to resolve this issue by enable TransposeConv with bias for TFLite:

- Update TFLite graph_transform features with:
      fill TransposeConv bias with zero if there is no bias
      fuse bias add into preceding TransposeConv(TEST added)

- Update TransposeConv with bias:
      add bias input to TransposeConv
      add optional bias to TransposeConv kernels

### example of the results:
  TRANSPOSE_CONV inputs:

1. output_shape
2. weights
3. activation
4. bias

![fused_transposeconv](https://user-images.githubusercontent.com/55463253/70334128-bc088200-183c-11ea-9f94-a803cc80df99.png)

### Need to discuss:
~~currently this PR only update reference kernel for transpose_conv, optimised kernal is commented out.~~
~~several TEST need to be added as well, but~~ further suggestions are needed for adding additional test.
Copybara import of the project:

--
1c6eb9c98229a9e8248dc1fe913a20cc6dd89332 by Peng Sun <peng.sun@arm.com>:

Fuse TransposeConv with Bias

For generating .tflite file with TFLiteConverter, when model contains
Conv2DTranspose layers, bias cannot fold into Operator TRANSPOSECONV.
It will result with extra Op ADD following Op TRANSPOSECONV.
But with other CONV-like layers (Conv2D, DepthwiseConv2D),
bias will be fold into CONV layer.
(check TF issue: https://github.com/tensorflow/tensorflow/issues/34622)

So we try to resolve this issue by enable TransposeConv with bias for TFLite:
  Update TFLite graph_transform features with:
    fill TransposeConv bias with zero if there is no bias
    fuse bias add into preceding TransposeConv(TEST added)
  Update TransposeConv with bias:
    add bias input to TransposeConv
    add optional bias to TransposeConv kernels(TEST added)

--
22611b880c94eb753c88a0a3e2977200e55ebd2c by Peng Sun <peng.sun@arm.com>:

clang-format with google style.

COPYBARA_INTEGRATE_REVIEW=https://github.com/tensorflow/tensorflow/pull/34903 from psunn:TransposeConvWithBias 22611b880c94eb753c88a0a3e2977200e55ebd2c
PiperOrigin-RevId: 307872447
Change-Id: I367fcd65f2662f4c7846d37bc69dc43670c83961
2020-04-22 12:33:46 -07:00
Peng Sun
0be4b1808b input, output offset is zero in case of int16 activations 2020-02-04 18:34:13 +00:00
Peng Sun
e71f56e928 INT16 reference_op for TRANSPOSE_CONVOLUTION
add INT16 reference ops transpose_conv
    add TEST code for INT16 transpose_conv
2020-01-17 19:59:16 +00:00
Renjie Liu
5e94ded1de Optimize int8 transpose_conv
PiperOrigin-RevId: 283881873
Change-Id: I568f5db0ba3663cb17208af41d30c2179e2e485c
2019-12-04 18:33:45 -08:00
Jared Duke
4ce6a9b7a4 Rename lite/c/c_api_internal.h to lite/c/common.h
The C types in lite/c/c_api_internal.h are not actually internal,
rather, they are common types used throughout the C++ and C APIs.
Rename the header accordingly.

PiperOrigin-RevId: 282494601
Change-Id: Ia784f35724d774db256ffcbbcdc5bb00e6574417
2019-11-25 21:49:25 -08:00
Yunlu Li
a7de1a78fe Add int8 transpose conv.
PiperOrigin-RevId: 281565221
Change-Id: I984c4e7e4dbb30a872c63778e52eac0bd91fd999
2019-11-20 14:02:09 -08:00
Renjie Liu
ff05c644e4 optimize quantized transpose_conv
PiperOrigin-RevId: 279558278
Change-Id: I1aa1c79bcef9de21c76852fcc1560f665c352185
2019-11-09 21:39:03 -08:00
Chao Mei
ade316deef 1. Remove all references to tflite::cpu_backend_support as we no longer do reference-counting on the cpu backend context object and GetFromContext is moved to CpuBackendContext class as a static member function.
2. Remove gemmlowp_support.{h,cc} as their functionalities have already been folded into CpuBackendContext class.

PiperOrigin-RevId: 259464967
2019-07-22 21:27:09 -07:00
Benoit Jacob
581577abf5 Port TransposeConv/float to cpu_backend_gemm.
PiperOrigin-RevId: 247062528
2019-05-07 14:29:32 -07:00
Renjie Liu
354b95f958 Reuse ComputePaddingHeightWidth, also support dilation != 1 case.
PiperOrigin-RevId: 244797614
2019-04-22 22:48:22 -07:00
Renjie Liu
5e52b70188 Optimize transpose_conv
PiperOrigin-RevId: 243561442
2019-04-15 00:07:34 -07:00
Haoliang Zhang
91a8831b4a Add reference implementation for quantized TransposeConv.
PiperOrigin-RevId: 239298532
2019-03-19 17:04:12 -07:00
A. Unique TensorFlower
c33db572fe Fix transpose_conv
Use the proper filter height/width dimensions.

PiperOrigin-RevId: 229294726
2019-01-14 18:28:49 -08:00
Austin Anderson
61c6c84964 Migrate TensorFlow Lite out of tensorflow/contrib
This change moves //tensorflow/contrib/lite to //tensorflow/lite in preparation
for TensorFlow 2.0's deprecation of contrib/. If you refer to TF Lite build
targets or headers, you will need to update them manually. If you use TF Lite
from the TensorFlow python package, "tf.contrib.lite" now points to "tf.lite".
Please update your imports as soon as possible.

For more details, see https://groups.google.com/a/tensorflow.org/forum/#!topic/tflite/iIIXOTOFvwQ

@angersson and @aselle are conducting this migration. Please contact them if
you have any further questions.

PiperOrigin-RevId: 219536476
2018-10-31 14:20:28 -07:00