tff.framework.ComputationBuildingBlock
Stay organized with collections
Save and categorize content based on your preferences.
The abstract base class for abstractions in the TFF's internal language.
Inherits From: TypedObject
tff.framework.ComputationBuildingBlock(
type_spec
)
Instances of this class correspond roughly one-to-one to the abstractions
defined in the Computation
message in TFF's computation.proto
, and are
intended primarily for the ease of manipulating the abstract syntax trees
(AST) of federated computations as they are transformed by TFF's compiler
pipeline to mold into the needs of a particular execution backend. The only
abstraction that does not have a dedicated Python equivalent is a section
of TensorFlow code (it's represented by tff.framework.CompiledComputation
).
Args |
type_spec
|
An instance of types.Type, or something convertible to it via
types.to_type().
|
Attributes |
proto
|
Returns a serialized form of this object as a pb.Computation instance.
|
type_signature
|
Returns the TFF type of this object (an instance of tff.Type ).
|
Methods
children
View source
@abc.abstractmethod
children() -> Iterator['ComputationBuildingBlock']
Returns an iterator yielding immediate child building blocks.
compact_representation
View source
compact_representation()
Returns the compact string representation of this building block.
View source
formatted_representation()
Returns the formatted string representation of this building block.
from_proto
View source
@classmethod
from_proto(
computation_proto: pb.Computation
) -> 'ComputationBuildingBlock'
Returns an instance of a derived class based on 'computation_proto'.
Args |
computation_proto
|
An instance of pb.Computation.
|
Returns |
An instance of a class that implements 'ComputationBuildingBlock' and
that contains the deserialized logic from in 'computation_proto'.
|
Raises |
NotImplementedError
|
if computation_proto contains a kind of computation
for which deserialization has not been implemented yet.
|
ValueError
|
if deserialization failed due to the argument being invalid.
|
structural_representation
View source
structural_representation()
Returns the structural string representation of this building block.
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 2024-09-20 UTC.
[null,null,["Last updated 2024-09-20 UTC."],[],[],null,["# tff.framework.ComputationBuildingBlock\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/federated/blob/v0.87.0 Version 2.0, January 2004 Licensed under the Apache License, Version 2.0 (the) |\n\nThe abstract base class for abstractions in the TFF's internal language.\n\nInherits From: [`TypedObject`](../../tff/TypedObject) \n\n tff.framework.ComputationBuildingBlock(\n type_spec\n )\n\nInstances of this class correspond roughly one-to-one to the abstractions\ndefined in the `Computation` message in TFF's `computation.proto`, and are\nintended primarily for the ease of manipulating the abstract syntax trees\n(AST) of federated computations as they are transformed by TFF's compiler\npipeline to mold into the needs of a particular execution backend. The only\nabstraction that does not have a dedicated Python equivalent is a section\nof TensorFlow code (it's represented by [`tff.framework.CompiledComputation`](../../tff/framework/CompiledComputation)).\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-------------|--------------------------------------------------------------------------------|\n| `type_spec` | An instance of types.Type, or something convertible to it via types.to_type(). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|------------------|------------------------------------------------------------------------------------------|\n| `proto` | Returns a serialized form of this object as a pb.Computation instance. |\n| `type_signature` | Returns the TFF type of this object (an instance of [`tff.Type`](../../tff/types/Type)). |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `children`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n @abc.abstractmethod\n children() -\u003e Iterator['ComputationBuildingBlock']\n\nReturns an iterator yielding immediate child building blocks.\n\n### `compact_representation`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n compact_representation()\n\nReturns the compact string representation of this building block.\n\n### `formatted_representation`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n formatted_representation()\n\nReturns the formatted string representation of this building block.\n\n### `from_proto`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n @classmethod\n from_proto(\n computation_proto: pb.Computation\n ) -\u003e 'ComputationBuildingBlock'\n\nReturns an instance of a derived class based on 'computation_proto'.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|---------------------|--------------------------------|\n| `computation_proto` | An instance of pb.Computation. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---|---|\n| An instance of a class that implements 'ComputationBuildingBlock' and that contains the deserialized logic from in 'computation_proto'. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ||\n|-----------------------|-------------------------------------------------------------------------------------------------------------|\n| `NotImplementedError` | if computation_proto contains a kind of computation for which deserialization has not been implemented yet. |\n| `ValueError` | if deserialization failed due to the argument being invalid. |\n\n\u003cbr /\u003e\n\n### `structural_representation`\n\n[View source](https://github.com/tensorflow/federated/blob/v0.87.0\nVersion 2.0, January 2004\nLicensed under the Apache License, Version 2.0 (the) \n\n structural_representation()\n\nReturns the structural string representation of this building block."]]