4#ifndef poplar_Program_hpp
5#define poplar_Program_hpp
10#include <poplar/DataStream.hpp>
11#include <poplar/DebugContext.hpp>
12#include <poplar/GraphElements.hpp>
13#include <poplar/OptionFlags.hpp>
14#include <poplar/StringRef.hpp>
15#include <poplar/SyncType.hpp>
16#include <poplar/Tensor.hpp>
17#include <poplar/TypeTraits.hpp>
40 bool isEmpty()
const {
return impl.get() ==
nullptr; }
43 core::ProgramImpl &getImpl() {
return *impl; }
44 const core::ProgramImpl &getImpl()
const {
return *impl; }
49 std::unique_ptr<core::ProgramImpl> impl;
78 template <
class... T>
void add_many(
const Program &first, T &&...rest) {
108 for (
const auto &p : programs) {
230 const bool unreachableDefault,
const DebugContext &debugContext = {});
239 const std::vector<std::pair<std::int32_t, Program>> &cases,
247 const std::vector<std::pair<std::int32_t, Program>> &cases,
271 const std::vector<std::pair<std::int32_t, Program>> &cases,
285 Tensor offset,
size_t repeats,
bool optimiseMemory,
288 Tensor offset,
size_t repeats,
bool optimiseMemory,
470 std::map<unsigned, unsigned> replicaMap,
598class PrintTensor :
public Program {
613 PrintTensor(StringRef title, Tensor t,
const DebugContext &debugContext = {});
616class ErrorProgram :
public Program {
626 ErrorProgram(StringRef message, Tensor debugTensor,
627 const DebugContext &debugContext = {});
630class Abort :
public Program {
636 Abort(
const DebugContext &debugContext = {});
643 Abort(
const std::string &message,
const DebugContext &debugContext = {});
646class AbortOnCondition :
public Program {
653 AbortOnCondition(Tensor predicate,
const DebugContext &debugContext = {});
662 AbortOnCondition(Tensor predicate,
const std::string &message,
663 const DebugContext &debugContext = {});
669void dumpProgram(
const Graph &graph,
const Program &program, std::ostream &out);
A reference to a compute set within a graph.
Definition: GraphElements.hpp:131
An object representing a stream for communicating between the host and the device.
Definition: DataStream.hpp:26
DebugContext gathers the common external parameters of the context of an operation.
Definition: DebugContext.hpp:221
A reference to a function buffer stored within a graph.
Definition: GraphElements.hpp:164
A reference to a function stored within a graph.
Definition: GraphElements.hpp:148
A reference to a function in the host.
Definition: GraphElements.hpp:179
A set of option/value string flags to be used in various APIs.
Definition: OptionFlags.hpp:24
A remote buffer is a region of remote (meaning not on the IPU) memory that is used as a cache.
Definition: DataStream.hpp:55
A reference to a subset of tensor elements.
Definition: Tensor.hpp:38
A program to mark a tensor as equal across replicas.
Definition: Program.hpp:551
A program to scope another program.
Definition: Program.hpp:560
A program to perform a function call to a previously stored program.
Definition: Program.hpp:578
Call(HostFunction f, ArrayRef< Tensor > inputs, ArrayRef< Tensor > outputs, const DebugContext &debugContext={})
Call a function in the host.
Call(Function f, const DebugContext &debugContext={})
Call the function.
A program that copies data.
Definition: Program.hpp:283
Copy(Tensor src, const RemoteBuffer &buffer, const DebugContext &debugContext={})
Construct a program to copy a tensor to a remote buffer.
Copy(const RemoteBuffer &buffer, Tensor dst, Tensor offset, const DebugContext &debugContext={})
Construct a program to copy a remote buffer to a tensor.
Copy(const FunctionBuffer &buffer, const Function &function, const DebugContext &debugContext={})
Construct a program to copy the contents of a FunctionBuffer to a Function.
Copy(Tensor src, const DataStream &stream, bool optimiseMemory=false, const DebugContext &debugContext={})
Construct a program to copy a tensor to a data stream.
Copy(Tensor src, const RemoteBuffer &buffer, Tensor offset, const DebugContext &debugContext={})
Construct a program to copy a tensor to a remote buffer.
Copy(const DataStream &stream, Tensor dst, bool optimiseMemory=false, const DebugContext &debugContext={})
Construct a program to copy from a data stream to a tensor.
Copy(Tensor src, Tensor dst, bool dontOutline=false, const DebugContext &debugContext={})
Construct a program to copy data from one tensor to another.
Copy(const RemoteBuffer &buffer, Tensor dst, const DebugContext &debugContext={})
Construct a program to copy a remote buffer to a tensor.
A program that copies tensors between replicated sub-graphs.
Definition: Program.hpp:446
CrossReplicaCopy(Tensor src, Tensor dst, std::map< unsigned, unsigned > replicaMap, const DebugContext &debugContext={})
Constructor to create a program to copy a tensor to the equivalent tensor in a different replica sub-...
Program that executes a compute set in the graph.
Definition: Program.hpp:56
Execute(ComputeSet cs, Tensor t, const DebugContext &debugContext={})
Construct a graph execution program and write the exit status to a scalar tensor.
Execute(ComputeSet cs, const DebugContext &debugContext={})
Construct a graph execution program.
A program that runs one of two programs depending on the value of a scalar tensor.
Definition: Program.hpp:200
If(Tensor predicate, const Program &trueBody, const Program &falseBody, const DebugContext &debugContext={})
A program that executes trueBody or falseBody depending on the value of predicate.
A program that executes for an indefinite number of iterations.
Definition: Program.hpp:189
Loop(const Program &prog, const DebugContext &debugContext={})
Construct a program which repeats indefinitely.
This class represents a control program that executes operations on the graph.
Definition: Program.hpp:30
A program that executes a program repeatedly while a condition is false.
Definition: Program.hpp:144
RepeatWhileFalse(const Program &cond, Tensor predicate, const Program &body, const DebugContext &debugContext={})
Construct a repeat-while-false program.
A program that executes a program repeatedly while a condition is true.
Definition: Program.hpp:170
RepeatWhileTrue(const Program &cond, Tensor predicate, const Program &body, const DebugContext &debugContext={})
Construct a repeat-while-true program.
A program that repeatedly executes for a fixed number of iterations.
Definition: Program.hpp:124
Repeat(unsigned count, const Program &prog, const DebugContext &debugContext={})
Construct a repeat program.
Program that executes a sequence of programs.
Definition: Program.hpp:77
void add(const Program &p)
Add a program to the end of the sequence.
Sequence(const DebugContext &debugContext={})
Construct an empty execution sequence (with optional debug context).
Definition: Program.hpp:89
Sequence(std::initializer_list< Program > programs, const DebugContext &debugContext={})
Construct an execution sequence from a list of programs.
Definition: Program.hpp:105
A program that runs one of many programs depending on the value of a tensor.
Definition: Program.hpp:228
Switch(Tensor control, const DebugContext &debugContext={})
Construct a switch with no cases and an empty default case.
Switch(Tensor control, const std::vector< std::pair< std::int32_t, Program > > &cases, const DebugContext &debugContext={})
Construct a switch with the specified set of cases and an empty default case.
Switch(Tensor control, const Program &defaultCaseBody, const DebugContext &debugContext={})
Construct a switch with no cases and the specified default case.
Switch(Tensor control, const std::vector< std::pair< std::int32_t, Program > > &cases, const Program &defaultCaseBody, const DebugContext &debugContext={})
Construct a switch with the specified set of cases and default case.
static Switch switchWithBoundsChecking(Tensor control, const std::vector< std::pair< std::int32_t, Program > > &cases, const DebugContext &debugContext={})
A helper function that causes the default case to throw an error.
Switch & add(std::int32_t value, const Program &body)
Add a case with the specified case value and body.
static Switch switchWithUnreachableDefault(Tensor control, const DebugContext &debugContext={})
This function lets the compiler assume the default case is unreachable.
A program to synchronise at a certain granularity dictated by the SyncType.
Definition: Program.hpp:568
Sync(SyncType type, const DebugContext &debugContext={})
A program to mark a tensor as containing an undefined value.
Definition: Program.hpp:539
Poplar classes and functions.
Definition: ArrayRef.hpp:14
SyncType
An enumeration used to state what type of synchronisation a Sync program represents.
Definition: SyncType.hpp:13