Skip to content

Commit 89a0b8f

Browse files
[converter] fixed py import for auto tracking (#7982)
* update py import for auto tracking * [e2e] Use ios12 and report karma seed (#7984) * [e2e] Use ios12 and report karma seed * Update karma.conf.js --------- Co-authored-by: Matthew Soulanille <[email protected]>
1 parent 73b2fd1 commit 89a0b8f

File tree

11 files changed

+38
-28
lines changed

11 files changed

+38
-28
lines changed

e2e/integration_tests/convert_predict.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
from tensorflow.python.framework import dtypes
4343
from tensorflow.python.framework import tensor_spec
4444
from tensorflow.python.ops import variables
45-
from tensorflow.python.training.tracking import tracking
45+
from tensorflow.python.trackable import autotrackable
4646
from tensorflow.python.saved_model.save import save
4747
import tensorflow_hub as hub
4848
import tensorflowjs as tfjs
@@ -182,7 +182,7 @@ def _create_saved_model_v2(save_dir):
182182
save_dir: directory name of where the saved model will be stored.
183183
"""
184184
input_data = constant_op.constant(1., shape=[1])
185-
root = tracking.AutoTrackable()
185+
root = autotrackable.AutoTrackable()
186186
root.v1 = variables.Variable(3.)
187187
root.v2 = variables.Variable(2.)
188188
root.f = def_function.function(lambda x: root.v1 * root.v2 * x)
@@ -211,7 +211,7 @@ def square_if_positive(v):
211211
v = v + 1
212212
return v
213213

214-
root = tracking.AutoTrackable()
214+
root = autotrackable.AutoTrackable()
215215
root.f = square_if_positive
216216
to_save = root.f.get_concrete_function(
217217
tensor_spec.TensorSpec([], dtypes.float32))
@@ -290,7 +290,7 @@ def _create_saved_model_v2_complex64(save_dir):
290290
save_dir: directory name of where the saved model will be stored.
291291
"""
292292
input_data = constant_op.constant(1., shape=[1])
293-
root = tracking.AutoTrackable()
293+
root = autotrackable.AutoTrackable()
294294
root.v1 = variables.Variable(3 + 1j, dtype=tf.complex64)
295295
root.f = def_function.function(lambda x: tf.complex(x, x) + root.v1)
296296
to_save = root.f.get_concrete_function(input_data)

e2e/integration_tests/metadata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
from tensorflow.python.framework import dtypes
4343
from tensorflow.python.framework import tensor_spec
4444
from tensorflow.python.ops import variables
45-
from tensorflow.python.training.tracking import tracking
45+
from tensorflow.python.trackable import autotrackable
4646
from tensorflow.python.saved_model.save import save
4747
import tensorflow_hub as hub
4848
import tensorflowjs as tfjs
@@ -79,7 +79,7 @@ def _create_model_with_metadata():
7979

8080
def _create_saved_model(save_dir):
8181
input_data = constant_op.constant(1., shape=[1])
82-
root = tracking.AutoTrackable()
82+
root = autotrackable.AutoTrackable()
8383
root.v1 = variables.Variable(3.)
8484
root.v2 = variables.Variable(2.)
8585
root.f = def_function.function(lambda x: root.v1 * root.v2 * x)

e2e/karma.conf.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,10 @@ module.exports = function(config) {
144144

145145
config.set({
146146
...extraConfig,
147+
reporters: [
148+
'spec',
149+
'jasmine-order',
150+
],
147151
browsers: ['Chrome'],
148152
browserStack: {
149153
username: process.env.BROWSERSTACK_USERNAME,
@@ -182,9 +186,9 @@ module.exports = function(config) {
182186
},
183187
bs_ios_12: {
184188
base: 'BrowserStack',
185-
device: 'iPhone X',
186-
os: 'iOS',
187-
os_version: '11.0',
189+
device: 'iPhone XS',
190+
os: 'ios',
191+
os_version: '12.3',
188192
real_mobile: true
189193
},
190194
bs_android_10: {

e2e/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
"karma-browserstack-launcher": "~1.6.0",
3131
"karma-chrome-launcher": "~3.1.1",
3232
"karma-jasmine": "~1.1.0",
33+
"karma-jasmine-order-reporter": "^1.1.0",
3334
"karma-spec-reporter": "~0.0.32",
3435
"karma-typescript": "~5.5.1",
3536
"karma-typescript-es6-transform": "^5.1.0",

e2e/yarn.lock

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2855,10 +2855,15 @@ karma-chrome-launcher@~3.1.1:
28552855
dependencies:
28562856
which "^1.2.1"
28572857

2858+
karma-jasmine-order-reporter@^1.1.0:
2859+
version "1.1.0"
2860+
resolved "https://registry.yarnpkg.com/karma-jasmine-order-reporter/-/karma-jasmine-order-reporter-1.1.0.tgz#3bd4cfd9e5ae53cc0d972905b811a479c127d0a8"
2861+
integrity sha512-mzC6WfOg7y5kCf7K4W+nB5NHea1ogcDjRpepFLLRjbi4lx08wQG+6EY2zd+mC2ANIvb6+ux2d9mFVtZ3MIwTYg==
2862+
28582863
karma-jasmine@~1.1.0:
28592864
version "1.1.2"
28602865
resolved "https://registry.yarnpkg.com/karma-jasmine/-/karma-jasmine-1.1.2.tgz#394f2b25ffb4a644b9ada6f22d443e2fd08886c3"
2861-
integrity sha1-OU8rJf+0pkS5rabyLUQ+L9CIhsM=
2866+
integrity sha512-SENGE9DhlIIFTSZWiNq4eGeXL8G6z9cqHIOdkx9jh1qhhQqwEy3tAoLRyER0vOcHqdOlKmGpOuXk+HOipIy7sg==
28622867

28632868
karma-spec-reporter@~0.0.32:
28642869
version "0.0.33"

tfjs-converter/python/tensorflowjs/converters/fuse_prelu_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from tensorflow.python.eager import def_function
2525
from tensorflow.python.framework import constant_op
2626
from tensorflow.python.ops import variables
27-
from tensorflow.python.training.tracking import tracking
27+
from tensorflow.python.trackable import autotrackable
2828

2929
from tensorflowjs.converters import fuse_depthwise_conv2d
3030
from tensorflowjs.converters import fuse_prelu
@@ -242,7 +242,7 @@ def execute_model(tensor):
242242
def testNonPreluPattern(self):
243243
"""Test a basic model with functions to make sure functions are inlined."""
244244
input_data = constant_op.constant(1., shape=[1])
245-
root = tracking.AutoTrackable()
245+
root = autotrackable.AutoTrackable()
246246
root.v1 = variables.Variable(3.)
247247
root.v2 = variables.Variable(2.)
248248

tfjs-converter/python/tensorflowjs/converters/tf_saved_model_conversion_v2_test.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from tensorflow.python.framework import dtypes
3131
from tensorflow.python.framework import tensor_spec
3232
from tensorflow.python.ops import variables
33-
from tensorflow.python.training.tracking import tracking
33+
from tensorflow.python.trackable import autotrackable
3434
from tensorflow.python.tools import freeze_graph
3535
from tensorflow.python.saved_model.save import save
3636
import tensorflow_hub as hub
@@ -190,7 +190,7 @@ def conv2d_addV2_depthwise_addV2(x):
190190
input=res, filter=filter, strides=[1, 1, 1, 1], padding="VALID")
191191
res = tf.raw_ops.AddV2(x=res, y=bias)
192192
return res
193-
root = tracking.AutoTrackable()
193+
root = autotrackable.AutoTrackable()
194194
root.f = conv2d_addV2_depthwise_addV2
195195
to_save = root.f.get_concrete_function(
196196
tensor_spec.TensorSpec([1, 1, 1, 1], dtypes.float32))
@@ -207,7 +207,7 @@ def addV2_conv2d(x):
207207
res = tf.raw_ops.Conv2D(
208208
input=res, filter=filter, strides=[1, 1, 1, 1], padding="VALID")
209209
return res
210-
root = tracking.AutoTrackable()
210+
root = autotrackable.AutoTrackable()
211211
root.f = addV2_conv2d
212212
to_save = root.f.get_concrete_function(
213213
tensor_spec.TensorSpec([1, 1, 1, 1], dtypes.float32))
@@ -247,7 +247,7 @@ def _create_saved_model_with_unfusable_prelu(self):
247247
def _create_saved_model(self):
248248
"""Test a basic model with functions to make sure functions are inlined."""
249249
input_data = constant_op.constant(1., shape=[1])
250-
root = tracking.AutoTrackable()
250+
root = autotrackable.AutoTrackable()
251251
root.v1 = variables.Variable(3.)
252252
root.v2 = variables.Variable(2.)
253253
root.f = def_function.function(lambda x: root.v1 * root.v2 * x)
@@ -260,7 +260,7 @@ def _create_saved_model_with_fusable_matmul(self):
260260
"""Test a fusable matmul model."""
261261
input_data = constant_op.constant(1., shape=[1, 1])
262262
bias_data = constant_op.constant(1., shape=[1])
263-
root = tracking.AutoTrackable()
263+
root = autotrackable.AutoTrackable()
264264
root.v2 = variables.Variable([[2.]])
265265
root.f = def_function.function(
266266
lambda x: tf.nn.relu(tf.nn.bias_add(tf.matmul(x, root.v2),
@@ -278,7 +278,7 @@ def find_next_odd(v):
278278
while tf.equal(v1 % 2, 0):
279279
v1 = v1 + 1
280280
return v1
281-
root = tracking.AutoTrackable()
281+
root = autotrackable.AutoTrackable()
282282
root.f = find_next_odd
283283
to_save = root.f.get_concrete_function(
284284
tensor_spec.TensorSpec([], dtypes.int32))
@@ -303,7 +303,7 @@ def _create_saved_model_with_tfdf(self):
303303
model.save(save_dir)
304304

305305
def _create_unsupported_saved_model(self):
306-
root = tracking.AutoTrackable()
306+
root = autotrackable.AutoTrackable()
307307
root.w = variables.Variable(tf.random.uniform([2, 2]))
308308

309309
@def_function.function
@@ -322,7 +322,7 @@ def exported_function(x):
322322
save(root, save_dir, to_save)
323323

324324
def _create_saved_model_with_debug_ops(self):
325-
root = tracking.AutoTrackable()
325+
root = autotrackable.AutoTrackable()
326326
root.w = variables.Variable(tf.random.uniform([2, 2]))
327327

328328
@def_function.function

tfjs-converter/python/tensorflowjs/converters/wizard_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import tensorflow.compat.v2 as tf
2525
from tensorflow.python.eager import def_function
2626
from tensorflow.python.ops import variables
27-
from tensorflow.python.training.tracking import tracking
27+
from tensorflow.python.trackable import autotrackable
2828
from tensorflow.python.saved_model import save
2929

3030
from tensorflowjs.converters import wizard
@@ -74,7 +74,7 @@ def _create_keras_saved_model(self):
7474
def _create_saved_model(self):
7575
"""Test a basic model with functions to make sure functions are inlined."""
7676
input_data = tf.constant(1., shape=[1])
77-
root = tracking.AutoTrackable()
77+
root = autotrackable.AutoTrackable()
7878
root.v1 = variables.Variable(3.)
7979
root.v2 = variables.Variable(2.)
8080
root.f = def_function.function(lambda x: root.v1 * root.v2 * x)

tfjs-converter/python/test_pip_package.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
from tensorflow.python.framework import constant_op
3434
from tensorflow.python.ops import variables
3535
from tensorflow.python.tools import freeze_graph
36-
from tensorflow.python.training.tracking import tracking
36+
from tensorflow.python.trackable import autotrackable
3737
from tensorflow.python.saved_model.save import save
3838
import tensorflow_hub as hub
3939

@@ -115,7 +115,7 @@ def _createTensorFlowSavedModel(save_path):
115115
"""
116116

117117
input_data = constant_op.constant(1., shape=[1])
118-
root = tracking.AutoTrackable()
118+
root = autotrackable.AutoTrackable()
119119
root.v1 = variables.Variable(3.)
120120
root.v2 = variables.Variable(2.)
121121
root.f = def_function.function(lambda x: root.v1 * root.v2 * x)

tfjs-node/python/int64_model.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@
2121
from tensorflow.python.framework import constant_op
2222
from tensorflow.python.framework import dtypes
2323
from tensorflow.python.ops import variables
24-
from tensorflow.python.training.tracking import tracking
24+
from tensorflow.python.trackable import autotrackable
2525
from tensorflow.python.saved_model.save import save
2626

2727
"""Test a basic model with functions to make sure functions are inlined."""
2828
input_data = constant_op.constant(1, shape=[2], dtype=tf.int64)
29-
root = tracking.AutoTrackable()
29+
root = autotrackable.AutoTrackable()
3030
root.v1 = variables.Variable(3, dtype=tf.int64)
3131
root.v2 = variables.Variable(2, dtype=tf.int64)
3232
root.f = def_function.function(lambda x: root.v1 * root.v2 * x)

0 commit comments

Comments
 (0)