Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.

Commit d193cda

Browse files
authored
Clarify "mobile" + a few other changes
1 parent d1a3262 commit d193cda

File tree

1 file changed

+13
-17
lines changed

1 file changed

+13
-17
lines changed

rfcs/20200712-tfrt-kernel-fallback.md

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ mobile devices by removing the need to execute them via the TensorFlow eager run
1414
calling kernels directly from the new [TFRT](https://github.com/tensorflow/runtime) TensorFlow runtime.
1515

1616
Note that there is an effort to call existing kernels by delegating to
17-
TensorFlow eager runtime instead. This approach is called Runtime Fallback and
18-
corresponding RFC will be published soon. The goals of the two fallback
17+
TensorFlow eager runtime instead. This approach is called Runtime Fallback. The goals of the two fallback
1918
mechanisms are as follows:
2019

2120
* Runtime Fallback aims to reuse all current TensorFlow kernels in TFRT.
@@ -39,11 +38,13 @@ calls TensorFlow kernels without going through Eager runtime first. We plan to
3938
address the second high level goal by trimming down dependencies, switching to
4039
more compact proto representation, etc.
4140

41+
Note that TensorFlow's current mobile solution is called [TensorFlow Lite](https://www.tensorflow.org/lite). At the same time, there is a work-in-progress effort to enable [TFRT](https://github.com/tensorflow/runtime) to run on mobile. This document focuses on the way TFRT would call kernels when running on mobile devices. Details of the way TFRT itself would be executed on mobile platforms are outside of the scope of this document.
42+
43+
4244
### Op Coverage Goals
4345

4446
First of all, we plan to target all the easier-to-support ops that don’t require
45-
implementing extensive pieces of infrastructure, but at the same time provide
46-
the most value to the TF Lite team.
47+
implementing extensive pieces of infrastructure.
4748

4849
We analysed how many kernels we can support in the future and include our
4950
findings in the following spreadsheets. As we describe in
@@ -90,8 +91,7 @@ custom
9091
extra effort required.
9192
* Gradients would not be supported by the first iteration of Kernel Fallback,
9293
but we might revisit it later.
93-
* Exact details of TFRT integration are still being worked out by TFRT and TF
94-
Lite teams. Since these teams might change the plan, exact details are not a
94+
* Exact details of TFRT integration are still being worked out by TFRT and TensorFlow mobile teams. Since these teams might change the plan, exact details are not a
9595
part of this doc. The take away is that we will integrate kernel fallback
9696
following the approach they decide on.
9797

@@ -104,7 +104,7 @@ pool of available ops on mobile devices, ideally supporting everything that full
104104
TensorFlow supports now.
105105

106106
However, supporting TensorFlow ops on mobile devices presents some challenges.
107-
Specifically, binary size on mobile platforms should be restricted. TF Lite team
107+
Specifically, binary size on mobile platforms should be restricted. TensorFlow mobile team
108108
provided us with the following *ideal* numbers:
109109

110110
* 100-200k overhead to call TF kernels
@@ -247,12 +247,11 @@ and templating approaches. Key findings are summarized below:
247247
estimated at 2.6% (based on adding `AddN` op).
248248

249249
Right now, we are leaning towards using inheritance. Seems like time increase is
250-
only significant for running many scalar ops in a sequence - probably a rare use
251-
case in the real world. (See more details in [Appendix 2](#appendix-2-extension-options))
250+
only not significant. (See more details in [Appendix 2](#appendix-2-extension-options))
252251

253252
To use inheritance, we will define `OpKernelConstructionInterface` and
254253
`OpKernelContextInterface` interfaces. Ideally, these interfaces should be pure
255-
virtual. However, we will have one exception - templated `eigen_device` method
254+
virtual. However, we will have some exception - for e.g. templated `eigen_device` method
256255
that calls per-device pure-virtual implementations.
257256

258257
We will then introduce `TFRTOpKernelConstruction` and `TFRTOpKernelContext`
@@ -261,7 +260,7 @@ subclasses that implement `OpKernelConstructionInterface` and
261260
`TFRTOpKernelConstruction` might look like:
262261

263262
```cpp
264-
class TFRTOpKernelConstruction : public OpKernelConstructionInterface {
263+
class TFRTOpKernelConstruction final : public OpKernelConstructionInterface {
265264
public:
266265
explicit TFRTOpKernelConstruction(AttrMap attributes);
267266
~TFRTOpKernelConstruction() override {};
@@ -348,7 +347,7 @@ op->Compute(&op_kernel_context);
348347
## tfrt\_fallback.kernel\_fallback call structure
349348

350349
We will be using the following conventions (essentially, these are based on
351-
Runtime Fallback work that will probably have RFC coming soon):
350+
Runtime Fallback work):
352351

353352
* Attributes are passed as key-value pairs, where both key and value are
354353
represented as strings.
@@ -506,7 +505,7 @@ between (such as tensor conversions).
506505
We also need to consider how kernel or runtime fallback will be selected. This
507506
could be a parameter at BEF file creation step. It might also be good to package
508507
both runtime and kernel fallback implementations in a BEF file to be selected at
509-
runtime.
508+
runtime (packaging both is only relevant for non-mobile usecase since it would prevent us from reducing binary size).
510509
511510
## Size Reduction
512511
@@ -564,9 +563,6 @@ due to significant work involved.
564563
`OpKernelConsturction`.
565564
* Speed up for lighter weight kernel calls.
566565
567-
We will run benchmarks to check performance numbers as we work on the
568-
implementation.
569-
570566
### Dependencies
571567
572568
No new dependencies.
@@ -576,7 +572,7 @@ No new dependencies.
576572
* Build / startup time / binary size will be impacted by additional code added
577573
to implement Kernel Fallback. At the same time one of the goals of Kernel
578574
Fallback is to provide a lower-binary-size way to run existing TensorFlow
579-
kernels in TF Lite.
575+
kernels on mobile.
580576
* Code will be maintained by TensorFlow DevInfra and TFRT teams.
581577
582578
#### Current Status

0 commit comments

Comments
 (0)