Skip to content

Commit

Permalink
Merge branch 'r2.13' into anirudh161-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaimaruseac committed May 26, 2023
2 parents edc153f + 236be4f commit 941732d
Show file tree
Hide file tree
Showing 27 changed files with 7,655 additions and 247 deletions.
50 changes: 23 additions & 27 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

### Major Features and Improvements

* `tf.lite`:
* `tf.lite`

* Added 16-bit and 64-bit float type support for built-in op `cast`.
* The Python TF Lite Interpreter bindings now have an option `experimental_disable_delegate_clustering` to turn-off delegate clustering.
Expand All @@ -26,7 +26,7 @@
* `add_op` supports broadcasting up to 6 dimensions.
* Added 16-bit support for `top_k`.

* `tf.function`:
* `tf.function`

* ConcreteFunction (`tf.types.experimental.ConcreteFunction`) as generated through `get_concrete_function` now performs holistic input validation similar to calling `tf.function` directly. This can cause breakages where existing calls pass Tensors with the wrong shape or omit certain non-Tensor arguments (including default values).

Expand Down Expand Up @@ -59,54 +59,50 @@

* Opened an experimental API, `tf.distribute.experimental.coordinator.get_current_worker_index`, for retrieving the worker index from within a worker, when using parameter server training with a custom training loop.

* `tf.experimental.dtensor`:
* `tf.experimental.dtensor`

* Deprecated `dtensor.run_on` in favor of `dtensor.default_mesh` to correctly indicate that the context does not override the mesh that the ops and functions will run on, it only sets a fallback default mesh.
* List of members of `dtensor.Layout` and `dtensor.Mesh` have slightly changed as part of efforts to consolidate the C++ and Python source code with pybind11. Most notably, `dtensor.Layout.serialized_string` is removed.
* Minor API changes to represent Single Device Layout for non-distributed Tensors inside DTensor functions. Runtime support will be added soon.

* `tf.experimental.ExtensionType`:
* `tf.experimental.ExtensionType`

* `tf.experimental.ExtensionType` now supports Python `tuple` as the type annotation of its fields.

* `tf.nest`:
* Deprecated API `tf.nest.is_sequence` has now been deleted. Please use `tf.nest.is_nested` instead.
* `tf.nest`

* Deprecated API `tf.nest.is_sequence` has now been deleted. Please use `tf.nest.is_nested` instead.

## Keras

Keras is a framework built on top of the TensorFlow. See more details on the [Keras website](https://keras.io/).

### Breaking Changes

* `tf.keras`

* Removed the Keras scikit-learn API wrappers (`KerasClassifier` and `KerasRegressor`), which had been deprecated in August 2021. We recommend using [SciKeras](https://github.com/adriangb/scikeras) instead.
* The default Keras model saving format is now the Keras v3 format: calling `model.save("xyz.keras")` will no longer create a H5 file, it will create a native Keras model file. This will only be breaking for you if you were manually inspecting or modifying H5 files saved by Keras under a `.keras` extension. If this breaks you, simply add `save_format="h5"` to your `.save()` call to revert back to the prior behavior.
* Added `keras.utils.TimedThread` utility to run a timed thread every x seconds. It can be used to run a threaded function alongside model training or any other snippet of code.
* In the `keras` PyPI package, accessible symbols are now restricted to symbols that are intended to be public. This may affect your code if you were using `import keras` and you used `keras` functions that were not public APIs, but were accessible in earlier versions with direct imports. In those cases, please use the following guideline:
* Removed the Keras scikit-learn API wrappers (`KerasClassifier` and `KerasRegressor`), which had been deprecated in August 2021. We recommend using [SciKeras](https://github.com/adriangb/scikeras) instead.
* The default Keras model saving format is now the Keras v3 format: calling `model.save("xyz.keras")` will no longer create a H5 file, it will create a native Keras model file. This will only be breaking for you if you were manually inspecting or modifying H5 files saved by Keras under a `.keras` extension. If this breaks you, simply add `save_format="h5"` to your `.save()` call to revert back to the prior behavior.
* Added `keras.utils.TimedThread` utility to run a timed thread every x seconds. It can be used to run a threaded function alongside model training or any other snippet of code.
* In the `keras` PyPI package, accessible symbols are now restricted to symbols that are intended to be public. This may affect your code if you were using `import keras` and you used `keras` functions that were not public APIs, but were accessible in earlier versions with direct imports. In those cases, please use the following guideline:
- The API may be available in the public Keras API under a different name, so make sure to look for it on keras.io or TensorFlow docs and switch to the public version.
- It could also be a simple python or TF utility that you could easily copy over to your own codebase. In those case, just make it your own!
- If you believe it should definitely be a public Keras API, please open a feature request in keras GitHub repo.
- As a workaround, you could import the same private symbol keras `keras.src`, but keep in mind the `src` namespace is not stable and those APIs may change or be removed in the future.

### Major Features and Improvements

* `tf.keras`

* Added F-Score metrics `tf.keras.metrics.FBetaScore`, `tf.keras.metrics.F1Score`, and `tf.keras.metrics.R2Score`.
* Added activation function `tf.keras.activations.mish`.
* Added experimental `keras.metrics.experimental.PyMetric` API for metrics that run Python code on the host CPU (compiled outside of the TensorFlow graph). This can be used for integrating metrics from external Python libraries (like sklearn or pycocotools) into Keras as first-class Keras metrics.
* Added `tf.keras.optimizers.Lion` optimizer.
* Added `tf.keras.layers.SpectralNormalization` layer wrapper to perform spectral normalization on the weights of a target layer.
* The `SidecarEvaluatorModelExport` callback has been added to Keras as `keras.callbacks.SidecarEvaluatorModelExport`. This callback allows for exporting the model the best-scoring model as evaluated by a `SidecarEvaluator` evaluator. The evaluator regularly evaluates the model and exports it if the user-defined comparison function determines that it is an improvement.
* Added warmup capabilities to `tf.keras.optimizers.schedules.CosineDecay` learning rate scheduler. You can now specify an initial and target learning rate, and our scheduler will perform a linear interpolation between the two after which it will begin a decay phase.
* Added experimental support for an exactly-once visitation guarantee for evaluating Keras models trained with `tf.distribute ParameterServerStrategy`, via the `exact_evaluation_shards` argument in `Model.fit` and `Model.evaluate`.
* Added `tf.keras.__internal__.KerasTensor`,`tf.keras.__internal__.SparseKerasTensor`, and `tf.keras.__internal__.RaggedKerasTensor` classes. You can use these classes to do instance type checking and type annotations for layer/model inputs and outputs.
* All the `tf.keras.dtensor.experimental.optimizers` classes have been merged with `tf.keras.optimizers`. You can migrate your code to use `tf.keras.optimizers` directly. The API namespace for `tf.keras.dtensor.experimental.optimizers` will be removed in future releases.
* Added support for `class_weight` for 3+ dimensional targets (e.g. image segmentation masks) in `Model.fit`.
* Added a new loss, `keras.losses.CategoricalFocalCrossentropy`.
* Removed the `tf.keras.dtensor.experimental.layout_map_scope()`. Use `tf.keras.dtensor.experimental.LayoutMap.scope()` instead.
* Added F-Score metrics `tf.keras.metrics.FBetaScore`, `tf.keras.metrics.F1Score`, and `tf.keras.metrics.R2Score`.
* Added activation function `tf.keras.activations.mish`.
* Added experimental `keras.metrics.experimental.PyMetric` API for metrics that run Python code on the host CPU (compiled outside of the TensorFlow graph). This can be used for integrating metrics from external Python libraries (like sklearn or pycocotools) into Keras as first-class Keras metrics.
* Added `tf.keras.optimizers.Lion` optimizer.
* Added `tf.keras.layers.SpectralNormalization` layer wrapper to perform spectral normalization on the weights of a target layer.
* The `SidecarEvaluatorModelExport` callback has been added to Keras as `keras.callbacks.SidecarEvaluatorModelExport`. This callback allows for exporting the model the best-scoring model as evaluated by a `SidecarEvaluator` evaluator. The evaluator regularly evaluates the model and exports it if the user-defined comparison function determines that it is an improvement.
* Added warmup capabilities to `tf.keras.optimizers.schedules.CosineDecay` learning rate scheduler. You can now specify an initial and target learning rate, and our scheduler will perform a linear interpolation between the two after which it will begin a decay phase.
* Added experimental support for an exactly-once visitation guarantee for evaluating Keras models trained with `tf.distribute ParameterServerStrategy`, via the `exact_evaluation_shards` argument in `Model.fit` and `Model.evaluate`.
* Added `tf.keras.__internal__.KerasTensor`,`tf.keras.__internal__.SparseKerasTensor`, and `tf.keras.__internal__.RaggedKerasTensor` classes. You can use these classes to do instance type checking and type annotations for layer/model inputs and outputs.
* All the `tf.keras.dtensor.experimental.optimizers` classes have been merged with `tf.keras.optimizers`. You can migrate your code to use `tf.keras.optimizers` directly. The API namespace for `tf.keras.dtensor.experimental.optimizers` will be removed in future releases.
* Added support for `class_weight` for 3+ dimensional targets (e.g. image segmentation masks) in `Model.fit`.
* Added a new loss, `keras.losses.CategoricalFocalCrossentropy`.
* Remove the `tf.keras.dtensor.experimental.layout_map_scope()`. You can user the `tf.keras.dtensor.experimental.LayoutMap.scope()` instead.

## Security

Expand Down
19 changes: 5 additions & 14 deletions tensorflow/core/common_runtime/executor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1201,20 +1201,11 @@ bool ExecutorState<PropagatorStateType>::NodeDone(
if (abort_run) {
TRACEPRINTF("StartAbort: %s", s.ToString().c_str());
if (cancellation_manager_) {
// Only log when the abort happens during the actual run time.
// Use LOG(INFO) instead of LOG(WARNING) because error status is
// expected when the executor is run under the grappler optimization
// phase. Do not log OutOfRange erros because they are expected when
// iterating through a tf.data input pipeline.
if (!errors::IsOutOfRange(s)) {
LOG(INFO) << "[" << immutable_state_.params().device->name()
<< "] (DEBUG INFO) Executor start aborting (this does not "
"indicate an error and you can ignore this message): "
<< s;
} else {
VLOG(1) << "[" << immutable_state_.params().device->name()
<< "] Executor start aborting: " << s;
}
// Use VLOG instead of LOG(warning) because error status is expected
// when the executor is run under the grappler optimization phase or
// when iterating through a tf.data input pipeline.
VLOG(1) << "[" << immutable_state_.params().device->name()
<< "] Executor start aborting: " << s;
}

if (rendezvous_) {
Expand Down
21 changes: 11 additions & 10 deletions tensorflow/core/kernels/mkl/mkl_matmul_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ class MklMatMulOp : public OpKernel {
(void)SetFPMathMode();
}

const int m = a.dim_size(1 - dim_pair[0].first);
const int k = a.dim_size(dim_pair[0].first);
const int n = b.dim_size(1 - dim_pair[0].second);
const int64_t m = a.dim_size(1 - dim_pair[0].first);
const int64_t k = a.dim_size(dim_pair[0].first);
const int64_t n = b.dim_size(1 - dim_pair[0].second);
bool transpose_a = dim_pair[0].first == 0;
bool transpose_b = dim_pair[0].second == 1;

Expand Down Expand Up @@ -147,9 +147,10 @@ class MklMatMulOp : public OpKernel {
// layout, leading dimension is the stride between consecutive rows, max(1,n)
//
// --------------------------------------------------------------------------
void MklBlasGemm(OpKernelContext* ctx, bool transa, bool transb, const int m,
const int n, const int k, const float* a, const int lda,
const float* b, const int ldb, float* c, const int ldc) {
void MklBlasGemm(OpKernelContext* ctx, bool transa, bool transb,
const int64_t m, const int64_t n, const int64_t k,
const float* a, const int64_t lda, const float* b,
const int64_t ldb, float* c, const int64_t ldc) {
// BLAS GEMM API defines Matrix Multiplication as c = alpha * op(a) * op(b)
// + beta * c.
// Since TF MatMul does not have parameters for alpha, beta, we set them to
Expand Down Expand Up @@ -180,10 +181,10 @@ class MklMatMulOp : public OpKernel {
#endif // !ENABLE_ONEDNN_OPENMP
}

void MklBlasGemm(OpKernelContext* ctx, bool transa, bool transb, const int m,
const int n, const int k, const bfloat16* a, const int lda,
const bfloat16* b, const int ldb, bfloat16* c,
const int ldc) {
void MklBlasGemm(OpKernelContext* ctx, bool transa, bool transb,
const int64_t m, const int64_t n, const int64_t k,
const bfloat16* a, const int64_t lda, const bfloat16* b,
const int64_t ldb, bfloat16* c, const int64_t ldc) {
const float alpha = 1.0f;
const float beta = 0.0f;
const int index_transa = transa ? 1 : 0;
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/core/kernels/mkl/mkl_matmul_ops_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace tensorflow {
static Eigen::internal::CacheSizes cache_sizes = Eigen::internal::CacheSizes();

typedef Eigen::ThreadPoolDevice CPUDevice;
inline bool ExecuteSingleThreadedGemm(int m, int n, int k, int bytes) {
inline bool ExecuteSingleThreadedGemm(int64_t m, int64_t n, int64_t k, int bytes) {
// Ideally we would like to determine blocking and then come up with
// a heuristic but what we are targeting are very small models whose
// total size is < x*L2. So we will do this simple calculation
Expand Down
2 changes: 1 addition & 1 deletion tensorflow/core/public/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ limitations under the License.

// TF_VERSION_SUFFIX is non-empty for pre-releases (e.g. "-alpha", "-alpha.1",
// "-beta", "-rc", "-rc.1")
#define TF_VERSION_SUFFIX "-rc0"
#define TF_VERSION_SUFFIX "-rc1"

#define TF_STR_HELPER(x) #x
#define TF_STR(x) TF_STR_HELPER(x)
Expand Down
1 change: 1 addition & 0 deletions tensorflow/opensource_only.files
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ tensorflow/tools/benchmark/onednn_benchmark_config:.sh
tensorflow/tools/build_info/BUILD:
tensorflow/tools/ci_build/a100/nightly.sh:
tensorflow/tools/ci_build/horovod/gpu/nightly.sh:
tensorflow/tools/ci_build/osx/arm64/tensorflow_metal_plugin_test:.py
tensorflow/tools/ci_build/release/common.sh:
tensorflow/tools/ci_build/release/common_win.bat:
tensorflow/tools/ci_build/release/mac_build_utils.sh:
Expand Down
5 changes: 5 additions & 0 deletions tensorflow/python/checkpoint/checkpoint_management.py
Original file line number Diff line number Diff line change
Expand Up @@ -877,3 +877,8 @@ def restore_or_initialize(self):
logging.info(
"Customized initialization is done through the passed `init_fn`.")
return None

def sync(self):
"""Wait for any outstanding save or restore operations."""
if self._checkpoint:
self._checkpoint.sync()
3 changes: 2 additions & 1 deletion tensorflow/python/training/saving/saveable_object_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,8 @@ def trackable_has_serialize_to_tensor(obj):
# In some cases (e.g. restored objects), the object may have
# `_serialize_to_tensors` even if the class does not.
return True
except AttributeError: # Data structure proxy wrappers don't have __dict__.
except (AttributeError, TypeError):
# Data structure proxy wrappers don't have __dict__.
pass

# Use MRO so that if a parent class has `_serialize_to_tensors`, but the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,8 @@ tf_class {
name: "save"
argspec: "args=[\'self\', \'checkpoint_number\', \'check_interval\', \'options\'], varargs=None, keywords=None, defaults=[\'None\', \'True\', \'None\'], "
}
member_method {
name: "sync"
argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,8 @@ tf_class {
name: "save"
argspec: "args=[\'self\', \'checkpoint_number\', \'check_interval\', \'options\'], varargs=None, keywords=None, defaults=[\'None\', \'True\', \'None\'], "
}
member_method {
name: "sync"
argspec: "args=[\'self\'], varargs=None, keywords=None, defaults=None"
}
}
1 change: 1 addition & 0 deletions tensorflow/tools/ci_build/build_scripts/ARM_SKIP_TESTS.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ set -x

ARM_SKIP_TESTS="-//tensorflow/lite/... \
-//tensorflow/python/kernel_tests/nn_ops:atrous_conv2d_test \
-//tensorflow/python/kernel_tests/nn_ops:conv_ops_test \
"
Loading

0 comments on commit 941732d

Please sign in to comment.