# tff.backends.mapreduce.MapReduceForm

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) 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) |

Standardized representation of logic deployable to MapReduce-like systems.

Inherits From: [`TypedObject`](https://www.tensorflow.org/federated/api_docs/python/tff/TypedObject)

    tff.backends.mapreduce.MapReduceForm(
        type_signature: https://www.tensorflow.org/federated/api_docs/python/tff/types/FunctionType,
        prepare: https://www.tensorflow.org/federated/api_docs/python/tff/framework/ConcreteComputation,
        work: https://www.tensorflow.org/federated/api_docs/python/tff/framework/ConcreteComputation,
        zero: https://www.tensorflow.org/federated/api_docs/python/tff/framework/ConcreteComputation,
        accumulate: https://www.tensorflow.org/federated/api_docs/python/tff/framework/ConcreteComputation,
        merge: https://www.tensorflow.org/federated/api_docs/python/tff/framework/ConcreteComputation,
        report: https://www.tensorflow.org/federated/api_docs/python/tff/framework/ConcreteComputation,
        secure_sum_bitwidth: https://www.tensorflow.org/federated/api_docs/python/tff/framework/ConcreteComputation,
        secure_sum_max_input: https://www.tensorflow.org/federated/api_docs/python/tff/framework/ConcreteComputation,
        secure_modular_sum_modulus: https://www.tensorflow.org/federated/api_docs/python/tff/framework/ConcreteComputation,
        update: https://www.tensorflow.org/federated/api_docs/python/tff/framework/ConcreteComputation
    )

This class docstring describes the purpose of `MapReduceForm` as a data
structure; for a discussion of the conceptual content of an instance `mrf` of
`MapReduceForm`, including how precisely it maps to a single federated round,
see the [package-level docstring](https://www.tensorflow.org/federated/api_docs/python/tff/backends/mapreduce).

This standardized representation can be used to describe a range of
computations representable as a single round of MapReduce-like processing, and
deployable to MapReduce-like systems that are only capable of executing plain
TensorFlow code.

Processes that do not originate at the server can be described by
`MapReduceForm`, as well as degenerate cases like computations which use
exclusively one of the two possible aggregation paths.

Instances of this class can be generated by TFF's transformation pipeline and
consumed by a variety of backends that have the ability to orchestrate their
execution in a MapReduce-like fashion. The latter can include systems that run
static data pipelines such Apache Beam or Hadoop, but also platforms like that
which has been described in the following paper:

"Towards Federated Learning at Scale: System Design"
<https://arxiv.org/pdf/1902.01046.pdf>

It should be noted that not every computation that proceeds in synchronous
rounds is representable as an instance of this class. In particular, this
representation is not suitable for computations that involve multiple phases
of processing, and does not generalize to arbitrary static data pipelines.
Generalized representations that can take advantage of the full expressiveness
of Apache Beam-like systems may emerge at a later time, and will be supported
by a separate set of tools, with a more expressive canonical representation.

The requirement that the variable constituents of the template be in the form
of pure TensorFlow code (not arbitrary TFF constructs) reflects the intent
for instances of this class to be easily converted into a representation that
can be compiled into a system that does *not* have the ability to interpret
the full TFF language (as defined in `computation.proto`), but that does have
the ability to run TensorFlow. Client-side logic in such systems could be
deployed in a number of ways, e.g., as shards in a MapReduce job, to mobile or
embedded devices, etc.

The individual TensorFlow computations that constitute a computation in this
form are supplied as constructor arguments. Generally, this class will note be
instantiated by a programmer directly but targeted by a sequence of
transformations that take a [`tff.Computation`](https://www.tensorflow.org/federated/api_docs/python/tff/Computation) and produce the appropriate
pieces of logic.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `type_signature` | The type signature of the corresponding [`tff.Computation`](https://www.tensorflow.org/federated/api_docs/python/tff/Computation) that is equivalent to the pieces of logic encoded in this data structure. |
| `prepare` | The computation that prepares the input for the clients. |
| `work` | The client-side work computation. |
| `zero` | The computation that produces the initial state for accumulators. |
| `accumulate` | The computation that adds a client update to an accumulator. |
| `merge` | The computation to use for merging pairs of accumulators. |
| `report` | The computation that produces the final server-side aggregate for the top level accumulator (the global update). |
| `secure_sum_bitwidth` | The computation that produces the bitwidth for bitwidth-based secure sums. |
| `secure_sum_max_input` | The computation that produces the maximum input for `max_input`-based secure sums. |
| `secure_modular_sum_modulus` | The computation that produces the modulus for secure modular sums. |
| `update` | The computation that takes the global update and the server state and produces the new server state, as well as server-side output. |

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `TypeError` | If the Python or TFF types of the arguments are invalid or not compatible with each other. |
| `AssertionError` | If the manner in which the given TensorFlow computations are represented by TFF does not match what this code is expecting (this is an internal error that requires code update). |

<br />

<br />

<br />

<br />

| ## Attributes ||
|---|---|
| `accumulate` | <br /> <br /> |
| `client_data_label` | <br /> <br /> |
| `merge` | <br /> <br /> |
| `prepare` | <br /> <br /> |
| `report` | <br /> <br /> |
| `secure_modular_sum_modulus` | <br /> <br /> |
| `secure_sum_bitwidth` | <br /> <br /> |
| `secure_sum_max_input` | <br /> <br /> |
| `securely_aggregates_tensors` | Whether the `MapReduceForm` uses secure aggregation. |
| `server_state_label` | <br /> <br /> |
| `type_signature` | Returns the TFF type of the equivalent [`tff.Computation`](https://www.tensorflow.org/federated/api_docs/python/tff/Computation). |
| `update` | <br /> <br /> |
| `work` | <br /> <br /> |
| `zero` | <br /> <br /> |

<br />

## Methods

### `summary`

[View source](https://github.com/tensorflow/federated/blob/v0.87.0
Version 2.0, January 2004
Licensed under the Apache License, Version 2.0 (the)

    summary(
        print_fn: Callable[..., None] = print
    ) -> None

Prints a string summary of the `MapReduceForm`.

<br />

<br />

<br />

| Args ||
|---|---|
| `print_fn` | Print function to use. It will be called on each line of the summary in order to capture the string summary. |

<br />