16d3f15320
ARM CI / build (3.10) (push) Has been cancelled
cffconvert / validate (push) Has been cancelled
Creates a GitHub Issue when a PR Rolled back via Commit to Master / create-issue-on-pr-rollback (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
120 lines
4.3 KiB
Python
120 lines
4.3 KiB
Python
# Copyright 2026 The TensorFlow Authors. All Rights Reserved.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
# ==============================================================================
|
|
|
|
# Description:
|
|
# Utilities for sharding object-based checkpoints.
|
|
|
|
load("//tensorflow:pytype.default.bzl", "pytype_strict_library")
|
|
load("//tensorflow:tensorflow.default.bzl", "tf_py_strict_test")
|
|
|
|
package(
|
|
# copybara:uncomment default_applicable_licenses = ["//tensorflow:license"],
|
|
default_visibility = [
|
|
"//tensorflow:internal",
|
|
],
|
|
licenses = ["notice"],
|
|
)
|
|
|
|
pytype_strict_library(
|
|
name = "sharding_policies",
|
|
srcs = ["sharding_policies.py"],
|
|
deps = [
|
|
":sharding_util",
|
|
"//tensorflow/python/eager:context",
|
|
"//tensorflow/python/framework:device",
|
|
"//tensorflow/python/framework:dtypes",
|
|
"//tensorflow/python/framework:ops",
|
|
"//tensorflow/python/framework:tensor",
|
|
"//tensorflow/python/framework:tensor_shape",
|
|
"//tensorflow/python/ops:array_ops",
|
|
"//tensorflow/python/ops:string_ops",
|
|
"//tensorflow/python/ops:variables",
|
|
"//tensorflow/python/trackable:base",
|
|
"//tensorflow/python/util:tf_export",
|
|
"@absl_py//absl/logging",
|
|
],
|
|
)
|
|
|
|
tf_py_strict_test(
|
|
name = "sharding_policies_test",
|
|
srcs = ["sharding_policies_test.py"],
|
|
tags = [
|
|
"notap",
|
|
"oss_excluded",
|
|
], # See b/455621783.
|
|
deps = [
|
|
":sharding_policies",
|
|
":sharding_util",
|
|
"//tensorflow/python/checkpoint",
|
|
"//tensorflow/python/checkpoint:checkpoint_options",
|
|
"//tensorflow/python/checkpoint:graph_view",
|
|
"//tensorflow/python/eager:def_function",
|
|
"//tensorflow/python/eager:remote",
|
|
"//tensorflow/python/eager:test",
|
|
"//tensorflow/python/framework:device",
|
|
"//tensorflow/python/framework:dtypes",
|
|
"//tensorflow/python/framework:ops",
|
|
"//tensorflow/python/framework:tensor_shape",
|
|
"//tensorflow/python/framework:test_lib",
|
|
"//tensorflow/python/module",
|
|
"//tensorflow/python/ops:variables",
|
|
"//tensorflow/python/platform:gfile",
|
|
"//tensorflow/python/training:server_lib",
|
|
"//tensorflow/python/training/saving:saveable_object",
|
|
"//tensorflow/python/training/saving:saveable_object_util",
|
|
"@absl_py//absl/logging",
|
|
],
|
|
)
|
|
|
|
pytype_strict_library(
|
|
name = "sharding_util",
|
|
srcs = ["sharding_util.py"],
|
|
deps = [
|
|
"//tensorflow/python/framework:device",
|
|
"//tensorflow/python/framework:dtypes",
|
|
"//tensorflow/python/framework:tensor",
|
|
"//tensorflow/python/framework:tensor_shape",
|
|
"//tensorflow/python/framework:tensor_spec",
|
|
"//tensorflow/python/ops:variables",
|
|
"//tensorflow/python/trackable:base",
|
|
"//tensorflow/python/training/saving:saveable_object",
|
|
"//tensorflow/python/util:tf_export",
|
|
],
|
|
)
|
|
|
|
tf_py_strict_test(
|
|
name = "sharding_util_test",
|
|
srcs = ["sharding_util_test.py"],
|
|
deps = [
|
|
":sharding_policies",
|
|
":sharding_util",
|
|
"//tensorflow/python/checkpoint",
|
|
"//tensorflow/python/checkpoint:graph_view",
|
|
"//tensorflow/python/eager:remote",
|
|
"//tensorflow/python/eager:test",
|
|
"//tensorflow/python/framework:device",
|
|
"//tensorflow/python/framework:dtypes",
|
|
"//tensorflow/python/framework:ops",
|
|
"//tensorflow/python/framework:tensor",
|
|
"//tensorflow/python/module",
|
|
"//tensorflow/python/ops:array_ops",
|
|
"//tensorflow/python/ops:math_ops",
|
|
"//tensorflow/python/ops:resource_variable_ops",
|
|
"//tensorflow/python/training:server_lib",
|
|
"//tensorflow/python/training/saving:saveable_object",
|
|
"//tensorflow/python/training/saving:saveable_object_util",
|
|
],
|
|
)
|