├── .ci
└── view_component_trigger
│ ├── Jenkinsfile
│ └── jobs.groovy
├── .clang-format
├── .clang-tidy
├── .github
├── CODEOWNERS
└── workflows
│ └── apply_linters.yml
├── .gitignore
├── .linters
└── activate_buildenv.sh
├── .pre-commit-config.yaml
├── .pylintrc
├── .style.yapf
├── CMakeLists.txt
├── License.txt
├── MANIFEST.in
├── README.md
├── config.buildenv.py
├── docs
├── common
│ ├── _static
│ │ └── css
│ │ │ └── custom_rtd.css
│ ├── conf.py
│ ├── custom_dic
│ ├── graphcorelogo-html.png
│ └── graphcorelogo-pdf.png
├── poptorch_geometric
│ ├── common
│ │ └── conf.py
│ └── user_guide
│ │ ├── index.rst
│ │ ├── installation.rst
│ │ ├── intro.rst
│ │ ├── legal.rst
│ │ ├── performance.rst
│ │ ├── reference.rst
│ │ ├── supported_operations.rst
│ │ └── tutorials.rst
└── user_guide
│ ├── CMakeLists.txt
│ ├── IPU-pipeline.jpg
│ ├── api.py
│ ├── batching.rst
│ ├── buffers.py
│ ├── comm-group-types.png
│ ├── debugging.py
│ ├── debugging.rst
│ ├── device_iterations.py
│ ├── error_handling.py
│ ├── example.rst
│ ├── experimental.rst
│ ├── hostio_optimisation.rst
│ ├── index.rst
│ ├── inferenceModel.py
│ ├── installation.rst
│ ├── intro.rst
│ ├── legal.rst
│ ├── mnist.py
│ ├── no-buffering-profile.png
│ ├── overview.rst
│ ├── phased_execution.py
│ ├── pipeline_simple.py
│ ├── pipelined_execution.png
│ ├── poptorch.conf
│ ├── poptorch_training_simple.py
│ ├── precompilation.py
│ ├── pytorch-software-stack.png
│ ├── pytorch_to_poptorch.rst
│ ├── reference.rst
│ ├── replica_grouped_weights.py
│ ├── sharded_execution.png
│ ├── stages_summary.png
│ ├── sumAnchorReturnType.py
│ ├── supported_ops.rst
│ ├── trainingModel.py
│ ├── with-buffering-overlap-profile.png
│ └── with-buffering-profile.png
├── examples
├── CMakeLists.txt
├── bert_ipu.py
├── lstm.py
├── mnist.py
├── simple_adder.py
└── zeus.jpg
├── popart_compiler
├── CMakeLists.txt
├── include
│ └── popart_compiler
│ │ ├── CodeletsCompilation.hpp
│ │ ├── Compiler.hpp
│ │ ├── CompilerOperationMacros.inc.hpp
│ │ ├── ManuallyAddedOperations.inc.hpp
│ │ ├── SupportedOperations.inc.hpp
│ │ └── Utils.hpp
├── source
│ ├── CodeletsCompilation.cpp
│ ├── Compiler.cpp
│ ├── CompilerImpl.cpp
│ ├── SessionOptions.cpp
│ ├── Utils.cpp
│ ├── custom_operations
│ │ ├── Embedding.cpp
│ │ ├── FastGatherLastDim.cpp
│ │ ├── FastGatherLastDim.hpp
│ │ ├── FastGatherLastDimBwdCodelets.inc.cpp
│ │ ├── FastGatherLastDimFwdCodelets.inc.cpp
│ │ ├── HostOp.cpp
│ │ ├── TorchSoftplus.cpp
│ │ ├── TorchSoftplus.hpp
│ │ ├── UpsampleBilinear2d.cpp
│ │ └── UpsampleBilinear2dCodelets.inc.cpp
│ └── include
│ │ └── popart_compiler
│ │ ├── CompilerImpl.hpp
│ │ ├── CompilerOptions.hpp
│ │ ├── CustomOps.hpp
│ │ ├── MultiConvBuilder.hpp
│ │ └── SessionOptionsImpl.hpp
└── types
│ └── include
│ └── popart_compiler
│ ├── CompilerTypes.hpp
│ └── PopartEnums.hpp
├── poptorch
├── CMakeLists.txt
├── include
│ └── poptorch
│ │ ├── DispatchTracer.hpp
│ │ ├── InplaceOps.hpp
│ │ ├── LowerToPopart.hpp
│ │ ├── LowerToPopartFactories.hpp
│ │ ├── PoplarExecutable.hpp
│ │ ├── SessionOptionsParser.hpp
│ │ └── Utils.hpp
└── source
│ ├── AddDetachOperations.cpp
│ ├── AddSubgraphConnectionNodes.cpp
│ ├── AliasProcessing.cpp
│ ├── CPUOffloadingCleanUp.cpp
│ ├── CompilerOps.cpp.inc
│ ├── ErrorOnUnsupportedAten.cpp
│ ├── FixupSetAvailableMemory.cpp
│ ├── GNNOptimizations.cpp
│ ├── GatherWithExpandedIndicesOptimization.cpp
│ ├── ImplicitCasting.cpp
│ ├── InplaceOps.cpp
│ ├── LowerToPopart.cpp
│ ├── LowerToPopartFactories.cpp
│ ├── OpBuilder.cpp
│ ├── OverlappedIO.cpp
│ ├── PopartCanonicalization.cpp
│ ├── PopartLateCanonicalization.cpp
│ ├── PoplarExecutable.cpp
│ ├── PoptorchStaticInit.hpp
│ ├── PoptorchSymbols.cpp
│ ├── PoptorchSymbols.hpp
│ ├── RemoveSurplusIdentityLosses.cpp
│ ├── RequiresGrad.cpp
│ ├── SessionOptionsParser.cpp
│ ├── Utils.cpp
│ ├── dispatch_tracer
│ ├── CMakeLists.txt
│ ├── CommonHelperFunctions.cpp
│ ├── CommonHelperFunctions.hpp
│ ├── InplaceAliasMapper.cpp
│ ├── InplaceAliasMapper.hpp
│ ├── README.md
│ ├── RegisterAtenOverloads.cpp
│ ├── RegisterMetaOps.cpp.inc
│ ├── RegisterOptionalAtenOps.cpp.inc
│ ├── Tensor.cpp
│ ├── Tensor.hpp
│ ├── TypeInferenceHandler.cpp
│ ├── TypeInferenceHandler.hpp
│ ├── ValueMapper.cpp
│ ├── ValueMapper.hpp
│ └── dispatchers
│ │ ├── IDispatch.cpp
│ │ ├── IDispatch.hpp
│ │ ├── JitDispatch.cpp
│ │ └── JitDispatch.hpp
│ ├── include
│ └── poptorch
│ │ ├── AliasProcessing.hpp
│ │ ├── CompilerOps.inc.hpp
│ │ ├── ImplicitCasting.hpp
│ │ ├── InplaceOpsPyTorch.hpp_nolint
│ │ ├── OpBuilder.hpp
│ │ ├── OverlappedIO.hpp
│ │ ├── PopartCanonicalization.hpp
│ │ ├── RequiresGrad.hpp
│ │ └── TypeAndConstantCanonicalization.hpp
│ ├── popart_canonicalization
│ ├── ActivationOps.cpp
│ ├── ArithmeticOps.cpp
│ ├── AtenHandlers.gen.cpp
│ ├── BilinearOps.cpp
│ ├── BitwiseOps.cpp
│ ├── BlasOps.cpp
│ ├── ConstantOps.cpp
│ ├── ConvolutionOps.cpp
│ ├── CustomOps.cpp
│ ├── DistanceOps.cpp
│ ├── DropoutOps.cpp
│ ├── EinsumOp.cpp
│ ├── EinsumOp.hpp
│ ├── EmbeddingOps.cpp
│ ├── IndexOps.cpp
│ ├── LossOps.cpp
│ ├── NormalizationOps.cpp
│ ├── OtherOps.cpp
│ ├── PoolingOps.cpp
│ ├── PopartCanonicalizationUtils.cpp
│ ├── PopartCanonicalizationUtils.hpp
│ ├── PoptorchHandlers.gen.cpp
│ ├── PyGTorchScatterOps.cpp
│ ├── PyGTorchSplineConvOps.cpp
│ ├── RNNOps.cpp
│ ├── RandomSamplingOps.cpp
│ ├── ReduceOps.cpp
│ ├── ReshapeOps.cpp
│ ├── ScatterReduction.cpp
│ ├── ScatterReduction.hpp
│ ├── SliceOps.cpp
│ ├── SoftmaxOps.cpp
│ ├── TensorOps.cpp
│ └── pyg_torch_cluster
│ │ ├── FpsOp.cpp
│ │ ├── GridOp.cpp
│ │ └── NearestOp.cpp
│ └── type_and_constant_canonicalization
│ ├── AddListNumElements.cpp
│ ├── CanonicaliseConstants.cpp
│ ├── CastUnsupportedInputs.cpp
│ ├── CheckAndChangeOutputTypes.cpp
│ ├── EvaluateConstexprs.cpp
│ └── MakeConstantIntParams.cpp
├── poptorch_compiler
└── pytorch_bridge
│ ├── CMakeLists.txt
│ ├── IpuSession.cpp
│ └── include
│ └── pytorch_bridge
│ ├── CompilerOptions.hpp
│ ├── CompilerTypes.hpp
│ ├── DebugInfo.hpp
│ └── IpuSession.hpp
├── poptorch_err
├── CMakeLists.txt
├── exception_info
│ └── poptorch_err
│ │ └── ExceptionInfo.hpp
├── include
│ └── poptorch_err
│ │ └── ExceptionHandling.hpp
└── source
│ └── ExceptionHandling.cpp
├── poptorch_geometric
├── CMakeLists.txt
├── License.txt
├── MANIFEST.in
├── README.md
├── config.buildenv.py
├── poptorch_geometric_third_party_licenses.txt
├── pyproject.toml
├── python
│ ├── CMakeLists.txt
│ ├── __init__.py
│ ├── cluster_loader.py
│ ├── collate.py
│ ├── common.py
│ ├── dataloader.py
│ ├── fixed_size_options.py
│ ├── masker.py
│ ├── neighbor_loader.py
│ ├── ops
│ │ ├── __init__.py
│ │ ├── aggregation_base.py
│ │ ├── cluster_gcn_conv.py
│ │ ├── hetero_linear.py
│ │ ├── instance_norm.py
│ │ ├── knn.py
│ │ ├── knn_graph.py
│ │ ├── knn_interpolate.py
│ │ ├── mf_conv.py
│ │ └── radius.py
│ ├── override.py
│ ├── py.typed
│ ├── pyg_cluster_loader.py
│ ├── pyg_collate.py
│ ├── pyg_dataloader.py
│ ├── stream_packing_sampler.py
│ ├── types.py
│ └── utils.py
├── requirements.txt
├── setup.cfg
└── setup.py
├── poptorch_logging
├── CMakeLists.txt
├── include
│ └── poptorch_logging
│ │ ├── Error.hpp
│ │ ├── Logging.hpp
│ │ ├── LoggingLight.hpp
│ │ └── Tracepoint.hpp
└── source
│ ├── Error.cpp
│ ├── Logging.cpp
│ └── Tracepoint.cpp
├── poptorch_third_party_licenses.txt
├── pyproject.toml
├── python
├── CMakeLists.txt
├── __init__.py
├── _args_parser.py
├── _dataloader.py
├── _impl.py
├── _logging.py
├── _optimizer_attributes.py
├── _options_config.py
├── _options_impl.py
├── _poplar_executor.py
├── _poptorch_data.py
├── _printing.py
├── _utils.py
├── enums.py
├── ops.py
├── optim.py
├── options.py
├── poptorch.cpp
├── profiling.py
├── py.typed
└── testing.py
├── requirements.txt
├── scripts
├── PopAtenHandlers.py
├── PopParse.py
├── PopTorchHandlers.py
├── __init__.py
├── apply_linters.py
├── check_spelling.py
├── create_buildenv.py
├── docs_build.py
├── download_external_datasets.py
├── enable.sh.in
├── generate_poppyg_package.py
├── generate_python_package.py
├── popgen
│ ├── __init__.py
│ ├── api.py
│ ├── generator.py
│ ├── helpers.py
│ ├── onnx.py
│ ├── operatorfactory.py
│ ├── poptorch.py
│ ├── registry.py
│ ├── transform.py
│ └── values.py
├── set_version.py
└── utils
│ └── _utils.py
├── setup.cfg
├── setup.py
├── tests
├── .gitignore
├── CMakeLists.txt
├── activations_test.py
├── attach_detach_test.py
├── attach_detach_wait_for_ipu_test.py
├── batching_test.py
├── bert_small_and_medium_test.py
├── blas_test.py
├── bool_support_test.py
├── buffers_test.py
├── conftest.py
├── convs_test.py
├── cpp
│ ├── CMakeLists.txt
│ └── GNNOptimizationsTest.cpp
├── cpu_op_test.py
├── ctc_decoder_test.py
├── custom_loss_test.py
├── custom_ops
│ ├── CMakeLists.txt
│ ├── custom_add_scalar_op.cpp
│ ├── custom_add_scalar_vec_op.cpp
│ ├── custom_add_vec_scalar_mul_op.cpp
│ ├── custom_cube_op.cpp
│ ├── custom_leaky_relu_op.cpp
│ ├── custom_many_attribute_op.cpp
│ ├── custom_reduce_op.cpp
│ └── custom_three_input_reduce_op.cpp
├── custom_ops_attributes_test.py
├── custom_ops_test.py
├── dataloader_test.py
├── debug_tensors_test.py
├── distance_ops_test.py
├── exception_test.py
├── fine_tuning_test.py
├── functional_test.py
├── generate_test_file.py
├── gnn
│ ├── .gitignore
│ ├── benchgnn
│ │ ├── README.md
│ │ ├── benchgnn.py
│ │ ├── datasets.py
│ │ ├── models.py
│ │ ├── requirements.txt
│ │ └── utils.py
│ ├── benchgnn_ops
│ │ ├── README.md
│ │ ├── benchgnn_ops.py
│ │ ├── builder.py
│ │ ├── example_configs
│ │ │ ├── common.yaml
│ │ │ ├── scatter_testcase1.yaml
│ │ │ └── scatter_testcase2.yaml
│ │ ├── metrics.py
│ │ ├── ops.py
│ │ └── requirements.txt
│ ├── conftest.py
│ ├── nn
│ │ ├── aggr
│ │ │ ├── aggr_utils.py
│ │ │ ├── conftest.py
│ │ │ ├── test_attention.py
│ │ │ ├── test_basic.py
│ │ │ ├── test_deep_sets.py
│ │ │ ├── test_equilibrium.py
│ │ │ ├── test_fused.py
│ │ │ ├── test_gmt.py
│ │ │ ├── test_gru.py
│ │ │ ├── test_lstm.py
│ │ │ ├── test_mlp_aggr.py
│ │ │ ├── test_multi.py
│ │ │ ├── test_quantile.py
│ │ │ ├── test_scaler.py
│ │ │ ├── test_set2set.py
│ │ │ ├── test_set_transformer.py
│ │ │ └── test_sort.py
│ │ ├── conftest.py
│ │ ├── conv
│ │ │ ├── conv_utils.py
│ │ │ ├── test_agnn_conv.py
│ │ │ ├── test_antisymmetric_conv.py
│ │ │ ├── test_appnp.py
│ │ │ ├── test_arma_conv.py
│ │ │ ├── test_cg_conv.py
│ │ │ ├── test_cheb_conv.py
│ │ │ ├── test_cluster_gcn_conv.py
│ │ │ ├── test_dna_conv.py
│ │ │ ├── test_edge_conv.py
│ │ │ ├── test_eg_conv.py
│ │ │ ├── test_fa_conv.py
│ │ │ ├── test_feast_conv.py
│ │ │ ├── test_film_conv.py
│ │ │ ├── test_gat_conv.py
│ │ │ ├── test_gated_graph_conv.py
│ │ │ ├── test_gatv2_conv.py
│ │ │ ├── test_gcn2_conv.py
│ │ │ ├── test_gcn_conv.py
│ │ │ ├── test_gen_conv.py
│ │ │ ├── test_general_conv.py
│ │ │ ├── test_gin_conv.py
│ │ │ ├── test_gmm_conv.py
│ │ │ ├── test_gps_conv.py
│ │ │ ├── test_graph_conv.py
│ │ │ ├── test_gravnet_conv.py
│ │ │ ├── test_han_conv.py
│ │ │ ├── test_heat_conv.py
│ │ │ ├── test_hetero_conv.py
│ │ │ ├── test_hgt_conv.py
│ │ │ ├── test_hypergraph_conv.py
│ │ │ ├── test_le_conv.py
│ │ │ ├── test_lg_conv.py
│ │ │ ├── test_mf_conv.py
│ │ │ ├── test_nn_conv.py
│ │ │ ├── test_pan_conv.py
│ │ │ ├── test_pdn_conv.py
│ │ │ ├── test_pna_conv.py
│ │ │ ├── test_point_conv.py
│ │ │ ├── test_point_gnn_conv.py
│ │ │ ├── test_point_transformer_conv.py
│ │ │ ├── test_ppf_conv.py
│ │ │ ├── test_res_gated_graph_conv.py
│ │ │ ├── test_rgat_conv.py
│ │ │ ├── test_rgcn_conv.py
│ │ │ ├── test_sage_conv.py
│ │ │ ├── test_sg_conv.py
│ │ │ ├── test_signed_conv.py
│ │ │ ├── test_simple_conv.py
│ │ │ ├── test_spline_conv.py
│ │ │ ├── test_ssg_conv.py
│ │ │ ├── test_supergat_conv.py
│ │ │ ├── test_tag_conv.py
│ │ │ ├── test_transformer_conv.py
│ │ │ ├── test_wl_conv.py
│ │ │ ├── test_wl_conv_continuous.py
│ │ │ └── test_x_conv.py
│ │ ├── dense
│ │ │ ├── dense_utils.py
│ │ │ └── test_convs.py
│ │ ├── functional
│ │ │ ├── test_bro.py
│ │ │ └── test_gini.py
│ │ ├── kge
│ │ │ ├── kge_utils.py
│ │ │ ├── test_complex.py
│ │ │ ├── test_distmult.py
│ │ │ ├── test_rotate.py
│ │ │ └── test_transe.py
│ │ ├── nn_utils.py
│ │ ├── norm
│ │ │ ├── norm_utils.py
│ │ │ ├── test_batch_norm.py
│ │ │ ├── test_diff_group_norm.py
│ │ │ ├── test_graph_norm.py
│ │ │ ├── test_graph_size_norm.py
│ │ │ ├── test_instance_norm.py
│ │ │ ├── test_layer_norm.py
│ │ │ ├── test_mean_subtraction_norm.py
│ │ │ ├── test_msg_norm.py
│ │ │ └── test_pair_norm.py
│ │ ├── pool
│ │ │ ├── pool_utils.py
│ │ │ ├── test_asap.py
│ │ │ ├── test_avg_pool.py
│ │ │ ├── test_consecutive.py
│ │ │ ├── test_decimation.py
│ │ │ ├── test_edge_pool.py
│ │ │ ├── test_fps.py
│ │ │ ├── test_glob.py
│ │ │ ├── test_graclus.py
│ │ │ ├── test_max_pool.py
│ │ │ ├── test_mem_pool.py
│ │ │ ├── test_pan_pool.py
│ │ │ ├── test_pool_knn.py
│ │ │ ├── test_radius.py
│ │ │ ├── test_sag_pool.py
│ │ │ ├── test_select_topk.py
│ │ │ ├── test_topk_pool.py
│ │ │ └── test_voxel_grid.py
│ │ ├── test_linear.py
│ │ ├── test_loss.py
│ │ ├── test_mish.py
│ │ ├── test_sequential.py
│ │ └── unpool
│ │ │ └── test_interpolate.py
│ ├── ops
│ │ ├── test_knn.py
│ │ ├── test_knn_graph.py
│ │ ├── test_knn_interpolate.py
│ │ ├── test_nearest.py
│ │ ├── test_radius_op.py
│ │ ├── test_spline_conv_ops.py
│ │ └── test_to_dense_batch.py
│ ├── test_basic_gnn.py
│ ├── test_cluster_loader.py
│ ├── test_collate.py
│ ├── test_dataloader.py
│ ├── test_encoding.py
│ ├── test_fixed_size_options.py
│ ├── test_masker.py
│ ├── test_model_args.py
│ ├── test_neighbor_loader.py
│ ├── test_register_custom_args.py
│ ├── test_stream_packing_sampler.py
│ └── utils.py
├── grouping_scatters_gathers_test.py
├── gru_test.py
├── half_float_test.py
├── half_test.py
├── helpers.py
├── hooks_test.py
├── if_test.py
├── index_ops_test.py
├── inplace_test.py
├── inputs_test.py
├── io_performance_test.py
├── ipu_print_tensor_test.py
├── loop_test.py
├── losses_test.py
├── lstm_test.py
├── math_ops_test.py
├── misc_nn_layers_test.py
├── misc_test.py
├── multiconv_test.py
├── non_contiguous_tensors_test.py
├── norms_test.py
├── ops_test.py
├── optimizers_test.py
├── options_test.py
├── other_ops_test.py
├── outputs_test.py
├── overlapped_io_test.py
├── phased_execution_test.py
├── pipelining_test.py
├── pooling_and_padding_test.py
├── popdist_test.py
├── poplar_executor_test.py
├── precompilation_test.py
├── pyg_torch_scatter_test.py
├── random_sampling_test.py
├── reduce_ops_test.py
├── replicated_graph_test.py
├── requires_grad_test.py
├── rnn_test.py
├── sharding_test.py
├── slice_test.py
├── tensor_ops_test.py
├── test_doc_urls.py
├── test_perf_counters.py
├── timeout_handler.py
├── torch_nn_test.py
├── torchvision_inference_test.py
├── type_support_test.py
└── weights_writing_test.py
└── version.json
/.ci/view_component_trigger/Jenkinsfile:
--------------------------------------------------------------------------------
1 | @Library('sw-jenkins-library@view-component-trigger') _
2 |
3 | viewComponentTrigger(jobsFilepath: '.ci/view_component_trigger/jobs.groovy')
4 |
--------------------------------------------------------------------------------
/.ci/view_component_trigger/jobs.groovy:
--------------------------------------------------------------------------------
1 | [
2 | [
3 | job: '/poptorch/poptorch_pr',
4 | parameters: [
5 | string(name: 'GCCI_BRANCH', value: 'mk2-main')
6 | ]
7 | ],
8 | ]
9 |
--------------------------------------------------------------------------------
/.clang-format:
--------------------------------------------------------------------------------
1 | Language: Cpp
2 | BasedOnStyle: llvm
3 |
--------------------------------------------------------------------------------
/.clang-tidy:
--------------------------------------------------------------------------------
1 | Checks: '*, -abseil*, -altera*, -android*, -cppcoreguidelines*, -cert*, -modernize*, -boost*, -google*, -fuchsia*, -hicpp*, -objc*, -llvm*, -bugprone-exception-escape, -readability-uppercase-literal-suffix, -misc-non-private-member-variables-in-classes, -fuchsia-default-arguments-declarations, -fuchsia-default-arguments-calls, -readability-magic-numbers, -fuchsia-overloaded-operator, -performance-noexcept-move-constructor, -concurrency-mt-unsafe, -readability-function-cognitive-complexity, -misc-throw-by-value-catch-by-reference, -misc-no-recursion, -bugprone-narrowing-conversions, -bugprone-easily-swappable-parameters, -readability-make-member-function-const, -readability-use-anyofallof, -readability-identifier-length,-misc-confusable-identifiers,-bugprone-reserved-identifier,-misc-unused-using-decls'
2 | WarningsAsErrors: '*'
3 | HeaderFilterRegex: ''
4 | AnalyzeTemporaryDtors: false
5 | CheckOptions:
6 | - key: readability-identifier-naming.NamespaceCase
7 | value: lower_case
8 | - key: readability-identifier-naming.ClassCase
9 | value: CamelCase
10 | - key: readability-identifier-naming.StructCase
11 | value: CamelCase
12 | - key: readability-identifier-naming.PrivateMemberPrefix
13 | value: _
14 | - key: readability-identifier-naming.ProtectedMemberPrefix
15 | value: _
16 | - key: readability-identifier-naming.MemberCase
17 | value: lower_case
18 | - key: readability-identifier-naming.StructCase
19 | value: CamelCase
20 | - key: readability-identifier-naming.MethodCase
21 | value: camelBack
22 | - key: readability-identifier-naming.FunctionCase
23 | value: camelBack
24 | - key: readability-identifier-naming.VariableCase
25 | value: lower_case
26 | - key: misc-throw-by-value-catch-by-reference.MaxSize
27 | value: '8'
28 |
--------------------------------------------------------------------------------
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | * @Software-GCAI/poptorch
2 |
--------------------------------------------------------------------------------
/.github/workflows/apply_linters.yml:
--------------------------------------------------------------------------------
1 | name: apply_linters.py git trailer check
2 |
3 | on:
4 | push:
5 | branches: [mk2-main]
6 | pull_request:
7 | branches: [mk2-main]
8 |
9 | jobs:
10 | apply_linters:
11 | timeout-minutes: 10
12 | name: apply_linters.py git trailer check
13 | runs-on: [self-hosted, linux]
14 | steps:
15 | - uses: actions/checkout@v3
16 | with:
17 | # 0 indicates fetch history for all branches and tags.
18 | # By default the checkout action only checks out the PR
19 | # ref. However apply_linters.py needs run git commands
20 | # that reference origin/mk2-main.
21 | fetch-depth: 0
22 | # Checkout the head instead of the merge commit
23 | ref: ${{ github.event.pull_request.head.sha }}
24 | - name: Verify most recent commit's git trailer
25 | run: python scripts/apply_linters.py --check-trailer
26 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | build
2 | __pycache__
3 | .linters
4 | .cache
5 | .vscode
6 | test_data
7 |
--------------------------------------------------------------------------------
/.linters/activate_buildenv.sh:
--------------------------------------------------------------------------------
1 | ../../build/activate_buildenv.sh
--------------------------------------------------------------------------------
/.pre-commit-config.yaml:
--------------------------------------------------------------------------------
1 | repos:
2 | - repo: https://github.com/pre-commit/pre-commit-hooks
3 | rev: v2.3.0
4 | hooks:
5 | - id: check-yaml
6 | - id: end-of-file-fixer
7 | - id: check-merge-conflict
8 | - id: trailing-whitespace
9 | - repo: local
10 | hooks:
11 | - id: apply_linters
12 | name: apply_linters
13 | entry: scripts/apply_linters.py
14 | language: python
15 | args: [-a, --add-trailer-on-success, --debug, --git-strategy=pre-commit]
16 | additional_dependencies: [pyyaml==6.0.0, packaging==23.0.0, colorama==0.4.6]
17 | # For the git trailer to be correct apply_linters.py must be applied to all the files.
18 |
--------------------------------------------------------------------------------
/License.txt:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2020 Graphcore Limited
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 |
--------------------------------------------------------------------------------
/MANIFEST.in:
--------------------------------------------------------------------------------
1 | recursive-include include *.hpp
2 | include poptorch/lib/*
3 | include poptorch/lib/poplar_rt/*
4 | include poptorch/lib/graphcore/lib/*.a
5 | include *.py
6 | include *.toml
7 | include License.txt
8 | include poptorch_third_party_licenses.txt
9 |
--------------------------------------------------------------------------------
/docs/common/custom_dic:
--------------------------------------------------------------------------------
1 | accessor
2 | AdamW
3 | AMSGrad
4 | AsyncRebatched
5 | autograd
6 | backend
7 | booleans
8 | bwd
9 | checkpointed
10 | checkpointing
11 | codepaths
12 | config
13 | connectionist
14 | const
15 | constness
16 | CTC
17 | dict
18 | EOF
19 | float16
20 | float32
21 | FP16
22 | InputChannels
23 | ints
24 | IO
25 | ipu
26 | IPU
27 | IPUs
28 | iterable
29 | L2
30 | libpvti
31 | matmul
32 | Mk1
33 | Mk2
34 | mpirun
35 | Nesterov
36 | num
37 | OpenMPI
38 | OutputChannels
39 | PopART
40 | PopART's
41 | PopDist
42 | PopLibs
43 | PopRun
44 | PopTorch
45 | precompile
46 | pvti
47 | PyTorch
48 | PyTorch's
49 | rebatch
50 | rebatched
51 | rebatching
52 | recomputation
53 | ReducingDim
54 | replan
55 | RMSprop
56 | RTS
57 | serializable
58 | SGD
59 | sharded
60 | sharding
61 | stdout
62 | str
63 | submodules
64 | TODO
65 | tracepoint
66 | tracepoints
67 | tracepointsints
68 | unrounded
69 | unroundedPopRunsubmodules
70 | bool
71 |
--------------------------------------------------------------------------------
/docs/common/graphcorelogo-html.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/graphcore/poptorch/c2a8b17762f1d7106f7bf048ff011ab4fee7685e/docs/common/graphcorelogo-html.png
--------------------------------------------------------------------------------
/docs/common/graphcorelogo-pdf.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/graphcore/poptorch/c2a8b17762f1d7106f7bf048ff011ab4fee7685e/docs/common/graphcorelogo-pdf.png
--------------------------------------------------------------------------------
/docs/poptorch_geometric/user_guide/index.rst:
--------------------------------------------------------------------------------
1 | PyTorch Geometric for the IPU: User Guide
2 | =========================================
3 |
4 | .. toctree::
5 | :maxdepth: 4
6 | :numbered: 3
7 |
8 | intro
9 | installation
10 | performance
11 | tutorials
12 | supported_operations
13 | reference
14 | legal
15 |
--------------------------------------------------------------------------------
/docs/poptorch_geometric/user_guide/intro.rst:
--------------------------------------------------------------------------------
1 | ============
2 | Introduction
3 | ============
4 |
5 | .. admonition:: Experimental Release
6 |
7 | This is an experimental release of PopTorch Geometric. Not all features of PyTorch Geometric are supported, and some functions may not work as expected. The implementation may change without warning in future releases in ways that are not backwards compatible.
8 |
9 | PopTorch Geometric is a set of extensions for PyTorch Geometric, enabling Graph
10 | Neural Network models to be trained, evaluated and used on Graphcore IPU
11 | hardware.
12 |
13 | PopTorch Geometric has been designed to require as few changes as possible to
14 | your models to run on the IPU.
15 | However, it does have some differences from native PyTorch Geometric execution,
16 | in order to get the most out of IPU hardware.
17 |
18 | PopTorch Geometric depends on the functionality provided by PopTorch.
19 |
20 | PopTorch and PopTorch Geometric are included in the `Poplar SDK `__. See the `Getting Started guide `_ for your system for how to
21 | install the Poplar SDK. Refer to :numref:`installation` for how to install the PopTorch and PopTorch Geometric wheels.
22 |
--------------------------------------------------------------------------------
/docs/poptorch_geometric/user_guide/legal.rst:
--------------------------------------------------------------------------------
1 | Legal notices
2 | =============
3 |
4 | |LEGAL:TRADEMARKS|
5 |
6 | |LEGAL:EULA|
7 |
8 | © Copyright 2023 Graphcore Ltd. All rights reserved.
9 |
--------------------------------------------------------------------------------
/docs/poptorch_geometric/user_guide/reference.rst:
--------------------------------------------------------------------------------
1 | .. _reference:
2 |
3 | =============
4 | API reference
5 | =============
6 |
7 | .. _api_options:
8 |
9 | Data loaders
10 | ============
11 |
12 | .. autoclass:: poptorch_geometric.dataloader.DataLoader
13 |
14 | .. autoclass:: poptorch_geometric.dataloader.FixedSizeDataLoader
15 |
16 | .. autoclass:: poptorch_geometric.pyg_dataloader.FixedSizeStrategy
17 |
18 | .. autoclass:: poptorch_geometric.pyg_dataloader.OverSizeStrategy
19 |
20 | Cluster data loaders
21 | ====================
22 |
23 | .. autoclass:: poptorch_geometric.cluster_loader.FixedSizeClusterLoader
24 |
25 | Collators
26 | =========
27 |
28 | .. autoclass:: poptorch_geometric.collate.FixedSizeCollater
29 |
30 | Batch samplers
31 | ==============
32 |
33 | .. autoclass:: poptorch_geometric.stream_packing_sampler.StreamPackingSampler
34 |
35 | Fixed size options
36 | ==================
37 |
38 | .. autoclass:: poptorch_geometric.fixed_size_options.FixedSizeOptions
39 |
--------------------------------------------------------------------------------
/docs/poptorch_geometric/user_guide/tutorials.rst:
--------------------------------------------------------------------------------
1 | .. _examples_and_tutorials:
2 |
3 | ======================
4 | Examples and tutorials
5 | ======================
6 |
7 | Examples demonstrating different use scenarios for PopTorch Geometric are
8 | available in the
9 | `Graphcore examples repository on GitHub `_.
10 |
11 | Tutorials in the form of Jupyter notebooks are available in the `PyTorch Geometric tutorials directory `__. These tutorials show how to get the maximum benefit from IPU systems with PopTorch Geometric.
12 |
--------------------------------------------------------------------------------
/docs/user_guide/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | set(LONG_TESTS mnist inferenceModel)
2 |
3 | function(add_poptorch_py_user_guide_example name path)
4 | message(STATUS "Adding python example '${name}'")
5 | set(extra_labels "")
6 | if("${name}" STREQUAL "pipeline_simple")
7 | set(extra_labels ";external_data")
8 | else()
9 | if("${name}" IN_LIST LONG_TESTS)
10 | set(extra_labels "")
11 | else()
12 | set(extra_labels ";short")
13 | endif()
14 | endif()
15 |
16 | add_test(NAME "${name}_user_guide_example"
17 | COMMAND python3 ${path}/${name}.py
18 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
19 | set_tests_properties("${name}_user_guide_example" PROPERTIES LABELS "user_guide_examples${extra_labels}")
20 | endfunction()
21 |
22 | install(FILES "poptorch.conf" DESTINATION "${PROJECT_BINARY_DIR}/tmp")
23 |
24 | file(GLOB EXAMPLES "${CMAKE_CURRENT_SOURCE_DIR}/*.py")
25 | if(COPY_TESTS)
26 | install(FILES ${EXAMPLES} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
27 | set(DOC_EXAMPLES_PATH "${CMAKE_CURRENT_BINARY_DIR}")
28 | else()
29 | set(DOC_EXAMPLES_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
30 | endif()
31 |
32 | foreach(EXAMPLE ${EXAMPLES})
33 | get_filename_component(NAME ${EXAMPLE} NAME_WE)
34 | add_poptorch_py_user_guide_example(${NAME} ${DOC_EXAMPLES_PATH})
35 | endforeach()
36 |
37 | if(BUILD_DOCS)
38 | run_poptorch_install_command(
39 | "python3 ${PROJECT_SOURCE_DIR}/scripts/docs_build.py --install-dir ${CMAKE_INSTALL_PREFIX} --add-to-sys-path ${CMAKE_INSTALL_PREFIX}"
40 | "${PROJECT_BINARY_DIR}"
41 | "docs_build.py")
42 | endif()
43 |
--------------------------------------------------------------------------------
/docs/user_guide/IPU-pipeline.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/graphcore/poptorch/c2a8b17762f1d7106f7bf048ff011ab4fee7685e/docs/user_guide/IPU-pipeline.jpg
--------------------------------------------------------------------------------
/docs/user_guide/buffers.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2021 Graphcore Ltd. All rights reserved.
2 | import torch
3 | import poptorch
4 |
5 |
6 | # counter_model_wrong_start
7 | class CounterModel(torch.nn.Module):
8 | def __init__(self):
9 | super().__init__()
10 | self.i = torch.tensor([0.], dtype=torch.float)
11 |
12 | def forward(self):
13 | self.i += 1
14 | return self.i
15 |
16 |
17 | model = CounterModel()
18 | poptorch_model = poptorch.inferenceModel(model)
19 | print(poptorch_model()) # tensor([1.])
20 | print(poptorch_model()) # tensor([1.])
21 | # counter_model_wrong_end
22 |
23 | torch.testing.assert_close(model.i, torch.tensor([1.], dtype=torch.float))
24 |
25 |
26 | # pragma pylint: disable=function-redefined,no-member
27 | # counter_model_correct_start
28 | class CounterModel(torch.nn.Module):
29 | def __init__(self):
30 | super().__init__()
31 | self.register_buffer("i", torch.tensor([0.], dtype=torch.float))
32 |
33 | def forward(self):
34 | self.i += 1
35 | return self.i
36 |
37 |
38 | model = CounterModel()
39 | poptorch_model = poptorch.inferenceModel(model)
40 |
41 | print(poptorch_model()) # tensor([1.])
42 | print(poptorch_model()) # tensor([2.])
43 | # counter_model_correct_end
44 |
45 | # Because the model is running in inference mode, we will need to manually
46 | # call copyWeightsToHost
47 | poptorch_model.copyWeightsToHost()
48 | torch.testing.assert_close(model.i, torch.tensor([2.], dtype=torch.float))
49 |
--------------------------------------------------------------------------------
/docs/user_guide/comm-group-types.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/graphcore/poptorch/c2a8b17762f1d7106f7bf048ff011ab4fee7685e/docs/user_guide/comm-group-types.png
--------------------------------------------------------------------------------
/docs/user_guide/debugging.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # Copyright (c) 2021 Graphcore Ltd. All rights reserved.
3 | import torch
4 | import poptorch
5 |
6 |
7 | class Model(torch.nn.Module):
8 | def __init__(self):
9 | super().__init__()
10 | self.fc1 = torch.nn.Linear(10, 10)
11 | self.relu = torch.nn.ReLU()
12 | self.fc2 = torch.nn.Linear(10, 10)
13 | self.loss = torch.nn.MSELoss(reduction="mean")
14 |
15 | def forward(self, x, labels=None):
16 | out = self.fc2(self.relu(self.fc1(x)))
17 | if self.training:
18 | return self.loss(out, labels)
19 | return out
20 |
21 |
22 | # tensor_names_start
23 | input = torch.rand(10, 10)
24 | label = torch.rand(10, 10)
25 |
26 | model = Model()
27 | poptorch_model = poptorch.trainingModel(model)
28 | poptorch_model(input, label)
29 |
30 | tensor_names = poptorch_model.getTensorNames()
31 | # tensor_names_end
32 |
33 | # tensor_anchor_start
34 | opts = poptorch.Options()
35 | opts.anchorTensor('grad_bias', 'Gradient___fc2.bias')
36 | opts.anchorTensor('update_weight', 'UpdatedVar___fc2.weight')
37 | # tensor_anchor_end
38 |
39 | poptorch_model.destroy()
40 |
41 | # tensor_retrieve_start
42 | poptorch_model = poptorch.trainingModel(model, opts)
43 | poptorch_model(input, label)
44 |
45 | grad = poptorch_model.getAnchoredTensor('grad_bias')
46 | update = poptorch_model.getAnchoredTensor('update_weight')
47 | # tensor_retrieve_end
48 |
49 | poptorch_model.destroy()
50 |
51 | # optim_state_dict_start
52 | optim = poptorch.optim.SGD(model.parameters(), lr=0.01)
53 | poptorch_model = poptorch.trainingModel(model, opts, optim)
54 | poptorch_model(input, label)
55 |
56 | state = optim.state_dict()
57 | # optim_state_dict_end
58 |
--------------------------------------------------------------------------------
/docs/user_guide/example.rst:
--------------------------------------------------------------------------------
1 | Examples
2 | ========
3 |
4 | You can find PyTorch examples and tutorials in the Graphcore GitHub `examples repository `__.
5 | This contains:
6 |
7 | * Examples of popular machine learning models for training and inference
8 | * :tutorials-repo:`Tutorials `
9 | * :tutorials-repo:`Examples of PopTorch and IPU features `
10 | * :tutorials-repo:`Examples of simple models `
11 | * Source code from videos, blogs and other documents
12 |
13 | MNIST example
14 | _____________
15 |
16 | The example in :numref:`mnist-example-code` shows how an MNIST model can be run on the IPU. The highlighted lines show the PopTorch-specific code required to run the example on multiple IPUs.
17 |
18 | You can download the full source code from GitHub: :github-poptorch:`mnist.py `.
19 |
20 | To run this example you will need to install the Poplar SDK (see the `Getting Started Guide `_ for your IPU system) and the appropriate version of ``torchvision``:
21 |
22 | .. code-block:: console
23 |
24 | $ python3 -m pip install torchvision==0.11.1
25 |
26 | .. literalinclude:: ../../examples/mnist.py
27 | :caption: MNIST example
28 | :name: mnist-example-code
29 | :start-after: mnist_start
30 | :end-before: mnist_end
31 | :emphasize-lines: 12, 15, 17, 20, 35, 96, 99
32 | :language: python
33 | :dedent: 3
34 | :linenos:
35 | :lineno-match:
36 |
--------------------------------------------------------------------------------
/docs/user_guide/experimental.rst:
--------------------------------------------------------------------------------
1 | =====================
2 | Experimental features
3 | =====================
4 |
5 | Distributed execution without PopRun
6 | ====================================
7 |
8 | PopTorch supports distributed execution on a Pod using the IPU over Fabric
9 | (IPUoF).
10 |
11 | If you run a program using your own distributed processing tool instead of PopRun, the only change you need to make to your code is to set the ID of the current process and
12 | the total number of processes the execution is distributed across, using
13 | :py:meth:`~poptorch.options._DistributedOptions.configureProcessId`.
14 |
15 | Note that :py:meth:`~poptorch.Options.replicationFactor` should
16 | be used to set the number of local replicas (per host) not the total (global)
17 | number of replicas.
18 |
19 | .. literalinclude:: device_iterations.py
20 | :caption: Changes required for distributed execution
21 | :start-after: distributed_execution_start
22 | :end-before: distributed_execution_end
23 | :emphasize-lines: 9, 12, 18
24 | :linenos:
25 |
26 | .. note:: ``DataLoader`` will automatically select a different subset of the
27 | dataset based on the process ID.
28 |
29 | .. warning:: All the processes must use the same seed if ``shuffle=True`` is used
30 | for the ``DataLoader``.
31 |
32 | torch.nn.CTCLoss
33 | ================
34 |
35 | The CTCLoss operator is supported, with some limitations:
36 |
37 | #. The ``reduction`` parameter must be set to either ``sum`` or ``mean``
38 | #. The ``targets`` tensor must be 2D, corresponding to stacked, padded layout
39 |
--------------------------------------------------------------------------------
/docs/user_guide/index.rst:
--------------------------------------------------------------------------------
1 | PyTorch for the IPU: User Guide
2 | ===============================
3 |
4 | .. toctree::
5 | :maxdepth: 4
6 | :numbered: 3
7 |
8 | intro
9 | installation
10 | pytorch_to_poptorch
11 | overview
12 | batching
13 | supported_ops
14 | debugging
15 | hostio_optimisation
16 | example
17 | experimental
18 | reference
19 | legal
20 |
--------------------------------------------------------------------------------
/docs/user_guide/inferenceModel.py:
--------------------------------------------------------------------------------
1 | # Copyright (c) 2020 Graphcore Ltd. All rights reserved.
2 | import os
3 | import poptorch
4 | # If running on the model then make sure to run on the full size model to
5 | # avoid running out of memory.
6 | if not poptorch.ipuHardwareIsAvailable():
7 | os.environ["POPTORCH_IPU_MODEL"] = "1"
8 |
9 | # pylint: disable=reimported
10 | # pylint: disable=ungrouped-imports
11 | # pylint: disable=wrong-import-order
12 | # pylint: disable=wrong-import-position
13 |
14 | # inference_model_start
15 | import torch
16 | import torchvision
17 | import poptorch
18 |
19 | # Some dummy imagenet sized input.
20 | picture_of_a_cat_here = torch.randn([1, 3, 224, 224])
21 |
22 | # The model, in this case a MobileNet model with pretrained weights that comes
23 | # canned with PyTorch.
24 | model = torchvision.models.mobilenet_v2(pretrained=True)
25 | model.train(False)
26 |
27 | # Wrap in the PopTorch inference wrapper
28 | inference_model = poptorch.inferenceModel(model)
29 |
30 | # Execute on IPU.
31 | out_tensor = inference_model(picture_of_a_cat_here)
32 |
33 | # Get the top 5 ImageNet classes.
34 | top_five_classes = torch.topk(torch.softmax(out_tensor, 1), 5)
35 | print(top_five_classes)
36 |
37 | # Try the same on native PyTorch
38 | native_out = model(picture_of_a_cat_here)
39 |
40 | native_top_five_classes = torch.topk(torch.softmax(native_out, 1), 5)
41 |
42 | # Models should be very close to native output although some operations are
43 | # numerically different and floating point differences can accumulate.
44 | assert any(top_five_classes[1][0] == native_top_five_classes[1][0])
45 | # inference_half_start
46 | model = torch.nn.Linear(1, 10)
47 |
48 | # Cast the parameters (weights) to half.
49 | model.half()
50 |
51 | t1 = torch.tensor([1.]).half()
52 |
53 | opts = poptorch.Options()
54 |
55 | inference_model = poptorch.inferenceModel(model, opts)
56 | out = inference_model(t1)
57 |
58 | assert out.dtype == torch.half
59 | # inference_half_end
60 |
--------------------------------------------------------------------------------
/docs/user_guide/legal.rst:
--------------------------------------------------------------------------------
1 | Trademarks & copyright
2 | ======================
3 |
4 | |LEGAL:TRADEMARKS|
5 |
6 | |LEGAL:EULA|
7 |
8 | Copyright © 2020-|YEAR| Graphcore Ltd. All rights reserved.
9 |
--------------------------------------------------------------------------------
/docs/user_guide/no-buffering-profile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/graphcore/poptorch/c2a8b17762f1d7106f7bf048ff011ab4fee7685e/docs/user_guide/no-buffering-profile.png
--------------------------------------------------------------------------------
/docs/user_guide/pipelined_execution.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/graphcore/poptorch/c2a8b17762f1d7106f7bf048ff011ab4fee7685e/docs/user_guide/pipelined_execution.png
--------------------------------------------------------------------------------
/docs/user_guide/poptorch.conf:
--------------------------------------------------------------------------------
1 | deviceIterations(1)
2 | setExecutionStrategy(poptorch.ShardedExecution())
3 | replicationFactor(1)
4 | enableSyntheticData(True)
5 |
--------------------------------------------------------------------------------
/docs/user_guide/pytorch-software-stack.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/graphcore/poptorch/c2a8b17762f1d7106f7bf048ff011ab4fee7685e/docs/user_guide/pytorch-software-stack.png
--------------------------------------------------------------------------------
/docs/user_guide/sharded_execution.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/graphcore/poptorch/c2a8b17762f1d7106f7bf048ff011ab4fee7685e/docs/user_guide/sharded_execution.png
--------------------------------------------------------------------------------
/docs/user_guide/stages_summary.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/graphcore/poptorch/c2a8b17762f1d7106f7bf048ff011ab4fee7685e/docs/user_guide/stages_summary.png
--------------------------------------------------------------------------------
/docs/user_guide/with-buffering-overlap-profile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/graphcore/poptorch/c2a8b17762f1d7106f7bf048ff011ab4fee7685e/docs/user_guide/with-buffering-overlap-profile.png
--------------------------------------------------------------------------------
/docs/user_guide/with-buffering-profile.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/graphcore/poptorch/c2a8b17762f1d7106f7bf048ff011ab4fee7685e/docs/user_guide/with-buffering-profile.png
--------------------------------------------------------------------------------
/examples/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | function(add_poptorch_py_example name path)
2 | message(STATUS "Adding python example '${name}'")
3 |
4 | set(extra_labels "")
5 | if("${name}" STREQUAL "bert_ipu")
6 | set(extra_labels ";external_data")
7 | else()
8 | set(extra_labels ";short")
9 | endif()
10 | add_test(NAME "${name}_example"
11 | COMMAND python3 ${path}/${name}.py
12 | WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
13 | set_tests_properties("${name}_example" PROPERTIES LABELS "examples${extra_labels}")
14 | endfunction()
15 |
16 | file(GLOB EXAMPLES "${CMAKE_CURRENT_SOURCE_DIR}/*.py")
17 | if(COPY_TESTS)
18 | install(FILES ${EXAMPLES} DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
19 | set(EXAMPLES_PATH "${CMAKE_CURRENT_BINARY_DIR}")
20 | else()
21 | set(EXAMPLES_PATH "${CMAKE_CURRENT_SOURCE_DIR}")
22 | endif()
23 |
24 | foreach(EXAMPLE ${EXAMPLES})
25 | get_filename_component(NAME ${EXAMPLE} NAME_WE)
26 | add_poptorch_py_example(${NAME} ${EXAMPLES_PATH})
27 | endforeach()
28 |
--------------------------------------------------------------------------------
/examples/lstm.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # Copyright (c) 2020 Graphcore Ltd. All rights reserved.
3 |
4 | import torch
5 | import torch.nn as nn
6 | import poptorch
7 |
8 |
9 | class SimpleLSTM(nn.Module):
10 | def __init__(self):
11 | super().__init__()
12 | self.lstm = nn.LSTM(3, 3)
13 |
14 | def forward(self, input_tensors, hidden):
15 | Y, (Y_h, Y_c) = self.lstm(input_tensors, hidden)
16 | return Y, (Y_h, Y_c)
17 |
18 |
19 | inputs = [torch.randn(1, 3) for _ in range(5)]
20 | # Add the extra 2nd dimension
21 | inputs = torch.cat(inputs).view(len(inputs), 1, -1)
22 | hidden = (torch.randn(1, 1, 3), torch.randn(1, 1, 3)) # clean out hidden state
23 |
24 | inference_lstm = poptorch.inferenceModel(SimpleLSTM())
25 | out, hidden = inference_lstm(inputs, hidden)
26 |
27 | print(out)
28 | print(hidden)
29 |
--------------------------------------------------------------------------------
/examples/simple_adder.py:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env python3
2 | # Copyright (c) 2020 Graphcore Ltd. All rights reserved.
3 |
4 | import torch
5 | import torch.nn as nn
6 | import poptorch
7 |
8 | # This simple example demonstrates compiling a model to add
9 | # two tensors together using the IPU.
10 |
11 |
12 | class SimpleAdder(nn.Module):
13 | def forward(self, x, y):
14 | return x + y
15 |
16 |
17 | model = SimpleAdder()
18 | inference_model = poptorch.inferenceModel(model)
19 |
20 | t1 = torch.tensor([1.])
21 | t2 = torch.tensor([2.])
22 |
23 | assert inference_model(t1, t2) == 3.0
24 | print("Success")
25 |
--------------------------------------------------------------------------------
/examples/zeus.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/graphcore/poptorch/c2a8b17762f1d7106f7bf048ff011ab4fee7685e/examples/zeus.jpg
--------------------------------------------------------------------------------
/popart_compiler/include/popart_compiler/CodeletsCompilation.hpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved.
2 | #ifndef POPART_COMPILER_CODELETS_COMPILATION_HPP
3 | #define POPART_COMPILER_CODELETS_COMPILATION_HPP
4 |
5 | #include
6 |
7 | namespace poptorch {
8 | namespace popart_compiler {
9 |
10 | // Called from python on each 'import poptorch'. Cache path is expected to be
11 | // a true filesystem path of the installed python package where codelet sources
12 | // are stored.
13 | void setCustomCodeletsPath(const char *cache_path);
14 |
15 | // Compile a custom codelet (if not already compiled) and store the output
16 | // file to the path specified with 'setCustomCodeletsPath' above. This can
17 | // safely be called from multiple threads/processes.
18 | std::unique_ptr compileCustomCodeletIfNeeded(const char *src_file_name,
19 | bool hw_only_codelet);
20 |
21 | } // namespace popart_compiler
22 | } // namespace poptorch
23 |
24 | #endif // POPART_COMPILER_CODELETS_COMPILATION_HPP
25 |
--------------------------------------------------------------------------------
/popart_compiler/include/popart_compiler/SupportedOperations.inc.hpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020 Graphcore Ltd. All rights reserved.
2 | /*
3 | OP_DECLS are in the following form:
4 | OP_DECL(namespace, funcName, function, onnx implementation, arguments, body argument)
5 | - namespace is the op's namespace
6 | - funcName is the op name
7 | - function is the actual op part of the : pair and will be
8 | used to name/call the given function.
9 | - Onnx implementation is the underlaying onnx function which will be
10 | called.
11 | - Arguments are the arguments to the op which will be parsed by different
12 | macros depending on which file this is in.
13 | - Body arguments are just the names of the arguments so they can be used in
14 | the cpp file.
15 | */
16 | #include "CompilerOperationMacros.inc.hpp"
17 | #include "ManuallyAddedOperations.inc.hpp"
18 |
--------------------------------------------------------------------------------
/popart_compiler/include/popart_compiler/Utils.hpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020 Graphcore Ltd. All rights reserved.
2 | #ifndef POPART_COMPILER_UTILS_HPP
3 | #define POPART_COMPILER_UTILS_HPP
4 |
5 | #include
6 | #include
7 |
8 | namespace poptorch {
9 | namespace popart_compiler {
10 |
11 | bool ipuModelEnvironmentVariableIsEnabled();
12 |
13 | bool ipuSmallModelEnvironmentVariableIsEnabled();
14 |
15 | std::string getIpuModelVersion();
16 |
17 | int getNumTilesPerIpu(const std::string &ipu_model_version);
18 |
19 | std::uint64_t roundUpNumIPUs(std::uint64_t num_ipus);
20 |
21 | bool waitIfIpuIsUnavailable();
22 |
23 | bool waitForAWhile();
24 |
25 | /** Returns the IPU version of the device if the system contains a device with
26 | * num_ipus -1 if there is a device but the architecture is unknown. 0 if there
27 | * is no device with num_ipus.
28 | *
29 | * Note: This function doesn't check if the devices are currently in use.
30 | */
31 | std::int64_t ipuHardwareVersion(std::uint64_t num_ipus = 1);
32 |
33 | // Converts a C++ string to a unique pointer of the string array; the purpose
34 | // is to return a "string" without using the non ABI-compatible std::string
35 | std::unique_ptr stringToUniquePtr(const std::string &str);
36 |
37 | // Returns the dtype int corresponding to the onnx type string
38 | int64_t dtypeIntFromOnnxStr(const char *onnx_type);
39 |
40 | // Returns the Onnx datatype as string corresponding the dtype int used in Onnx
41 | // and Popart ops which take an int64_t dtype argument, a.g. "randomnormal"
42 | const char *onnxStrFromDtypeInt(int64_t dtype);
43 |
44 | } // namespace popart_compiler
45 | } // namespace poptorch
46 |
47 | #endif // POPART_COMPILER_UTILS_HPP
48 |
--------------------------------------------------------------------------------
/popart_compiler/source/include/popart_compiler/SessionOptionsImpl.hpp:
--------------------------------------------------------------------------------
1 | // Copyright (c) 2020 Graphcore Ltd. All rights reserved.
2 | #pragma once
3 |
4 | #include
5 | #include