Skip to content

Commit 96939c1

Browse files
committed
Update trust_input parameter documentation to clarify input validation behavior
1 parent 5e9b75b commit 96939c1

File tree

3 files changed

+30
-20
lines changed

3 files changed

+30
-20
lines changed

pytensor/compile/function/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,12 @@ def function(
165165
on_unused_input
166166
What to do if a variable in the 'inputs' list is not used in the graph.
167167
Possible values are 'raise', 'warn', 'ignore' and None.
168-
trust_input: bool
169-
If True, the inputs are trusted to be correct. This is used to avoid
170-
the overhead of checking the inputs for correctness. This should only
171-
be used if the inputs are guaranteed to be correct.
168+
trust_input: bool, default False
169+
If True, no input validation checks are performed when the function is
170+
called. This includes checking the number of inputs, their types and
171+
that multiple inputs are not aliased to each other. Failure to meet any
172+
of these conditions can lead to computational errors or to the
173+
interpreter crashing.
172174
173175
Returns
174176
-------

pytensor/compile/function/pfunc.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,10 +426,12 @@ def pfunc(
426426
fgraph
427427
An existing `FunctionGraph` from which to construct the returned
428428
`Function`. When this is non-``None``, nothing is cloned.
429-
trust_input : bool
430-
If True, the inputs are trusted to be correct. This is used to avoid
431-
the overhead of checking the inputs for correctness. This should only
432-
be used if the inputs are guaranteed to be correct.
429+
trust_input : bool, default False
430+
If True, no input validation checks are performed when the function is
431+
called. This includes checking the number of inputs, their types and
432+
that multiple inputs are not aliased to each other. Failure to meet any
433+
of these conditions can lead to computational errors or to the
434+
interpreter crashing.
433435
434436
Returns
435437
-------

pytensor/compile/function/types.py

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,12 @@ def __init__(
370370
TODO
371371
maker
372372
The `FunctionMaker` that created this instance.
373-
trust_input : bool
374-
If True, the inputs are trusted to be correct. This is used to avoid
375-
the overhead of checking the inputs for correctness. This should only
376-
be used if the inputs are guaranteed to be correct.
373+
trust_input : bool, default False
374+
If True, no input validation checks are performed when the function is
375+
called. This includes checking the number of inputs, their types and
376+
that multiple inputs are not aliased to each other. Failure to meet any
377+
of these conditions can lead to computational errors or to the
378+
interpreter crashing.
377379
name
378380
A string name.
379381
"""
@@ -1308,10 +1310,12 @@ class FunctionMaker:
13081310
name : str
13091311
An optional name for this function. If used, the profile mode will
13101312
print the time spent in this function.
1311-
trust_input : bool
1312-
If True, the inputs are trusted to be correct. This is used to avoid
1313-
the overhead of checking the inputs for correctness. This should only
1314-
be used if the inputs are guaranteed to be correct.
1313+
trust_input : bool, default False
1314+
If True, no input validation checks are performed when the function is
1315+
called. This includes checking the number of inputs, their types and
1316+
that multiple inputs are not aliased to each other. Failure to meet any
1317+
of these conditions can lead to computational errors or to the
1318+
interpreter crashing.
13151319
"""
13161320

13171321
@staticmethod
@@ -1747,10 +1751,12 @@ def orig_function(
17471751
fgraph
17481752
An existing `FunctionGraph` to use instead of constructing a new one
17491753
from cloned `outputs`.
1750-
trust_input : bool
1751-
If True, the inputs are trusted to be correct. This is used to avoid
1752-
the overhead of checking the inputs for correctness. This should only
1753-
be used if the inputs are guaranteed to be correct.
1754+
trust_input : bool, default False
1755+
If True, no input validation checks are performed when the function is
1756+
called. This includes checking the number of inputs, their types and
1757+
that multiple inputs are not aliased to each other. Failure to meet any
1758+
of these conditions can lead to computational errors or to the
1759+
interpreter crashing.
17541760
"""
17551761

17561762
if profile:

0 commit comments

Comments
 (0)