Deep Learning and AI

Update Alert: TensorFlow 2.8

February 3, 2022 • 13 min read

blog-TensorFlow-2.8.0.png

A Look at TensorFlow 2.8

Google released TensorFlow 2.8 yesterday which adds a few major features and improvements, and a lot of bug fixes and security updates. The main focus of this release is to extend the functionality of TensorFlow Lite.

Highlights include more TFLite support for TensorFlow operations; experimental API that Configures TensorFlow ops to run deterministically; PluggableDevice architecture which offers a plugin mechanism for registering devices with TensorFlow without the need to make changes in TensorFlow code; and more.

You can view the full list of changes on the TensorFlow GitHub page (and download and install the latest version): TensorFlow 2.8.0

Let's take a closer look at some of these features.

TensorFlow Lite Gets More Support

TensorFlow Lite (TFLite) is an open source framework included with TensorFlow (essentially a lightweight version of TensorFlow), and is intended for mobile and IoT devices. Since it is a scaled down framework it cannot do everything TensorFlow can, but they are constantly rolling out new support with new versions.

With TensorFlow 2.8, five more ops are now supported, including:

  • tf.raw_ops.Bucketize op on CPU.
  • tf.where op for data types tf.int32/tf.uint32/tf.int8/tf.uint8/tf.int64.
  • tf.random.normal op for output data type tf.float32 on CPU.
  • tf.random.uniform op for output data type tf.float32 on CPU.
  • tf.random.categorical op for output data type tf.int64 on CPU.

TPU Experimental Embedding Feature

Tensor Processing Units (TPUs) are Google's custom-developed application-specific integrated circuits (ASICs) used to accelerate machine learning workloads. tf.tpu.experimental.embedding.FeatureConfig now takes an additional argument output_shape which can specify the shape of the output activation for the feature.

tf.tpu.experimental.embedding.TPUEmbedding now has the same behavior as tf.tpu.experimental.embedding.serving_embedding_lookup which can take arbitrary rank of dense and sparse tensor. For ragged tensor, though the input tensor remains to be rank 2, the activations now can be rank 2 or above by specifying the output shape in the feature config or via the build method.

Configure TensorFlow ops to run deterministically

When op determinism is enabled, TensorFlow ops will be deterministic.

tf.config.experimental.enable_op_determinism()

This means that if an op is run multiple times with the same inputs on the same hardware, it will have the exact same outputs each time. This is useful for debugging models. Note that determinism in general comes at the expense of lower performance and so your model may run slower when op determinism is enabled.

If you want your TensorFlow program to run deterministically, put the following code near the start of your program:

tf.keras.utils.set_random_seed(1)
tf.config.experimental.enable_op_determinism()

Calling tf.keras.utils.set_random_seed sets the Python seed, the NumPy seed, and the TensorFlow seed. Setting these seeds is necessary to ensure any random numbers your program generates are also deterministic.

By default, op determinism is not enabled, so ops might return different results when run with the same inputs. These differences are often caused by the use of asynchronous threads within the op nondeterministically changing the order in which floating-point numbers are added. Most of these cases of nondeterminism occur on GPUs, which have thousands of hardware threads that are used to run ops. Enabling determinism directs such ops to use a different algorithm, one that does not use threads in a nondeterministic way.

You can learn more about deterministic models here:

https://www.tensorflow.org/api_docs/python/tf/config/experimental/enable_op_determinism

Some Change Highlights

  • TFLite adds GPU Delegation support for serialization to Java API. This boosts initialization time up to 90% when OpenCL is available.
  • Keras added 3 new APIs for enable/disable/check the usage of tf.random.Generator in keras backend, which will be the new backend for all the RNG in Keras.
  • Keras added additional standardize and split modes to TextVectorizationstandardize="lower" will lowercase inputs; standardize="string_punctuation" will remove all puncuation; split="character" will split on every unicode character.
  • TensorFlow has been validated on Windows Subsystem for Linux 2 (aka WSL 2) for both GPUs and CPUs.

      Security Fixes

      There were also a large number of security fixes included. TensorFlow 2.8:

      • Fixes a floating point division by 0 when executing convolution operators (CVE-2022-21725)
      • Fixes a heap OOB read in shape inference for ReverseSequence (CVE-2022-21728)
      • Fixes a heap OOB access in Dequantize (CVE-2022-21726)
      • Fixes an integer overflow in shape inference for Dequantize (CVE-2022-21727)
      • Fixes a heap OOB access in FractionalAvgPoolGrad (CVE-2022-21730)
      • Fixes an overflow and divide by zero in UnravelIndex (CVE-2022-21729)
      • Fixes a type confusion in shape inference for ConcatV2 (CVE-2022-21731)
      • Fixes an OOM in ThreadPoolHandle (CVE-2022-21732)
      • Fixes an OOM due to integer overflow in StringNGrams (CVE-2022-21733)
      • Fixes more issues caused by incomplete validation in boosted trees code (CVE-2021-41208)
      • Fixes an integer overflows in most sparse component-wise ops (CVE-2022-23567)
      • Fixes an integer overflows in AddManySparseToTensorsMap (CVE-2022-23568)
      • Fixes a number of CHECK-failures in MapStage (CVE-2022-21734)
      • Fixes a division by zero in FractionalMaxPool (CVE-2022-21735)
      • Fixes a number of CHECK-fails when building invalid/overflowing tensor shapes (CVE-2022-23569)
      • Fixes an undefined behavior in SparseTensorSliceDataset (CVE-2022-21736)
      • Fixes an assertion failure based denial of service via faulty bin count operations (CVE-2022-21737)
      • Fixes a reference binding to null pointer in QuantizedMaxPool (CVE-2022-21739)
      • Fixes an integer overflow leading to crash in SparseCountSparseOutput (CVE-2022-21738)
      • Fixes a heap overflow in SparseCountSparseOutput (CVE-2022-21740)
      • Fixes an FPE in BiasAndClamp in TFLite (CVE-2022-23557)
      • Fixes an FPE in depthwise convolutions in TFLite (CVE-2022-21741)
      • Fixes an integer overflow in TFLite array creation (CVE-2022-23558)
      • Fixes an integer overflow in TFLite (CVE-2022-23559)
      • Fixes a dangerous OOB write in TFLite (CVE-2022-23561)
      • Fixes a vulnerability leading to read and write outside of bounds in TFLite (CVE-2022-23560)
      • Fixes a set of vulnerabilities caused by using insecure temporary files (CVE-2022-23563)
      • Fixes an integer overflow in Range resulting in undefined behavior and OOM (CVE-2022-23562)
      • Fixes a vulnerability where missing validation causes tf.sparse.split to crash when axis is a tuple (CVE-2021-41206)
      • Fixes a CHECK-fail when decoding resource handles from proto (CVE-2022-23564)
      • Fixes a CHECK-fail with repeated AttrDef (CVE-2022-23565)
      • Fixes a heap OOB write in Grappler (CVE-2022-23566)
      • Fixes a CHECK-fail when decoding invalid tensors from proto (CVE-2022-23571)
      • Fixes a null-dereference when specializing tensor type (CVE-2022-23570)
      • Fixes a crash when type cannot be specialized (CVE-2022-23572)
      • Fixes a heap OOB read/write in SpecializeType (CVE-2022-23574)
      • Fixes an unitialized variable access in AssignOp (CVE-2022-23573)
      • Fixes an integer overflow in OpLevelCostEstimator::CalculateTensorSize (CVE-2022-23575)
      • Fixes an integer overflow in OpLevelCostEstimator::CalculateOutputSize (CVE-2022-23576)
      • Fixes a null dereference in GetInitOp (CVE-2022-23577)
      • Fixes a memory leak when a graph node is invalid (CVE-2022-23578)
      • Fixes an abort caused by allocating a vector that is too large (CVE-2022-23580)
      • Fixes multiple CHECK-failures during Grappler's IsSimplifiableReshape (CVE-2022-23581)
      • Fixes multiple CHECK-failures during Grappler's SafeToRemoveIdentity (CVE-2022-23579)
      • Fixes multiple CHECK-failures in TensorByteSize (CVE-2022-23582)
      • Fixes multiple CHECK-failures in binary ops due to type confusion (CVE-2022-23583)
      • Fixes a use after free in DecodePng kernel (CVE-2022-23584)
      • Fixes a memory leak in decoding PNG images (CVE-2022-23585)
      • Fixes multiple CHECK-fails in function.cc (CVE-2022-23586)
      • Fixes multiple CHECK-fails due to attempting to build a reference tensor (CVE-2022-23588)
      • Fixes an integer overflow in Grappler cost estimation of crop and resize operation (CVE-2022-23587)
      • Fixes a null pointer dereference in Grappler's IsConstant (CVE-2022-23589)
      • Fixes a CHECK failure in constant folding (CVE-2021-41197)
      • Fixes a stack overflow due to self-recursive function in GraphDef (CVE-2022-23591)
      • Fixes a heap OOB access in RunForwardTypeInference (CVE-2022-23592)
      • Fixes a crash due to erroneous StatusOr (CVE-2022-23590)
      • Fixes multiple crashes and heap OOB accesses in TFG dialect (MLIR) (CVE-2022-23594)
      • Fixes a segfault in simplifyBroadcast (MLIR) (CVE-2022-23593)
      • Fixes a null pointer dereference in BuildXlaCompilationCache (XLA) (CVE-2022-23595)
      • Updates icu to 69.1 to handle CVE-2020-10531

      Feel free to contact us if you have any questions or take a look at our Deep Learning Solutions if you're interested in a workstation or server to run TensorFlow on.


      Tags

      tensorflow

      machine learning

      ai

      keras

      deep learning

      artificial intelligence



      Related Content