Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release a version from git 2023/11 for tf 2.14 compatibility #6

Merged
merged 2 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 36 additions & 5 deletions recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,50 @@

package:
name: tf_slim
version: {{ version }}
version: {{ version }}.post20231128
source:
url: https://github.com/google-research/tf-slim/archive/refs/heads/r{{ version }}.zip
sha256: f9f6f04c9852bd6bc76bc11e1090ae44ff1dea31a5d7ef4f5feeaa20ae55cdb2
patches:
# Find the commit after the latest release 1.1.0
# https://github.com/google-research/tf-slim/pull/21
- 21-avoid_layer_apply.patch
# https://github.com/google-research/tf-slim/commit/550196c9db2b76d9e23bc394f4dd02df78159a6a
- numpy_123_comaptibility.patch
# git checkout remove_layer_apply
# git format-patch 8f0215e924996d7287392241bc8d8b1133d0c5ca
- patches/0001-Internal-change.patch
- patches/0002-Set-the-default-value-for-the-use_gpu-param-to-True-.patch
- patches/0003-Fix-a-NaN-issue-with-streaming_covariance.patch
- patches/0004-Remove-the-private-TF-API-usage-of-layers.patch
- patches/0005-Internal-Google-change.patch
- patches/0006-Fix-TensorFlow-checkpoint-and-trackable-imports.patch
- patches/0007-NumPy-Fix-NumPy-1.23-compatibility-problems-in-tf_sl.patch
- patches/0008-Fix-tests-broken-by-previous-change-list-due-to-smal.patch
- patches/0009-NumPy-Remove-references-to-deprecated-NumPy-type-ali.patch
- patches/0010-NumPy-Remove-references-to-deprecated-NumPy-type-ali.patch
- patches/0011-Remove-legacy-references-from-ops.py.patch
- patches/0012-Redirect-references-to-stack-and-unstack-to-their-ne.patch
- patches/0013-Refactor-case-and-case_v2-out-of-control_flow_ops.py.patch
- patches/0014-Move-control_flow_ops.Assert-into-its-own-file-contr.patch
- patches/0015-Move-control_flow_ops.while_loop-into-its-own-file-w.patch
- patches/0016-Redirect-references-from-control_flow_ops.cond-to-co.patch
- patches/0017-Update-some-isinstance-checks-of-tf.compat.v1.Variab.patch
- patches/0018-Update-references-from-variables.VariableV1-to-its-n.patch
- patches/0019-Update-references-from-tensorflow.python.platform-to.patch
- patches/0020-Update-legacy-reference-to-variable_scope.variable-i.patch
- patches/0021-Internal-Code-Change.patch
- patches/0022-Delete-remnants-of-toollog-removal.patch
- patches/0023-NumPy-Fix-uses-of-functions-deprecated-in-NumPy-1.25.patch
- patches/0024-Use-ExitStack-and-call-ops.device-device-only-when-d.patch
- patches/0025-Fix-streaming_concat-crashes-on-specific-and-relativ.patch
- patches/0026-Update-ops.Tensor-references-to-third_party-tensorfl.patch
- patches/0027-Update-legacy-references-to-tensor.Tensor.patch
- patches/0028-Move-references-to-TF-resource-variable-toggle-funct.patch
- patches/0029-Update-outdated-references-to-functions-imported-by-.patch
# https://github.com/google-research/tf-slim/pull/21
- patches/0030-Remove-call-to-layer.apply-and-just-use-__call__.patch

build:
noarch: python
number: 3
number: 0
script: {{ PYTHON }} -m pip install . -vv

requirements:
Expand Down
35 changes: 35 additions & 0 deletions recipe/patches/0001-Internal-change.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
From b189304a31b4e471128e988a3108ee6845a53e31 Mon Sep 17 00:00:00 2001
From: Sanjoy Das <[email protected]>
Date: Wed, 27 Jan 2021 20:59:44 -0800
Subject: [PATCH 01/30] Internal change.

PiperOrigin-RevId: 354234980
Change-Id: I5989d83c71236cd88b5cdbf245dbb96c3a36068c
---
pip_pkg.sh | 2 +-
tests_release.sh | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/pip_pkg.sh b/pip_pkg.sh
index 5caab4e..632cb16 100755
--- a/pip_pkg.sh
+++ b/pip_pkg.sh
@@ -1,4 +1,4 @@
-# Copyright 2020 The TF-Slim Authors.
+# Copyright 2021 The TF-Slim Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
diff --git a/tests_release.sh b/tests_release.sh
index 5c3b5e7..a719d50 100755
--- a/tests_release.sh
+++ b/tests_release.sh
@@ -1,4 +1,4 @@
-# Copyright 2020 The TF-Slim Authors.
+# Copyright 2021 The TF-Slim Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
--
2.40.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
From 6387efbf7878c5269f3a19cbe33e631988528bc5 Mon Sep 17 00:00:00 2001
From: Sanjoy Das <[email protected]>
Date: Wed, 10 Feb 2021 22:53:32 -0800
Subject: [PATCH 02/30] Set the default value for the use_gpu-param to True in
test utilities

Also, fix a bug in IsFunctionCallOp found by this CL.

Contrary to what it sounds like, `use_gpu` does not force the test to run on
GPUs, it merely *allows* the test to run on GPUs (there is a separate
`force_gpu` option for forcing). This means setting `use_gpu` to `True` means
that the test will run on GPUs if one is available.

Given that setting `use_gpu` to `True` by default makes sense, and there should
be a good reason for a test to set it to `False` (which disallows GPU use, even
when one is available).

For this reason, this CL changes the default value of `use_gpu`. As you can
see, this has already found a few real bugs.

In a later CL I will remove instances that pass use_gpu=True explicitly as those
should no longer be necessary.

PiperOrigin-RevId: 356906251
Change-Id: I39cc6e254b3295f3f3bc5c90f397cf15bd1c2eed
---
tf_slim/ops/variables_test.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tf_slim/ops/variables_test.py b/tf_slim/ops/variables_test.py
index 231f99e..9f127eb 100644
--- a/tf_slim/ops/variables_test.py
+++ b/tf_slim/ops/variables_test.py
@@ -480,7 +480,8 @@ class VariablesTest(test.TestCase):
self.assertDeviceEqual(e.initial_value.device, 'cpu:99')

def testVariableWithReplicaDeviceSetter(self):
- with self.cached_session():
+ # Explicitly disable GPU usage because we check for the CPU device below.
+ with self.cached_session(use_gpu=False):
with ops.device(device_setter.replica_device_setter(ps_tasks=2)):
a = variables_lib2.variable('a', [])
b = variables_lib2.variable('b', [])
--
2.40.1

Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
From 77b441267e27359e94a641b906f07afc25f69b13 Mon Sep 17 00:00:00 2001
From: TF-Slim Team <[email protected]>
Date: Mon, 15 Mar 2021 21:08:50 -0700
Subject: [PATCH 03/30] Fix a NaN issue with streaming_covariance.

PiperOrigin-RevId: 363099343
Change-Id: I7012be19e3afd9b0b1f8f7b8e047065ae09909ce
---
tf_slim/metrics/metric_ops.py | 2 +-
tf_slim/metrics/metric_ops_test.py | 27 +++++++++++++++++----------
2 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/tf_slim/metrics/metric_ops.py b/tf_slim/metrics/metric_ops.py
index 3febbfa..cdd844c 100644
--- a/tf_slim/metrics/metric_ops.py
+++ b/tf_slim/metrics/metric_ops.py
@@ -3242,7 +3242,7 @@ def streaming_covariance(predictions,
delta_comoment = (
batch_comoment + (prev_mean_prediction - batch_mean_prediction) *
(prev_mean_label - batch_mean_label) *
- (prev_count * batch_count / update_count))
+ (math_ops.div_no_nan(prev_count * batch_count, update_count)))
update_comoment = state_ops.assign_add(comoment, delta_comoment)

covariance = array_ops.where(
diff --git a/tf_slim/metrics/metric_ops_test.py b/tf_slim/metrics/metric_ops_test.py
index 9920fa2..3d63758 100644
--- a/tf_slim/metrics/metric_ops_test.py
+++ b/tf_slim/metrics/metric_ops_test.py
@@ -5947,12 +5947,13 @@ class StreamingCovarianceTest(tf.test.TestCase):
with self.cached_session() as sess:
np.random.seed(123)
n = 100
+ stride = 10
predictions = np.random.randn(n)
labels = 0.5 * predictions + np.random.randn(n)
- weights = np.tile(np.arange(n // 10), n // 10)
+ weights = np.tile(np.arange(n // stride), n // stride)
np.random.shuffle(weights)
+ weights[0:stride] = 0.0

- stride = 10
predictions_t = array_ops.placeholder(dtypes_lib.float32, [stride])
labels_t = array_ops.placeholder(dtypes_lib.float32, [stride])
weights_t = array_ops.placeholder(dtypes_lib.float32, [stride])
@@ -5974,14 +5975,20 @@ class StreamingCovarianceTest(tf.test.TestCase):
if not np.isnan(prev_expected_cov):
self.assertAlmostEqual(prev_expected_cov,
sess.run(cov, feed_dict=feed_dict), 5)
- expected_cov = np.cov(
- predictions[:stride * (i + 1)],
- labels[:stride * (i + 1)],
- fweights=weights[:stride * (i + 1)])[0, 1]
- self.assertAlmostEqual(expected_cov,
- sess.run(update_op, feed_dict=feed_dict), 5)
- self.assertAlmostEqual(expected_cov, sess.run(cov, feed_dict=feed_dict),
- 5)
+ if np.sum(weights[:stride * (i + 1)]) != 0.0:
+ expected_cov = np.cov(
+ predictions[:stride * (i + 1)],
+ labels[:stride * (i + 1)],
+ fweights=weights[:stride * (i + 1)])[0, 1]
+ else:
+ expected_cov = NAN
+ sess.run(update_op, feed_dict=feed_dict)
+ self.assertEqual(
+ np.isnan(expected_cov),
+ np.isnan(sess.run(cov, feed_dict=feed_dict)))
+ if not np.isnan(expected_cov):
+ self.assertAlmostEqual(expected_cov,
+ sess.run(cov, feed_dict=feed_dict), 5)
prev_expected_cov = expected_cov


--
2.40.1

Loading