@@ -373,6 +373,7 @@ def __init__(
373
373
return_none : bool ,
374
374
output_keys ,
375
375
maker : "FunctionMaker" ,
376
+ trust_input : bool = False ,
376
377
name : str | None = None ,
377
378
):
378
379
"""
@@ -407,6 +408,12 @@ def __init__(
407
408
TODO
408
409
maker
409
410
The `FunctionMaker` that created this instance.
411
+ trust_input : bool, default False
412
+ If True, no input validation checks are performed when the function is
413
+ called. This includes checking the number of inputs, their types and
414
+ that multiple inputs are not aliased to each other. Failure to meet any
415
+ of these conditions can lead to computational errors or to the
416
+ interpreter crashing.
410
417
name
411
418
A string name.
412
419
"""
@@ -420,7 +427,7 @@ def __init__(
420
427
self .return_none = return_none
421
428
self .maker = maker
422
429
self .profile = None # reassigned in FunctionMaker.create
423
- self .trust_input = False # If True, we don't check the input parameter
430
+ self .trust_input = trust_input # If True, we don't check the input parameter
424
431
self .name = name
425
432
self .nodes_with_inner_function = []
426
433
self .output_keys = output_keys
@@ -1341,7 +1348,12 @@ class FunctionMaker:
1341
1348
name : str
1342
1349
An optional name for this function. If used, the profile mode will
1343
1350
print the time spent in this function.
1344
-
1351
+ trust_input : bool, default False
1352
+ If True, no input validation checks are performed when the function is
1353
+ called. This includes checking the number of inputs, their types and
1354
+ that multiple inputs are not aliased to each other. Failure to meet any
1355
+ of these conditions can lead to computational errors or to the
1356
+ interpreter crashing.
1345
1357
"""
1346
1358
1347
1359
@staticmethod
@@ -1507,6 +1519,7 @@ def __init__(
1507
1519
output_keys = None ,
1508
1520
name = None ,
1509
1521
no_fgraph_prep = False ,
1522
+ trust_input = False ,
1510
1523
):
1511
1524
# Save the provided mode, not the instantiated mode.
1512
1525
# The instantiated mode don't pickle and if we unpickle an PyTensor
@@ -1609,6 +1622,7 @@ def __init__(
1609
1622
self .on_unused_input = on_unused_input # Used for the pickling/copy
1610
1623
self .output_keys = output_keys
1611
1624
self .name = name
1625
+ self .trust_input = trust_input
1612
1626
1613
1627
self .required = [(i .value is None ) for i in self .inputs ]
1614
1628
self .refeed = [
@@ -1726,6 +1740,7 @@ def create(self, input_storage=None, storage_map=None):
1726
1740
self .return_none ,
1727
1741
self .output_keys ,
1728
1742
self ,
1743
+ trust_input = self .trust_input ,
1729
1744
name = self .name ,
1730
1745
)
1731
1746
@@ -1743,6 +1758,7 @@ def orig_function(
1743
1758
on_unused_input = None ,
1744
1759
output_keys = None ,
1745
1760
fgraph : FunctionGraph | None = None ,
1761
+ trust_input : bool = False ,
1746
1762
) -> Function :
1747
1763
"""
1748
1764
Return a Function that will calculate the outputs from the inputs.
@@ -1773,7 +1789,12 @@ def orig_function(
1773
1789
fgraph
1774
1790
An existing `FunctionGraph` to use instead of constructing a new one
1775
1791
from cloned `outputs`.
1776
-
1792
+ trust_input : bool, default False
1793
+ If True, no input validation checks are performed when the function is
1794
+ called. This includes checking the number of inputs, their types and
1795
+ that multiple inputs are not aliased to each other. Failure to meet any
1796
+ of these conditions can lead to computational errors or to the
1797
+ interpreter crashing.
1777
1798
"""
1778
1799
1779
1800
if profile :
@@ -1806,6 +1827,7 @@ def orig_function(
1806
1827
output_keys = output_keys ,
1807
1828
name = name ,
1808
1829
fgraph = fgraph ,
1830
+ trust_input = trust_input ,
1809
1831
)
1810
1832
with config .change_flags (compute_test_value = "off" ):
1811
1833
fn = m .create (defaults )
0 commit comments