Skip to content

Commit

Permalink
[converter] fixed py import for auto tracking (#7982)
Browse files Browse the repository at this point in the history
* 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 <msoulanille@google.com>
  • Loading branch information
pyu10055 and mattsoulanille committed Oct 3, 2023
1 parent 73b2fd1 commit 89a0b8f
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 28 deletions.
8 changes: 4 additions & 4 deletions e2e/integration_tests/convert_predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import tensor_spec
from tensorflow.python.ops import variables
from tensorflow.python.training.tracking import tracking
from tensorflow.python.trackable import autotrackable
from tensorflow.python.saved_model.save import save
import tensorflow_hub as hub
import tensorflowjs as tfjs
Expand Down Expand Up @@ -182,7 +182,7 @@ def _create_saved_model_v2(save_dir):
save_dir: directory name of where the saved model will be stored.
"""
input_data = constant_op.constant(1., shape=[1])
root = tracking.AutoTrackable()
root = autotrackable.AutoTrackable()
root.v1 = variables.Variable(3.)
root.v2 = variables.Variable(2.)
root.f = def_function.function(lambda x: root.v1 * root.v2 * x)
Expand Down Expand Up @@ -211,7 +211,7 @@ def square_if_positive(v):
v = v + 1
return v

root = tracking.AutoTrackable()
root = autotrackable.AutoTrackable()
root.f = square_if_positive
to_save = root.f.get_concrete_function(
tensor_spec.TensorSpec([], dtypes.float32))
Expand Down Expand Up @@ -290,7 +290,7 @@ def _create_saved_model_v2_complex64(save_dir):
save_dir: directory name of where the saved model will be stored.
"""
input_data = constant_op.constant(1., shape=[1])
root = tracking.AutoTrackable()
root = autotrackable.AutoTrackable()
root.v1 = variables.Variable(3 + 1j, dtype=tf.complex64)
root.f = def_function.function(lambda x: tf.complex(x, x) + root.v1)
to_save = root.f.get_concrete_function(input_data)
Expand Down
4 changes: 2 additions & 2 deletions e2e/integration_tests/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import tensor_spec
from tensorflow.python.ops import variables
from tensorflow.python.training.tracking import tracking
from tensorflow.python.trackable import autotrackable
from tensorflow.python.saved_model.save import save
import tensorflow_hub as hub
import tensorflowjs as tfjs
Expand Down Expand Up @@ -79,7 +79,7 @@ def _create_model_with_metadata():

def _create_saved_model(save_dir):
input_data = constant_op.constant(1., shape=[1])
root = tracking.AutoTrackable()
root = autotrackable.AutoTrackable()
root.v1 = variables.Variable(3.)
root.v2 = variables.Variable(2.)
root.f = def_function.function(lambda x: root.v1 * root.v2 * x)
Expand Down
10 changes: 7 additions & 3 deletions e2e/karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,10 @@ module.exports = function(config) {

config.set({
...extraConfig,
reporters: [
'spec',
'jasmine-order',
],
browsers: ['Chrome'],
browserStack: {
username: process.env.BROWSERSTACK_USERNAME,
Expand Down Expand Up @@ -182,9 +186,9 @@ module.exports = function(config) {
},
bs_ios_12: {
base: 'BrowserStack',
device: 'iPhone X',
os: 'iOS',
os_version: '11.0',
device: 'iPhone XS',
os: 'ios',
os_version: '12.3',
real_mobile: true
},
bs_android_10: {
Expand Down
1 change: 1 addition & 0 deletions e2e/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"karma-browserstack-launcher": "~1.6.0",
"karma-chrome-launcher": "~3.1.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-order-reporter": "^1.1.0",
"karma-spec-reporter": "~0.0.32",
"karma-typescript": "~5.5.1",
"karma-typescript-es6-transform": "^5.1.0",
Expand Down
7 changes: 6 additions & 1 deletion e2e/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2855,10 +2855,15 @@ karma-chrome-launcher@~3.1.1:
dependencies:
which "^1.2.1"

karma-jasmine-order-reporter@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/karma-jasmine-order-reporter/-/karma-jasmine-order-reporter-1.1.0.tgz#3bd4cfd9e5ae53cc0d972905b811a479c127d0a8"
integrity sha512-mzC6WfOg7y5kCf7K4W+nB5NHea1ogcDjRpepFLLRjbi4lx08wQG+6EY2zd+mC2ANIvb6+ux2d9mFVtZ3MIwTYg==

karma-jasmine@~1.1.0:
version "1.1.2"
resolved "https://registry.yarnpkg.com/karma-jasmine/-/karma-jasmine-1.1.2.tgz#394f2b25ffb4a644b9ada6f22d443e2fd08886c3"
integrity sha1-OU8rJf+0pkS5rabyLUQ+L9CIhsM=
integrity sha512-SENGE9DhlIIFTSZWiNq4eGeXL8G6z9cqHIOdkx9jh1qhhQqwEy3tAoLRyER0vOcHqdOlKmGpOuXk+HOipIy7sg==

karma-spec-reporter@~0.0.32:
version "0.0.33"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from tensorflow.python.eager import def_function
from tensorflow.python.framework import constant_op
from tensorflow.python.ops import variables
from tensorflow.python.training.tracking import tracking
from tensorflow.python.trackable import autotrackable

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from tensorflow.python.framework import dtypes
from tensorflow.python.framework import tensor_spec
from tensorflow.python.ops import variables
from tensorflow.python.training.tracking import tracking
from tensorflow.python.trackable import autotrackable
from tensorflow.python.tools import freeze_graph
from tensorflow.python.saved_model.save import save
import tensorflow_hub as hub
Expand Down Expand Up @@ -190,7 +190,7 @@ def conv2d_addV2_depthwise_addV2(x):
input=res, filter=filter, strides=[1, 1, 1, 1], padding="VALID")
res = tf.raw_ops.AddV2(x=res, y=bias)
return res
root = tracking.AutoTrackable()
root = autotrackable.AutoTrackable()
root.f = conv2d_addV2_depthwise_addV2
to_save = root.f.get_concrete_function(
tensor_spec.TensorSpec([1, 1, 1, 1], dtypes.float32))
Expand All @@ -207,7 +207,7 @@ def addV2_conv2d(x):
res = tf.raw_ops.Conv2D(
input=res, filter=filter, strides=[1, 1, 1, 1], padding="VALID")
return res
root = tracking.AutoTrackable()
root = autotrackable.AutoTrackable()
root.f = addV2_conv2d
to_save = root.f.get_concrete_function(
tensor_spec.TensorSpec([1, 1, 1, 1], dtypes.float32))
Expand Down Expand Up @@ -247,7 +247,7 @@ def _create_saved_model_with_unfusable_prelu(self):
def _create_saved_model(self):
"""Test a basic model with functions to make sure functions are inlined."""
input_data = constant_op.constant(1., shape=[1])
root = tracking.AutoTrackable()
root = autotrackable.AutoTrackable()
root.v1 = variables.Variable(3.)
root.v2 = variables.Variable(2.)
root.f = def_function.function(lambda x: root.v1 * root.v2 * x)
Expand All @@ -260,7 +260,7 @@ def _create_saved_model_with_fusable_matmul(self):
"""Test a fusable matmul model."""
input_data = constant_op.constant(1., shape=[1, 1])
bias_data = constant_op.constant(1., shape=[1])
root = tracking.AutoTrackable()
root = autotrackable.AutoTrackable()
root.v2 = variables.Variable([[2.]])
root.f = def_function.function(
lambda x: tf.nn.relu(tf.nn.bias_add(tf.matmul(x, root.v2),
Expand All @@ -278,7 +278,7 @@ def find_next_odd(v):
while tf.equal(v1 % 2, 0):
v1 = v1 + 1
return v1
root = tracking.AutoTrackable()
root = autotrackable.AutoTrackable()
root.f = find_next_odd
to_save = root.f.get_concrete_function(
tensor_spec.TensorSpec([], dtypes.int32))
Expand All @@ -303,7 +303,7 @@ def _create_saved_model_with_tfdf(self):
model.save(save_dir)

def _create_unsupported_saved_model(self):
root = tracking.AutoTrackable()
root = autotrackable.AutoTrackable()
root.w = variables.Variable(tf.random.uniform([2, 2]))

@def_function.function
Expand All @@ -322,7 +322,7 @@ def exported_function(x):
save(root, save_dir, to_save)

def _create_saved_model_with_debug_ops(self):
root = tracking.AutoTrackable()
root = autotrackable.AutoTrackable()
root.w = variables.Variable(tf.random.uniform([2, 2]))

@def_function.function
Expand Down
4 changes: 2 additions & 2 deletions tfjs-converter/python/tensorflowjs/converters/wizard_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import tensorflow.compat.v2 as tf
from tensorflow.python.eager import def_function
from tensorflow.python.ops import variables
from tensorflow.python.training.tracking import tracking
from tensorflow.python.trackable import autotrackable
from tensorflow.python.saved_model import save

from tensorflowjs.converters import wizard
Expand Down Expand Up @@ -74,7 +74,7 @@ def _create_keras_saved_model(self):
def _create_saved_model(self):
"""Test a basic model with functions to make sure functions are inlined."""
input_data = tf.constant(1., shape=[1])
root = tracking.AutoTrackable()
root = autotrackable.AutoTrackable()
root.v1 = variables.Variable(3.)
root.v2 = variables.Variable(2.)
root.f = def_function.function(lambda x: root.v1 * root.v2 * x)
Expand Down
4 changes: 2 additions & 2 deletions tfjs-converter/python/test_pip_package.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from tensorflow.python.framework import constant_op
from tensorflow.python.ops import variables
from tensorflow.python.tools import freeze_graph
from tensorflow.python.training.tracking import tracking
from tensorflow.python.trackable import autotrackable
from tensorflow.python.saved_model.save import save
import tensorflow_hub as hub

Expand Down Expand Up @@ -115,7 +115,7 @@ def _createTensorFlowSavedModel(save_path):
"""

input_data = constant_op.constant(1., shape=[1])
root = tracking.AutoTrackable()
root = autotrackable.AutoTrackable()
root.v1 = variables.Variable(3.)
root.v2 = variables.Variable(2.)
root.f = def_function.function(lambda x: root.v1 * root.v2 * x)
Expand Down
4 changes: 2 additions & 2 deletions tfjs-node/python/int64_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@
from tensorflow.python.framework import constant_op
from tensorflow.python.framework import dtypes
from tensorflow.python.ops import variables
from tensorflow.python.training.tracking import tracking
from tensorflow.python.trackable import autotrackable
from tensorflow.python.saved_model.save import save

"""Test a basic model with functions to make sure functions are inlined."""
input_data = constant_op.constant(1, shape=[2], dtype=tf.int64)
root = tracking.AutoTrackable()
root = autotrackable.AutoTrackable()
root.v1 = variables.Variable(3, dtype=tf.int64)
root.v2 = variables.Variable(2, dtype=tf.int64)
root.f = def_function.function(lambda x: root.v1 * root.v2 * x)
Expand Down
4 changes: 2 additions & 2 deletions tfjs-node/python/unint8_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
from tensorflow.python.eager import def_function
from tensorflow.python.framework import constant_op
from tensorflow.python.ops import variables
from tensorflow.python.training.tracking import tracking
from tensorflow.python.trackable import autotrackable
from tensorflow.python.saved_model.save import save

"""Test a basic model with functions to make sure functions are inlined."""
input_data = constant_op.constant(1, shape=[1], dtype=tf.uint8)
root = tracking.AutoTrackable()
root = autotrackable.AutoTrackable()
root.v1 = variables.Variable(3)
root.v2 = variables.Variable(2)
root.f = def_function.function(lambda x: root.v1 * root.v2 * tf.cast(x, tf.int32))
Expand Down

0 comments on commit 89a0b8f

Please sign in to comment.