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

Add missing tf.function parameters #142

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5bfb831
adding two missing params
tatianacv Jan 24, 2023
0f84bb0
fix trailing whitespace
tatianacv Jan 24, 2023
8872d38
Merge remote-tracking branch 'upstream/main' into 139-missing-tffunct…
tatianacv Jan 26, 2023
fe4a4f0
Progress
tatianacv Jan 26, 2023
b13b3d2
Fix
tatianacv Jan 26, 2023
700d3bf
Merge branch 'main' into 139-missing-tffunction-parameters
tatianacv Jan 31, 2023
3ca358f
Maintaining the same format
tatianacv Feb 26, 2023
e659e93
Formatting, trailing whitespace
tatianacv Feb 26, 2023
3f284f1
Maintaining the same format
tatianacv Feb 26, 2023
f587254
Passing build
tatianacv Feb 27, 2023
35fd7a7
Merge branch 'main' into 139-missing-tffunction-parameters
khatchad Mar 4, 2023
52e25b8
Merge branch 'main' into 139-missing-tffunction-parameters
khatchad Mar 5, 2023
fee0cbc
Adding more information
tatianacv Mar 6, 2023
8f79e34
Adding more information
tatianacv Mar 6, 2023
2215e1f
Restructure sentence
tatianacv Mar 8, 2023
f4047bf
Restructure sentence
tatianacv Mar 8, 2023
cbfd513
Adding additional information to field description (link included)
tatianacv Mar 15, 2023
20b4418
Merge branch 'main' into 139-missing-tffunction-parameters
tatianacv Mar 15, 2023
ce615bb
Merge branch 'main' into 139-missing-tffunction-parameters
khatchad Mar 21, 2023
3ffd5a9
Adding specific URLs
tatianacv Mar 22, 2023
617cfb5
removing HTML
tatianacv Mar 22, 2023
c9a3be5
Merge branch 'main' into 139-missing-tffunction-parameters
khatchad Mar 28, 2023
98a669e
Merge branch 'main' into 139-missing-tffunction-parameters
tatianacv Mar 31, 2023
0d64c55
matching anchor with field name
tatianacv Mar 31, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,16 @@ public class HybridizationParameters {
*/
private boolean reduceRetracingParamExists;

/**
* True iff this {@link Function}'s {@link decoratorsType} has parameter experimental_compile.
*/
private boolean experimentalCompileParamExists;

/**
* True iff this {@link Function}'s {@link decoratorsType} has parameter experminetal_relax_shapes.
*/
private boolean experimentalRelaxShapesParamExists;

public HybridizationParameters(IProgressMonitor monitor) throws BadLocationException {
FunctionDefinition functionDefinition = Function.this.getFunctionDefinition();
decoratorsType[] decoratorArray = functionDefinition.getFunctionDef().decs;
Expand Down Expand Up @@ -139,16 +149,13 @@ else if (name.id.equals(INPUT_SIGNATURE))
else if (name.id.equals(AUTOGRAPH))
// Found parameter autograph
this.autoGraphParamExists = true;
// The version of the API we are using allows
// parameter names jit_compile and
// deprecated name experimental_compile
else if (name.id.equals(JIT_COMPILE) || name.id.equals(EXPERIMENTAL_COMPILE))
else if (name.id.equals(JIT_COMPILE))
// Found parameter jit_compile/experimental_compile
this.jitCompileParamExists = true;
// The version of the API we are using allows
// parameter names reduce_retracing
// and deprecated name experimental_relax_shapes
else if (name.id.equals(REDUCE_RETRACING) || name.id.equals(EXPERIMENTAL_RELAX_SHAPES))
tatianacv marked this conversation as resolved.
Show resolved Hide resolved
else if (name.id.equals(REDUCE_RETRACING))
// Found parameter reduce_retracing
// or experimental_relax_shapes
this.reduceRetracingParamExists = true;
Expand All @@ -161,6 +168,12 @@ else if (name.id.equals(EXPERIMENTAL_AUTOGRAPH_OPTIONS))
else if (name.id.equals(EXPERIMENTAL_FOLLOW_TYPE_HINTS))
// Found parameter experimental_follow_type_hints
this.experimentaFollowTypeHintsParamExists = true;
else if (name.id.equals(EXPERIMENTAL_COMPILE))
// Found parameter experimental_compile
this.experimentalCompileParamExists = true;
else if (name.id.equals(EXPERIMENTAL_RELAX_SHAPES))
// Found parameter experimental_relax_shapes
this.experimentalRelaxShapesParamExists = true;
}
}
} // else, tf.function is used without parameters.
Expand Down Expand Up @@ -237,6 +250,24 @@ public boolean hasJitCompileParam() {
public boolean hasReduceRetracingParam() {
return this.reduceRetracingParamExists;
}

/**
* True iff this {@link Function}'s {@link decoratorsType} has parameter experimental_compile.
*
* @return True iff this {@link Function} has parameter experimental_compile.
*/
public boolean hasExperimentalCompileParam() {
return this.experimentalCompileParamExists;
}

/**
* True iff this {@link Function}'s {@link decoratorsType} has parameter experimental_relax_shapes.
*
* @return True iff this {@link Function} has parameter experimental_relax_shapes.
*/
public boolean hasExperimentalRelaxShapesParam() {
return this.experimentalRelaxShapesParamExists;
}
}

private static final String TF_FUNCTION_FQN = "tensorflow.python.eager.def_function.function";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import custom
import tensorflow as tf


@custom.decorator(input_signature=None)
def func(x):
print('Tracing with', x)
return x
@tf.function
def test(x):
return x



if __name__ == '__main__':
func(1)
x = tf.constant(1)
test(x)

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tensorflow==2.9.3
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import custom
import tensorflow as tf


@custom.decorator(input_signature=None)
@tf.function(autograph=False)
def func():
pass
@tf.function(input_signature=(tf.TensorSpec(shape=[None], dtype=tf.float32),), autograph=False)
def func(x):
print('Tracing with', x)
return x


if __name__ == '__main__':
func()

number = tf.constant([1.0, 1.0])
func(number)
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import tensorflow as tf
import custom


@tf.function(autograph=False)
@tf.function(jit_compile=True)
@custom.decorator(input_signature=None)
def func(x):
print('Tracing with', x)
return x


if __name__ == '__main__':
func(tf.constant(1))

if __name__ == '__main__':
func(1)
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@
tensorflow==2.9.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import custom
import tensorflow as tf


@custom.decorator(input_signature=None)
@tf.function(autograph=False)
def func():
pass


if __name__ == '__main__':
func()
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tensorflow==2.9.3
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import tensorflow as tf


@tf.function(autograph=False)
@tf.function(jit_compile=True)
def func(x):
return x


if __name__ == '__main__':
func(tf.constant(1))
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tensorflow==2.9.3
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import tensorflow as tf


@tf.function
def test(x):
return x
@tf.function(experimental_compile=True)
def func():
print("Testing")


if __name__ == '__main__':
x = tf.constant(1)
test(x)

func()
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import tensorflow as tf


@tf.function(input_signature=(tf.TensorSpec(shape=[None], dtype=tf.float32),), autograph=False)
def func(x):
print('Tracing with', x)
return x
@tf.function(experimental_relax_shapes=True)
def func():
print("Testing")


if __name__ == '__main__':
number = tf.constant([1.0, 1.0])
func(number)

func()
Loading