Poplar and PopLibs
Loop.hpp
Go to the documentation of this file.
1// Copyright (c) 2020 Graphcore Ltd. All rights reserved.
8#ifndef popops_Loop_hpp
9#define popops_Loop_hpp
10
11#include <poplar/Graph.hpp>
12#include <poplar/Program.hpp>
13#include <poputil/DebugInfo.hpp>
15
16namespace popops {
17
18using CountedLoopBodyType =
19 std::function<poplar::program::Program(const poplar::Tensor &)>;
20
42countedLoop(poplar::Graph &graph, std::size_t begin, std::size_t end,
43 size_t step, const CountedLoopBodyType &body,
44 const poplar::DebugContext &debugContext = {});
45
68countedLoop(poplar::Graph &graph, std::size_t count,
69 const CountedLoopBodyType &body,
70 const poplar::DebugContext &debugContext = {});
71
72poplar::Tensor addForLoopCounterVertex(poplar::Graph &graph,
73 const poplar::Tensor &count,
74 const poplar::Tensor &countLimit,
75 int countStep, unsigned tile,
77 const poplar::DebugContext &di);
78
109 int initialCount, const poplar::Tensor &countLimit,
110 int countStep, const poplar::program::Program &body,
111 const poplar::DebugContext &debugContext = {});
112
139countedForLoop(poplar::Graph &graph, int initialCount,
140 const poplar::Tensor &countLimit, int countStep,
141 const poplar::program::Program &body,
142 const poplar::DebugContext &debugContext = {});
143
144} // namespace popops
145
146#endif // popops_Loop_hpp
Poplibs generic debug info structure.
Generate a string describing a vertex type.
DebugContext gathers the common external parameters of the context of an operation.
Definition: DebugContext.hpp:221
This class represents a graph program to be executed on the IPU.
Definition: Graph.hpp:52
A reference to a subset of tensor elements.
Definition: Tensor.hpp:38
This class represents a control program that executes operations on the graph.
Definition: Program.hpp:30
Program that executes a sequence of programs.
Definition: Program.hpp:77
Common functions, such as elementwise and reductions.
Definition: AllTrue.hpp:15
poplar::program::Sequence countedLoop(poplar::Graph &graph, std::size_t begin, std::size_t end, size_t step, const CountedLoopBodyType &body, const poplar::DebugContext &debugContext={})
Create a loop program with constant initial count, increment and end value.
poplar::program::Sequence countedForLoop(poplar::Graph &graph, const poplar::Tensor &count, int initialCount, const poplar::Tensor &countLimit, int countStep, const poplar::program::Program &body, const poplar::DebugContext &debugContext={})
Create a for-loop program with constant initial count and increment, and a tensor as the end value.