tfp.experimental.auto_batching.instructions.FunctionCallOp
Stay organized with collections
Save and categorize content based on your preferences.
Call a Function
.
tfp.experimental.auto_batching.instructions.FunctionCallOp(
function, vars_in, vars_out
)
This is a higher-level instruction, what in LLVM jargon is called an
"intrinsic". An upstream compiler may construct such instructions;
there is a pass that lowers these to sequences of instructions the
downstream VM can stage directly.
This differs from PrimOp
in that the function being called is
itself implemented in this instruction language, and is subject to
auto-batching by the downstream VM.
A FunctionCallOp
is required to statically know the identity of the
Function
being called. This is because we want to copy the return
values to their destinations at the caller side of the return
sequence. Why do we want that? Because threads may diverge at
function returns, thus needing to write the returned values to
different caller variables. Doing that on the callee side would
require per-thread information about where to write the variables,
which, in this design, is encoded in the program counter stack.
Why, in turn, may threads diverge at function returns? Because part
of the point is to allow them to converge when calling the same
function, even if from different points.
Args |
function
|
A Function object describing the function to call.
This requires all call targets to be known statically.
|
vars_in
|
list of strings. The names of the VM variables whose
current values to pass to the function .
|
vars_out
|
pattern of strings. The names of the VM variables
where to save the results returned from function .
|
Attributes |
function
|
A namedtuple alias for field number 0
|
vars_in
|
A namedtuple alias for field number 1
|
vars_out
|
A namedtuple alias for field number 2
|
Methods
replace
View source
replace(
vars_out=None
)
Return a copy of self
with vars_out
replaced.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-11-21 UTC.
[null,null,["Last updated 2023-11-21 UTC."],[],[],null,["# tfp.experimental.auto_batching.instructions.FunctionCallOp\n\n\u003cbr /\u003e\n\n|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/probability/blob/v0.23.0/tensorflow_probability/python/experimental/auto_batching/instructions.py#L490-L543) |\n\nCall a `Function`.\n\n#### View aliases\n\n\n**Main aliases**\n\n[`tfp.experimental.auto_batching.frontend.instructions.FunctionCallOp`](https://www.tensorflow.org/probability/api_docs/python/tfp/experimental/auto_batching/instructions/FunctionCallOp), [`tfp.experimental.auto_batching.frontend.st.inst.FunctionCallOp`](https://www.tensorflow.org/probability/api_docs/python/tfp/experimental/auto_batching/instructions/FunctionCallOp), [`tfp.experimental.auto_batching.frontend.stack.inst.FunctionCallOp`](https://www.tensorflow.org/probability/api_docs/python/tfp/experimental/auto_batching/instructions/FunctionCallOp), [`tfp.experimental.auto_batching.stack_optimization.inst.FunctionCallOp`](https://www.tensorflow.org/probability/api_docs/python/tfp/experimental/auto_batching/instructions/FunctionCallOp), [`tfp.experimental.auto_batching.stackless.inst.FunctionCallOp`](https://www.tensorflow.org/probability/api_docs/python/tfp/experimental/auto_batching/instructions/FunctionCallOp)\n\n\u003cbr /\u003e\n\n tfp.experimental.auto_batching.instructions.FunctionCallOp(\n function, vars_in, vars_out\n )\n\nThis is a higher-level instruction, what in LLVM jargon is called an\n\"intrinsic\". An upstream compiler may construct such instructions;\nthere is a pass that lowers these to sequences of instructions the\ndownstream VM can stage directly.\n\nThis differs from `PrimOp` in that the function being called is\nitself implemented in this instruction language, and is subject to\nauto-batching by the downstream VM.\n\nA `FunctionCallOp` is required to statically know the identity of the\n`Function` being called. This is because we want to copy the return\nvalues to their destinations at the caller side of the return\nsequence. Why do we want that? Because threads may diverge at\nfunction returns, thus needing to write the returned values to\ndifferent caller variables. Doing that on the callee side would\nrequire per-thread information about where to write the variables,\nwhich, in this design, is encoded in the program counter stack.\nWhy, in turn, may threads diverge at function returns? Because part\nof the point is to allow them to converge when calling the same\nfunction, even if from different points.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|------------|-------------------------------------------------------------------------------------------------------------|\n| `function` | A `Function` object describing the function to call. This requires all call targets to be known statically. |\n| `vars_in` | list of strings. The names of the VM variables whose current values to pass to the `function`. |\n| `vars_out` | pattern of strings. The names of the VM variables where to save the results returned from `function`. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|------------|-----------------------------------------|\n| `function` | A `namedtuple` alias for field number 0 |\n| `vars_in` | A `namedtuple` alias for field number 1 |\n| `vars_out` | A `namedtuple` alias for field number 2 |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `replace`\n\n[View source](https://github.com/tensorflow/probability/blob/v0.23.0/tensorflow_probability/python/experimental/auto_batching/instructions.py#L539-L543) \n\n replace(\n vars_out=None\n )\n\nReturn a copy of `self` with `vars_out` replaced."]]