6. IPU supported operations
Below is a list of currently supported operations that can be executed on IPU hardware. This list will be expanded over time as we add more support. Some overloads and modes of operation for ops are not supported and we’ve tried to list all the caveats but some may have been missed.
6.1. Torch operations
6.1.1. Tensor operations
Many of the tensor operations will be executed before even reaching the IPU
so we can consider them supported anyway. Some, like contiguous(), make
no sense on a distributed memory system like the IPU so are ignored. There
are no constraints on the memory format of how operations should be called
other than the constraint that all graph inputs should be contiguous.
We will also create tensor views. However, the aliasing property of views with respect to in-place operations should not be relied on as we may have slightly different view behaviour.
Additionally, some PyTorch operations may be implemented by composition of the listed ops but may not be explicitly listed but are in fact supported.
Creation ops
torch.arangetensor.filltorch.fulltorch.full_liketorch.Tensor.new_onestorch.Tensor.new_zerostorch.onestorch.ones_liketorch.zerostorch.zeros_like
Indexing, slicing, joining and mutating ops
In PyTorch, slicing a tensor is accessing a subset of the tensor by providing the start and end indices, such as tensor[1:5].
With a PopTorch model, you may take a slice of a tensor only if one of two conditions are met:
The start and end are constants, or can be resolved to be constants (for example, a function of the shape of a tensor which does not change between runs).
The start and end of the slice are related by a constant, for example
tensor[x:x+5]. Please note that this will produce different results to PyTorch if the end value exceeds the length of the tensor: PyTorch will output a smaller size tensor but PopTorch will allow the slice to wrap round to the start of the relevant dimension.
PyTorch functions
torch.bincounttorch.bucketizetorch.cattorch.chunktorch.gathertorch.index_selecttorch.index_reducetorch.reshapetorch.rolltorch.scattertorch.scatter_addtorch.scatter_reducetorch.stacktorch.splittorch.squeezetorch.ttorch.take_along_dimtorch.transposetorch.unbindtorch.unsqueezetorch.where
Tensor methods
tensor.expandtensor.expand_astensor.masked_filltensor.index_fill_
Random samplers
To set the random state, use poptorch.Options.randomSeed
torch.bernoullitorch.distributions.Bernoullitorch.randntorch.normaltorch.distributions.Normaltorch.randtorch.uniformtorch.distributions.Uniformtorch.exponentialtorch.distributions.Exponential
6.1.2. Math operations
Pointwise ops
torch.abstorch.acostorch.acoshtorch.addtorch.addcdivtorch.amaxtorch.amintorch.asintorch.asinhtorch.atantorch.atanhtorch.bitwise_andtorch.bitwise_nottorch.bitwise_ortorch.bitwise_xortorch.cdisttorch.ceiltorch.clamptorch.clamp_maxtorch.clamp_mintorch.costorch.coshtorch.divtorch.exptorch.expm1torch.floortorch.floor_dividetorch.fmodtorch.fractorch.logtorch.log10torch.log1ptorch.log2torch.logical_andtorch.logical_ortorch.multorch.normtorch.negtorch.powtorch.reciprocaltorch.remaindertorch.roundtorch.rsqrttorch.sigmoidtorch.signtorch.sintorch.sinhtorch.sqrttorch.squaretorch.subtorch.tantorch.tanhtorch.true_dividetorch.trunc
Reduction ops
torch.alltorch.anytorch.argmaxtorch.argmintorch.count_nonzerotorch.meantorch.mediantorch.prodtorch.logsumexptorch.stdtorch.std_meantorch.sumtorch.vartorch.var_mean
Comparison ops
torch.eqtorch.getorch.gttorch.letorch.lttorch.maxtorch.mintorch.netorch.isnantorch.topkThe option
sorted=Falseis not supported fortorch.topk.
torch.argsorttorch.randpermtorch.sort
torch.linalg ops
torch.linalg.norm2-norm and nuclear norm are unsupported for matrices.
torch.linalg.matrix_norm2-norm and nuclear norm are unsupported.
torch.linalg.vector_norm
Other ops
torch.cumsumtorch.cumprodtorch.crosstorch.meshgridtorch.cartesian_prodtorch.tensordot
BLAS and LAPACK Operations
torch.addmmtorch.matmultorch.bmm
6.2. Torch.nn operations
6.2.1. Containers
torch.nn.Module and torch.nn.Sequential can be passed into our
compiler wrappers and just work.
6.2.2. Convolution layers
Conv transpose operations do not yet support dilations.
torch.nn.Conv1dtorch.nn.Conv2dtorch.nn.Conv3dtorch.nn.ConvTranspose1dtorch.nn.ConvTranspose2dtorch.nn.ConvTranspose3d
6.2.3. Pooling layers
Currently the max pool layers do not return the indices
so only the variants with return_indices=False are supported.
torch.nn.MaxPool1dtorch.nn.MaxPool2dtorch.nn.MaxPool3dtorch.nn.AvgPool1dtorch.nn.AvgPool2dtorch.nn.AvgPool3dtorch.nn.AdaptiveAvgPool1dtorch.nn.AdaptiveAvgPool2dtorch.nn.AdaptiveAvgPool3d
6.2.4. Padding layers
All padding layers are supported.
torch.nn.ReflectionPad1dtorch.nn.ReflectionPad2dtorch.nn.ReplicationPad1dtorch.nn.ReplicationPad2dtorch.nn.ReplicationPad3dtorch.nn.ZeroPad2dtorch.nn.ConstantPad1dtorch.nn.ConstantPad2dtorch.nn.ConstantPad3d
6.2.5. Activations
torch.nn.ELUtorch.nn.CELUtorch.nn.GELUtorch.nn.Hardshrinktorch.nn.LeakyReLUtorch.nn.LogSoftmaxtorch.nn.Mishtorch.nn.ReLUtorch.nn.SELUtorch.nn.SiLUtorch.nn.Sigmoidtorch.nn.Softmaxtorch.nn.Softplustorch.nn.Softsigntorch.nn.Softshrinktorch.nn.Tanhtorch.nn.PReLUtorch.nn.RReLUtorch.nn.Hardtanhtorch.nn.functional.glutorch.nn.Threshold
6.2.6. Normalization layers
Currently only affine=True is supported as a parameter. That is to say, only the variants with trainable parameters are supported.
torch.nn.BatchNorm1dtorch.nn.BatchNorm2dtorch.nn.BatchNorm3dtorch.nn.LayerNormtorch.nn.GroupNormtorch.nn.InstanceNorm1dtorch.nn.InstanceNorm2dtorch.nn.InstanceNorm3dtorch.nn.utils.weight_norm
6.2.7. Recurrent layers
Bidirectional layers, non-zero dropout probabilities,
and setting num_layers to a value greater than 1
are not currently supported for any recurrent layer. In addition,
setting bias=False is currently only supported for torch.nn.GRU.
torch.nn.RNNtorch.nn.GRUtorch.nn.LSTM
6.2.8. Linear layers
torch.nn.Identitytorch.nn.Lineartorch.nn.Bilinear
6.2.9. Dropout
torch.nn.dropout
6.2.10. Sparse layers
Embedding and EmbeddingBag are supported with the exception of the padding_idx parameter
being unsupported.
torch.nn.Embeddingtorch.nn.EmbeddingBagtorch.nn.functional.one_hot
6.2.11. Loss functions
This version supports a limited subset of loss functions. However, we support
identity_loss() which gives you the ability to implement any arbitrary
loss function.
See also
One caveat for the following loss functions is if they are used they will always be included in the back propagation and will always receive a gradient, which is a slight deviation from normal PyTorch operations, where they have to opt in to the gradient pass.
torch.nn.L1Losstorch.nn.MSELosstorch.nn.CrossEntropyLosstorch.nn.NLLLosstorch.nn.BCELosstorch.nn.KLDivLosstorch.nn.PoissonNLLLosstorch.nn.HingeEmbeddingLosstorch.nn.BCEWithLogitsLosstorch.nn.SmoothL1Losstorch.nn.SoftMarginLosstorch.nn.CosineEmbeddingLosstorch.nn.MarginRankingLosstorch.nn.TripletMarginLosstorch.nn.CTCLoss
6.2.12. Vision Layers
Support nearest and bicubic mode.
torch.nn.Upsample
PyTorch Scatter functions
torch_scatter.scattertorch_scatter.composite.scatter_log_softmaxtorch_scatter.composite.scatter_softmaxtorch_scatter.composite.scatter_stdtorch_scatter.composite.scatter_logsumexp
PyTorch Spline Convolution functions
torch_spline_conv.spline_basistorch_spline_conv.spline_weighting
6.3. 16-bit float operations
Warning
Handling of float16 operations has been greatly simplified since PopTorch version 3.0. Please read this section
carefully if you are used to the way this worked prior to version 3.0.
In PopTorch version 3.0 and later, float16 operations are handled straightforwardly by the dispatcher frontend.
Tensors and models can be freely cast to and from float16, and normalization running
statistics can also be retyped by simple casting.
If you have PopTorch code created with a previous version of PopTorch, see Section 6.4, 16-bit float migration.
6.4. 16-bit float migration
Legacy PopTorch code using float16 can be updated for the dispatcher frontend by considering the following points:
Casts were not well supported by the tracing frontend. They are fully supported by the dispatcher frontend.
opts.Precision.halfFloatCasting()was used to switch between ways of resolving ops with bothfloat32andfloat16inputs (mixed-precision inputs), either by upcasting the inputs tofloat32, or by downcasting them tofloat16. This option is not supported under the dispatcher frontend: mixed precision ops are now always upcast tofloat32, in accordance with normal PyTorch behaviour. To recreate the effect ofopts.Precision.halfFloatCasting(poptorch.HalfFloatCastingBehavior.FloatDowncastToHalf), which was the default behaviour with the tracing frontend,float32inputs to mixed-precision ops should be explicitly cast tofloat16before being passed to the op.opts.Precision.runningStatisticsAlwaysFloat()was used to cause the running mean and variance of certain normalization ops to be calculated infloat32precision, even though the normalization module itself had been cast tofloat16. This option is not supported in the dispatcher frontend, as the same effect can be achieved by simply casting the running statistic tensors back tofloat32before running the model.
6.5. Gradient computation control
torch.no_grad is supported as a context manager as well as a decorator to suppress the
computation of gradients locally.