Poplar and PopLibs
VarStructure.hpp
Go to the documentation of this file.
1// Copyright (c) 2019 Graphcore Ltd. All rights reserved.
8#ifndef poputil_VarStructure_hpp
9#define poputil_VarStructure_hpp
10
11#include <functional>
12#include <map>
13#include <unordered_set>
14#include <vector>
15
16#include <poplar/Graph.hpp>
17
18namespace poputil {
19
28 const poplar::Tensor &t);
29
35using GroupingInfo = std::pair<unsigned, unsigned>;
36
45std::vector<GroupingInfo> detectDimGroupings(const poplar::Graph &graph,
46 const poplar::Tensor &t);
47
78 const std::vector<std::size_t> &shape,
79 const std::vector<std::size_t> &nPartitions,
80 const poplar::DebugContext &debugContext = {});
81
99 const poplar::Tensor &t, const std::vector<std::size_t> &nPartitions,
100 const std::function<void(const std::vector<std::size_t> &i,
101 const poplar::Tensor &s)> &f);
102
103} // end namespace poputil
104
105#endif // poputil_VarStructure_hpp
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
Class representing device data types.
Definition: Type.hpp:42
General utility functions for building graphs.
Definition: GfloatExprUtil.hpp:23
std::pair< unsigned, unsigned > GroupingInfo
Grouped dimension info.
Definition: VarStructure.hpp:35
std::vector< GroupingInfo > detectDimGroupings(const poplar::Graph &graph, const poplar::Tensor &t)
Find all grouped dimensions from the innermost grouped dimension moving outwards, returning groupings...
unsigned detectInnermostGrouping(const poplar::Graph &graph, const poplar::Tensor &t)
Detect if the tensor t has a grouping in its innermost dimension.
void iterateTensorPartitions(const poplar::Tensor &t, const std::vector< std::size_t > &nPartitions, const std::function< void(const std::vector< std::size_t > &i, const poplar::Tensor &s)> &f)
Iterate a function over the partitions of a tensor.
poplar::Tensor createPartitionableTensor(poplar::Graph &graph, const poplar::Type &type, const std::vector< std::size_t > &shape, const std::vector< std::size_t > &nPartitions, const poplar::DebugContext &debugContext={})
Create a tensor with the given shape, so that when it is partitioned into slices according to the giv...