├── .arcconfig ├── .arclint ├── .clang-format ├── .gitignore ├── .style.yapf ├── CMakeLists.txt ├── License.txt ├── README.md ├── cbt.json ├── exported_symbols_linux.lds ├── exported_symbols_osx.lds ├── poprithms ├── CMakeLists.txt ├── cmake │ └── EnableCompilerWarnings.cmake ├── notes │ ├── autodiff │ │ └── Autodiff.md │ ├── common │ │ └── compute │ │ │ └── diagrams │ │ │ ├── all_reduce_and_redundant_compute-Page-1.drawio.png │ │ │ ├── all_reduce_and_redundant_compute-Page-2.drawio.png │ │ │ └── all_reduce_and_redundant_compute.drawio │ ├── memory │ │ ├── alias │ │ │ ├── Alias.md │ │ │ └── diagrams │ │ │ │ ├── Untitled.drawio │ │ │ │ ├── complex0.drawio │ │ │ │ ├── complex0.png │ │ │ │ ├── numpystrides0.drawio │ │ │ │ ├── numpystrides0.png │ │ │ │ ├── numpystrides1.drawio │ │ │ │ ├── numpystrides1.png │ │ │ │ ├── numpystrides2.drawio │ │ │ │ ├── numpystrides2.png │ │ │ │ ├── sett0.drawio │ │ │ │ ├── sett0.png │ │ │ │ ├── sett1.drawio │ │ │ │ ├── sett1.png │ │ │ │ ├── sett2.drawio │ │ │ │ ├── sett2.drawio.png │ │ │ │ ├── sett2.png │ │ │ │ ├── sett3.drawio │ │ │ │ ├── sett3.png │ │ │ │ ├── sett4.drawio │ │ │ │ ├── sett4.png │ │ │ │ ├── sett5.drawio │ │ │ │ ├── sett5.png │ │ │ │ ├── sett6.drawio │ │ │ │ ├── sett6.png │ │ │ │ ├── stripes0.drawio │ │ │ │ └── stripes0.png │ │ ├── chain │ │ │ └── Chain.md │ │ └── unwind │ │ │ ├── Unwinding.md │ │ │ └── diagrams │ │ │ ├── Readme.md │ │ │ ├── broadcastadd0.drawio │ │ │ ├── broadcastadd0.png │ │ │ ├── broadcastadd1.drawio │ │ │ ├── broadcastadd1.png │ │ │ ├── broadcastadd2.drawio │ │ │ ├── broadcastadd2.png │ │ │ ├── call0.drawio │ │ │ ├── call0.png │ │ │ ├── call1.drawio │ │ │ ├── call1.png │ │ │ ├── call2.drawio │ │ │ ├── call2.png │ │ │ ├── fixedpoint0.drawio │ │ │ ├── fixedpoint0.png │ │ │ ├── fixedpoint1.drawio │ │ │ ├── fixedpoint1.png │ │ │ ├── matmul0.drawio │ │ │ ├── matmul0.png │ │ │ ├── matmul1.drawio │ │ │ ├── matmul1.png │ │ │ ├── objectivefunction0.drawio │ │ │ ├── objectivefunction0.png │ │ │ ├── playground.drawio │ │ │ ├── unbroadcastadd0.drawio │ │ │ ├── unbroadcastadd0.png │ │ │ ├── unbroadcastadd1.drawio │ │ │ ├── unbroadcastadd1.png │ │ │ ├── unwinding0 │ │ │ ├── unwinding0.drawio │ │ │ ├── unwinding0.png │ │ │ ├── unwinding1.drawio │ │ │ ├── unwinding1.png │ │ │ ├── unwinding2.drawio │ │ │ ├── unwinding2.png │ │ │ ├── unwinding3.drawio │ │ │ ├── unwinding3.png │ │ │ ├── unwinding4.drawio │ │ │ ├── unwinding4.png │ │ │ ├── unwinding5.drawio │ │ │ ├── valuedpair0.drawio │ │ │ └── valuedpair0.png │ ├── release_notes │ │ ├── for_sdk_2p3.txt │ │ └── for_sdk_2p5.txt │ └── schedule │ │ └── shift │ │ ├── Shift.md │ │ ├── adversary │ │ ├── animation.gif │ │ ├── dag.png │ │ └── demo.md │ │ ├── bifurcating │ │ ├── animation.gif │ │ ├── dag.png │ │ └── demo.md │ │ ├── grid │ │ ├── animation.gif │ │ ├── dag.png │ │ └── demo.md │ │ ├── ladderclimbing.md │ │ ├── optimizations.md │ │ ├── recompute │ │ ├── animation.gif │ │ ├── dag.png │ │ └── demo.md │ │ ├── shift_util.py │ │ ├── tree │ │ ├── animation.gif │ │ ├── dag.png │ │ └── demo.md │ │ └── visualization.py ├── poprithms │ ├── CMakeLists.txt │ ├── include │ │ └── poprithms │ │ │ ├── autodiff │ │ │ ├── automatic │ │ │ │ ├── autogradfunction.hpp │ │ │ │ ├── call.hpp │ │ │ │ ├── differentiator.hpp │ │ │ │ ├── gradinfos.hpp │ │ │ │ ├── gradopin.hpp │ │ │ │ ├── gradops.hpp │ │ │ │ ├── iautomaticmutator.hpp │ │ │ │ ├── iautomaticquerier.hpp │ │ │ │ ├── repeat.hpp │ │ │ │ ├── requiredids.hpp │ │ │ │ └── switch.hpp │ │ │ ├── core │ │ │ │ ├── autodiff.hpp │ │ │ │ ├── gradinfo.hpp │ │ │ │ ├── graphmutator.hpp │ │ │ │ ├── summary.hpp │ │ │ │ └── togradgraph.hpp │ │ │ ├── guide │ │ │ │ ├── graphinfo.hpp │ │ │ │ ├── guide.hpp │ │ │ │ ├── objective.hpp │ │ │ │ └── traversals.hpp │ │ │ ├── ids │ │ │ │ └── ids.hpp │ │ │ └── testutil │ │ │ │ ├── finitedifference.hpp │ │ │ │ ├── testgraphinfo.hpp │ │ │ │ ├── testgraphmutator.hpp │ │ │ │ └── testop.hpp │ │ │ ├── coloring │ │ │ └── ipropagator.hpp │ │ │ ├── common │ │ │ ├── compute │ │ │ │ ├── autodiff │ │ │ │ │ ├── autodiffer.hpp │ │ │ │ │ ├── automaticmutator.hpp │ │ │ │ │ ├── automaticquerier.hpp │ │ │ │ │ ├── coregraphmutator.hpp │ │ │ │ │ └── guidegraphinfo.hpp │ │ │ │ ├── callstackquerier.hpp │ │ │ │ ├── copyoptions.hpp │ │ │ │ ├── device.hpp │ │ │ │ ├── devicetype.hpp │ │ │ │ ├── gradopinids.hpp │ │ │ │ ├── gradopins.hpp │ │ │ │ ├── graph.hpp │ │ │ │ ├── host.hpp │ │ │ │ ├── hosttensor.hpp │ │ │ │ ├── iexecutable.hpp │ │ │ │ ├── ihostrunner.hpp │ │ │ │ ├── initialvalues.hpp │ │ │ │ ├── ipu.hpp │ │ │ │ ├── matmuloptions.hpp │ │ │ │ ├── memoryaliasmapper.hpp │ │ │ │ ├── op.hpp │ │ │ │ ├── ops │ │ │ │ │ ├── binaryelementwise.hpp │ │ │ │ │ ├── dynamic.hpp │ │ │ │ │ ├── encode.hpp │ │ │ │ │ ├── init.hpp │ │ │ │ │ ├── interdevicecopy.hpp │ │ │ │ │ ├── matmul.hpp │ │ │ │ │ ├── nop.hpp │ │ │ │ │ ├── reduce.hpp │ │ │ │ │ ├── reffrom.hpp │ │ │ │ │ ├── unaryelementwise.hpp │ │ │ │ │ ├── viewchange.hpp │ │ │ │ │ ├── withautodiff.hpp │ │ │ │ │ ├── withcallees.hpp │ │ │ │ │ └── withoutcallees.hpp │ │ │ │ ├── opverifier.hpp │ │ │ │ ├── pipeline.hpp │ │ │ │ ├── prune │ │ │ │ │ └── pruner.hpp │ │ │ │ ├── remote.hpp │ │ │ │ ├── remoteoptions.hpp │ │ │ │ ├── replication.hpp │ │ │ │ ├── scheduler.hpp │ │ │ │ ├── simexecutable.hpp │ │ │ │ ├── simtensormap.hpp │ │ │ │ ├── slickgraph.hpp │ │ │ │ ├── subgraph.hpp │ │ │ │ ├── tensor.hpp │ │ │ │ └── testutil │ │ │ │ │ ├── finitedifference.hpp │ │ │ │ │ ├── misctraintester.hpp │ │ │ │ │ ├── polyexecutabletester.hpp │ │ │ │ │ └── repeattester.hpp │ │ │ ├── multiout │ │ │ │ ├── consumptionid.hpp │ │ │ │ ├── fwdedgemap.hpp │ │ │ │ ├── graph.hpp │ │ │ │ ├── ioindices.hpp │ │ │ │ ├── logging.hpp │ │ │ │ ├── op.hpp │ │ │ │ ├── opid.hpp │ │ │ │ ├── optionaltensorid.hpp │ │ │ │ ├── optraversal.hpp │ │ │ │ ├── removalevent.hpp │ │ │ │ ├── skiptraversal.hpp │ │ │ │ ├── tensorid.hpp │ │ │ │ ├── tensormap.hpp │ │ │ │ ├── toptionaltensor.hpp │ │ │ │ ├── traversal.hpp │ │ │ │ └── util.hpp │ │ │ └── schedulable │ │ │ │ ├── additionalfwdedges.hpp │ │ │ │ ├── graph.hpp │ │ │ │ ├── op.hpp │ │ │ │ └── subgraphid.hpp │ │ │ ├── compute │ │ │ └── host │ │ │ │ ├── regionutil.hpp │ │ │ │ ├── tensor.hpp │ │ │ │ ├── tensormapper.hpp │ │ │ │ ├── usings.hpp │ │ │ │ └── viewchange.hpp │ │ │ ├── error │ │ │ └── error.hpp │ │ │ ├── logging │ │ │ ├── logging.hpp │ │ │ └── timepartitionlogger.hpp │ │ │ ├── memory │ │ │ ├── alias │ │ │ │ ├── graph.hpp │ │ │ │ ├── jitgrower.hpp │ │ │ │ ├── logging.hpp │ │ │ │ ├── mapper.hpp │ │ │ │ ├── node.hpp │ │ │ │ ├── nodes.hpp │ │ │ │ ├── origins.hpp │ │ │ │ ├── tensor.hpp │ │ │ │ └── usings.hpp │ │ │ ├── chain │ │ │ │ ├── chain.hpp │ │ │ │ ├── logging.hpp │ │ │ │ ├── settutil.hpp │ │ │ │ └── type.hpp │ │ │ ├── inplace │ │ │ │ ├── allowmultigatealias.hpp │ │ │ │ ├── checkparallelwriteable.hpp │ │ │ │ ├── color.hpp │ │ │ │ ├── constantpadding.hpp │ │ │ │ ├── constraint.hpp │ │ │ │ ├── crosslink.hpp │ │ │ │ ├── graph.hpp │ │ │ │ ├── logging.hpp │ │ │ │ ├── padding.hpp │ │ │ │ ├── proposal.hpp │ │ │ │ ├── result.hpp │ │ │ │ ├── tensor.hpp │ │ │ │ └── tensormap.hpp │ │ │ ├── nest │ │ │ │ ├── logging.hpp │ │ │ │ ├── optionalset.hpp │ │ │ │ ├── region.hpp │ │ │ │ ├── sett.hpp │ │ │ │ └── stripe.hpp │ │ │ └── unwind │ │ │ │ ├── dynamicattractions.hpp │ │ │ │ ├── graph.hpp │ │ │ │ ├── hosttensorhelper.hpp │ │ │ │ ├── logging.hpp │ │ │ │ ├── lower.hpp │ │ │ │ ├── matmulattractions.hpp │ │ │ │ ├── path.hpp │ │ │ │ ├── scheduledsolution.hpp │ │ │ │ ├── solution.hpp │ │ │ │ ├── sumlike.hpp │ │ │ │ └── valuedtensorid.hpp │ │ │ ├── ndarray │ │ │ ├── accessors.hpp │ │ │ ├── broadcastsetter.hpp │ │ │ ├── deviceid.hpp │ │ │ ├── dtype.hpp │ │ │ ├── groupedmatmulpack.hpp │ │ │ ├── shape.hpp │ │ │ ├── strideandoffset.hpp │ │ │ ├── tensorinfo.hpp │ │ │ └── unfold.hpp │ │ │ ├── outline │ │ │ └── linear │ │ │ │ ├── graph.hpp │ │ │ │ ├── linearusings.hpp │ │ │ │ ├── logging.hpp │ │ │ │ ├── op.hpp │ │ │ │ └── tensor.hpp │ │ │ ├── program │ │ │ ├── callstack │ │ │ │ ├── calleeindex.hpp │ │ │ │ ├── calleetensorid.hpp │ │ │ │ ├── callstack.hpp │ │ │ │ ├── carriedtensorid.hpp │ │ │ │ ├── copyin.hpp │ │ │ │ ├── copymap.hpp │ │ │ │ ├── copyout.hpp │ │ │ │ ├── querier.hpp │ │ │ │ ├── stackedio.hpp │ │ │ │ ├── stacktensorid.hpp │ │ │ │ └── stackutil.hpp │ │ │ ├── distributed │ │ │ │ ├── codelocation.hpp │ │ │ │ ├── helper.hpp │ │ │ │ └── program.hpp │ │ │ ├── pipeline │ │ │ │ ├── guide.hpp │ │ │ │ ├── imutator.hpp │ │ │ │ ├── iquerier.hpp │ │ │ │ ├── objective.hpp │ │ │ │ └── pipeline.hpp │ │ │ └── prune │ │ │ │ └── prune.hpp │ │ │ ├── schedule │ │ │ ├── connectedcomponents │ │ │ │ └── connectedcomponents.hpp │ │ │ ├── dfs │ │ │ │ └── dfs.hpp │ │ │ ├── scc │ │ │ │ └── scc.hpp │ │ │ ├── shift │ │ │ │ ├── alloc.hpp │ │ │ │ ├── allocweight.hpp │ │ │ │ ├── filteredschedule.hpp │ │ │ │ ├── fromcache.hpp │ │ │ │ ├── graph.hpp │ │ │ │ ├── ischedulecache.hpp │ │ │ │ ├── kahndecider.hpp │ │ │ │ ├── logging.hpp │ │ │ │ ├── op.hpp │ │ │ │ ├── opalloc.hpp │ │ │ │ ├── rotationalgo.hpp │ │ │ │ ├── rotationtermination.hpp │ │ │ │ ├── schedulecache.hpp │ │ │ │ ├── schedulechange.hpp │ │ │ │ ├── scheduledgraph.hpp │ │ │ │ ├── settings.hpp │ │ │ │ ├── shiftandcost.hpp │ │ │ │ ├── shiftusings.hpp │ │ │ │ ├── summarywriter.hpp │ │ │ │ ├── trackentry.hpp │ │ │ │ └── transitiveclosureoptimizations.hpp │ │ │ ├── supercon │ │ │ │ ├── graph.hpp │ │ │ │ └── logging.hpp │ │ │ ├── transitiveclosure │ │ │ │ ├── logging.hpp │ │ │ │ ├── partitionedtransitiveclosure.hpp │ │ │ │ └── transitiveclosure.hpp │ │ │ └── vanilla │ │ │ │ ├── pathcount.hpp │ │ │ │ ├── types.hpp │ │ │ │ ├── vanilla.hpp │ │ │ │ └── vanillamap.hpp │ │ │ └── util │ │ │ ├── circularcounter.hpp │ │ │ ├── contiguoussubset.hpp │ │ │ ├── copybyclone.hpp │ │ │ ├── copybyclone_impl.hpp │ │ │ ├── hashcombine.hpp │ │ │ ├── interval.hpp │ │ │ ├── map.hpp │ │ │ ├── permutation.hpp │ │ │ ├── printiter.hpp │ │ │ ├── stridedpartition.hpp │ │ │ ├── stringutil.hpp │ │ │ ├── typedinteger.hpp │ │ │ ├── typedvector.hpp │ │ │ ├── unisort.hpp │ │ │ ├── valuedtuple.hpp │ │ │ └── where.hpp │ ├── poprithms-config.cmake │ └── src │ │ └── poprithms │ │ ├── autodiff │ │ ├── autodiff │ │ │ ├── error.cpp │ │ │ └── error.hpp │ │ ├── automatic │ │ │ ├── autogradfunction.cpp │ │ │ ├── call.cpp │ │ │ ├── differentiator.cpp │ │ │ ├── gradinfos.cpp │ │ │ ├── iautomatic.cpp │ │ │ ├── repeat.cpp │ │ │ └── switch.cpp │ │ ├── core │ │ │ ├── autodiff.cpp │ │ │ ├── gradinfo.cpp │ │ │ └── summary.cpp │ │ ├── guide │ │ │ ├── graphinfo.cpp │ │ │ ├── guide.cpp │ │ │ ├── objective.cpp │ │ │ └── traversals.cpp │ │ └── testutil │ │ │ ├── finitedifference.cpp │ │ │ ├── testgraphinfo.cpp │ │ │ ├── testgraphmutator.cpp │ │ │ └── testop.cpp │ │ ├── coloring │ │ ├── error.cpp │ │ └── error.hpp │ │ ├── common │ │ ├── CMakeLists.txt │ │ ├── compute │ │ │ ├── autodiff │ │ │ │ ├── coregraphmutator.cpp │ │ │ │ └── guidegraphinfo.cpp │ │ │ ├── callstackquerier.cpp │ │ │ ├── device.cpp │ │ │ ├── devicetype.cpp │ │ │ ├── error.cpp │ │ │ ├── error.hpp │ │ │ ├── graph.cpp │ │ │ ├── iexecutable.cpp │ │ │ ├── initialvalues.cpp │ │ │ ├── memoryaliasmapper.cpp │ │ │ ├── op.cpp │ │ │ ├── ops │ │ │ │ ├── binaryelementwise.cpp │ │ │ │ ├── dynamic.cpp │ │ │ │ ├── encode.cpp │ │ │ │ ├── init.cpp │ │ │ │ ├── interdevicecopy.cpp │ │ │ │ ├── matmul.cpp │ │ │ │ ├── ops.cpp │ │ │ │ ├── reduce.cpp │ │ │ │ ├── reffrom.cpp │ │ │ │ ├── unaryelementwise.cpp │ │ │ │ ├── viewchange.cpp │ │ │ │ ├── withcallees.cpp │ │ │ │ └── withoutcallees.cpp │ │ │ ├── opverifier.cpp │ │ │ ├── pipeline │ │ │ │ └── pipeline.cpp │ │ │ ├── prune │ │ │ │ ├── prune.cpp │ │ │ │ └── prunemutator.hpp │ │ │ ├── scheduler.cpp │ │ │ ├── simexecutable.cpp │ │ │ ├── simtensormap.cpp │ │ │ ├── slickgraph.cpp │ │ │ ├── subgraph.cpp │ │ │ ├── tensor.cpp │ │ │ └── testutil │ │ │ │ ├── misctraintester.cpp │ │ │ │ └── repeattester.cpp │ │ ├── multiout │ │ │ ├── consumptionid.cpp │ │ │ ├── error.cpp │ │ │ ├── error.hpp │ │ │ ├── fwdedgemap.cpp │ │ │ ├── graph.cpp │ │ │ ├── logging.cpp │ │ │ ├── op.cpp │ │ │ ├── opid.cpp │ │ │ ├── optionaltensorid.cpp │ │ │ ├── optraversal.cpp │ │ │ ├── removalevent.cpp │ │ │ └── tensorid.cpp │ │ └── schedulable │ │ │ ├── bidiredgemap.cpp │ │ │ ├── bidiredgemap.hpp │ │ │ ├── error.cpp │ │ │ ├── error.hpp │ │ │ ├── graph.cpp │ │ │ ├── op.cpp │ │ │ └── subgraphid.cpp │ │ ├── compute │ │ └── host │ │ │ ├── basedata.cpp │ │ │ ├── error.cpp │ │ │ ├── error.hpp │ │ │ ├── gridpointhelper.cpp │ │ │ ├── ieeehalf.cpp │ │ │ ├── include │ │ │ ├── allocdata.hpp │ │ │ ├── basedata.hpp │ │ │ ├── baseoperators.hpp │ │ │ ├── externdecl.hpp │ │ │ ├── gridpointhelper.hpp │ │ │ ├── ieeehalf.hpp │ │ │ ├── numpyformatter.hpp │ │ │ ├── origindata.hpp │ │ │ ├── pointerdata.hpp │ │ │ ├── typedconcat.hpp │ │ │ ├── typeddata.hpp │ │ │ ├── typeswitch.hpp │ │ │ └── viewdata.hpp │ │ │ ├── numpyformatter.cpp │ │ │ ├── origindata.cpp │ │ │ ├── regionutil.cpp │ │ │ ├── serializer.cpp │ │ │ ├── serializer.hpp │ │ │ ├── tensor.cpp │ │ │ ├── tensormapper.cpp │ │ │ ├── types │ │ │ ├── bool.cpp │ │ │ ├── float16.cpp │ │ │ ├── float32float64.cpp │ │ │ ├── int16uint16.cpp │ │ │ ├── int32uint32.cpp │ │ │ ├── int64uint64.cpp │ │ │ └── int8uint8.cpp │ │ │ └── viewchange.cpp │ │ ├── error │ │ └── error.cpp │ │ ├── logging │ │ ├── error.cpp │ │ ├── error.hpp │ │ ├── logging.cpp │ │ └── timepartitionlogger.cpp │ │ ├── memory │ │ ├── alias │ │ │ ├── error.cpp │ │ │ ├── error.hpp │ │ │ ├── graph.cpp │ │ │ ├── logging.cpp │ │ │ ├── node.cpp │ │ │ ├── nodes.cpp │ │ │ ├── origins.cpp │ │ │ └── tensor.cpp │ │ ├── chain │ │ │ ├── chain.cpp │ │ │ ├── disjointregionsmapper.hpp │ │ │ ├── error.cpp │ │ │ ├── error.hpp │ │ │ ├── logging.cpp │ │ │ ├── op.cpp │ │ │ ├── op.hpp │ │ │ ├── settutil.cpp │ │ │ └── type.cpp │ │ ├── inplace │ │ │ ├── crosslink.cpp │ │ │ ├── error.cpp │ │ │ ├── error.hpp │ │ │ ├── graph.cpp │ │ │ ├── logging.cpp │ │ │ ├── op.cpp │ │ │ ├── op.hpp │ │ │ ├── ops.cpp │ │ │ ├── ops.hpp │ │ │ ├── proposal.cpp │ │ │ ├── result.cpp │ │ │ ├── tensor.cpp │ │ │ └── tensormap.cpp │ │ ├── nest │ │ │ ├── error.cpp │ │ │ ├── error.hpp │ │ │ ├── logging.cpp │ │ │ ├── region.cpp │ │ │ ├── sett.cpp │ │ │ └── stripe.cpp │ │ └── unwind │ │ │ ├── error.cpp │ │ │ ├── error.hpp │ │ │ ├── graph.cpp │ │ │ ├── hosttensorhelper.cpp │ │ │ ├── logging.cpp │ │ │ ├── lower.cpp │ │ │ ├── op.cpp │ │ │ ├── op.hpp │ │ │ ├── ops.cpp │ │ │ ├── ops.hpp │ │ │ ├── path.cpp │ │ │ ├── scheduledsolution.cpp │ │ │ ├── solution.cpp │ │ │ ├── sumlike.cpp │ │ │ └── valuedtensorid.cpp │ │ ├── ndarray │ │ ├── accessors.cpp │ │ ├── broadcastsetter.cpp │ │ ├── dtype.cpp │ │ ├── error.cpp │ │ ├── error.hpp │ │ ├── serializer.hpp │ │ ├── shape.cpp │ │ └── tensorinfo.cpp │ │ ├── outline │ │ └── linear │ │ │ ├── error.cpp │ │ │ ├── error.hpp │ │ │ ├── graph.cpp │ │ │ ├── linearusings.cpp │ │ │ ├── logging.cpp │ │ │ ├── op.cpp │ │ │ └── tensor.cpp │ │ ├── program │ │ ├── callstack │ │ │ ├── callstack.cpp │ │ │ ├── copyin.cpp │ │ │ ├── copyout.cpp │ │ │ ├── error.cpp │ │ │ ├── error.hpp │ │ │ └── querier.cpp │ │ ├── distributed │ │ │ ├── codelocation.cpp │ │ │ ├── error.cpp │ │ │ ├── error.hpp │ │ │ ├── helper.cpp │ │ │ └── program.cpp │ │ ├── pipeline │ │ │ ├── error.cpp │ │ │ ├── error.hpp │ │ │ └── pipeline.cpp │ │ └── prune │ │ │ ├── error.cpp │ │ │ ├── error.hpp │ │ │ └── prune.cpp │ │ ├── schedule │ │ ├── connectedcomponents │ │ │ ├── connectedcomponents.cpp │ │ │ ├── error.cpp │ │ │ └── error.hpp │ │ ├── dfs │ │ │ ├── dfs.cpp │ │ │ ├── error.cpp │ │ │ └── error.hpp │ │ ├── scc │ │ │ ├── error.cpp │ │ │ ├── error.hpp │ │ │ └── scc.cpp │ │ ├── shift │ │ │ ├── alloc.cpp │ │ │ ├── allocsimplifier.cpp │ │ │ ├── allocsimplifier.hpp │ │ │ ├── allocweight.cpp │ │ │ ├── error.cpp │ │ │ ├── error.hpp │ │ │ ├── fromcache.cpp │ │ │ ├── graph.cpp │ │ │ ├── graphserialization.cpp │ │ │ ├── graphserialization.hpp │ │ │ ├── greedykahn.cpp │ │ │ ├── greedykahn.hpp │ │ │ ├── kahndecider.cpp │ │ │ ├── logging.cpp │ │ │ ├── op.cpp │ │ │ ├── schedulecache.cpp │ │ │ ├── scheduledgraph.cpp │ │ │ ├── settings.cpp │ │ │ ├── shiftandcost.cpp │ │ │ ├── solutioncache.cpp │ │ │ ├── summarywriter.cpp │ │ │ ├── transitiveclosureconstrainer.cpp │ │ │ ├── transitiveclosureconstrainer.hpp │ │ │ ├── transitiveclosureoptimizations.cpp │ │ │ ├── transitiveclosureoptimizer.cpp │ │ │ ├── transitiveclosureoptimizer.hpp │ │ │ ├── updatefromfirstfinal.cpp │ │ │ └── updatefromfirstfinal.hpp │ │ ├── supercon │ │ │ ├── error.cpp │ │ │ ├── error.hpp │ │ │ ├── graph.cpp │ │ │ └── logging.cpp │ │ ├── transitiveclosure │ │ │ ├── error.cpp │ │ │ ├── error.hpp │ │ │ ├── logging.cpp │ │ │ ├── partitionedtransitiveclosure.cpp │ │ │ └── transitiveclosure.cpp │ │ └── vanilla │ │ │ ├── basestackwithmanypriorities.hpp │ │ │ ├── error.cpp │ │ │ ├── error.hpp │ │ │ ├── fifostack.hpp │ │ │ ├── filostack.hpp │ │ │ ├── greedystack.hpp │ │ │ ├── kahn.hpp │ │ │ ├── pathcount.cpp │ │ │ ├── randomstack.hpp │ │ │ └── vanilla.cpp │ │ └── util │ │ ├── error.cpp │ │ ├── error.hpp │ │ ├── interval.cpp │ │ ├── permutation.cpp │ │ ├── printiter.cpp │ │ ├── stridedpartition.cpp │ │ └── stringutil.cpp └── tests │ ├── CMakeLists.txt │ ├── googletests │ ├── CMakeLists.txt │ ├── autodiff │ │ ├── CMakeLists.txt │ │ └── automatic │ │ │ ├── CMakeLists.txt │ │ │ └── gradinfos_0.cpp │ ├── common │ │ ├── CMakeLists.txt │ │ └── compute │ │ │ ├── CMakeLists.txt │ │ │ ├── basic_functionality_0.cpp │ │ │ ├── call_0.cpp │ │ │ ├── interdevicecopy_0.cpp │ │ │ ├── simexecutable_0.cpp │ │ │ └── train_misc_0.cpp │ └── example │ │ ├── CMakeLists.txt │ │ └── googletest_example_0.cpp │ ├── mocks │ ├── CMakeLists.txt │ ├── include │ │ └── mock │ │ │ ├── memory │ │ │ └── alias │ │ │ │ ├── mockgraph.hpp │ │ │ │ ├── mockgraphfixture.hpp │ │ │ │ ├── mocktensor.hpp │ │ │ │ └── mocktensorfixture.hpp │ │ │ └── util │ │ │ ├── mockpermutation.hpp │ │ │ └── mockpermutationfixture.hpp │ └── src │ │ ├── CMakeLists.txt │ │ ├── memory │ │ └── alias │ │ │ ├── mockgraph.cpp │ │ │ └── mocktensor.cpp │ │ ├── poprithms_mock-config.cmake.in │ │ └── util │ │ └── mockpermutation.cpp │ ├── regression │ ├── CMakeLists.txt │ └── schedule │ │ ├── CMakeLists.txt │ │ └── shift │ │ ├── CMakeLists.txt │ │ ├── README.txt │ │ ├── fromserial.cpp │ │ ├── regression.cpp │ │ └── summarize.py │ ├── tests │ ├── CMakeLists.txt │ ├── autodiff │ │ ├── CMakeLists.txt │ │ ├── core_0.cpp │ │ ├── finite_difference_0.cpp │ │ └── guide_0.cpp │ ├── boost │ │ ├── CMakeLists.txt │ │ └── boost_basics.cpp │ ├── coloring │ │ ├── CMakeLists.txt │ │ └── coloring_0.cpp │ ├── common │ │ ├── CMakeLists.txt │ │ ├── compute │ │ │ ├── CMakeLists.txt │ │ │ ├── autograd_function_0.cpp │ │ │ ├── basics_0.cpp │ │ │ ├── demo_replicated_training_0.cpp │ │ │ ├── differentiator_0.cpp │ │ │ ├── error_checking_0.cpp │ │ │ ├── logging_0.cpp │ │ │ ├── miscellaneous_sim_train_0.cpp │ │ │ ├── pipeline_0.cpp │ │ │ ├── prune_call_0.cpp │ │ │ ├── prune_withcallees_0.cpp │ │ │ ├── repeat_0.cpp │ │ │ ├── second_derivative_0.cpp │ │ │ ├── switch_0.cpp │ │ │ ├── train_through_call_0.cpp │ │ │ ├── transform_sin_example_0.cpp │ │ │ └── value_dependence_0.cpp │ │ ├── multiout │ │ │ ├── CMakeLists.txt │ │ │ └── multiout_0.cpp │ │ └── schedulable │ │ │ ├── CMakeLists.txt │ │ │ ├── schedulable_0.cpp │ │ │ └── schedulable_1.cpp │ ├── compute │ │ ├── CMakeLists.txt │ │ ├── internal │ │ │ ├── CMakeLists.txt │ │ │ ├── base_operators_0.cpp │ │ │ ├── gridpointhelper_0.cpp │ │ │ └── numpy_string_formatter_0.cpp │ │ ├── tensor │ │ │ ├── CMakeLists.txt │ │ │ ├── arange_0.cpp │ │ │ ├── basic_0.cpp │ │ │ ├── cast_0.cpp │ │ │ ├── concat_0.cpp │ │ │ ├── constructors_0.cpp │ │ │ ├── contains_aliases_0.cpp │ │ │ ├── demo_0.cpp │ │ │ ├── gather_0.cpp │ │ │ ├── matmul_0.cpp │ │ │ ├── neg_0.cpp │ │ │ ├── numpy_binary_0.cpp │ │ │ ├── numpy_slice_0.cpp │ │ │ ├── numpy_unary_0.cpp │ │ │ ├── random_factories_0.cpp │ │ │ ├── reciprocal_0.cpp │ │ │ ├── reduce_0.cpp │ │ │ ├── reshape_0.cpp │ │ │ ├── resize_0.cpp │ │ │ ├── scatter_0.cpp │ │ │ ├── unary_0.cpp │ │ │ ├── update_0.cpp │ │ │ ├── vector_getters_0.cpp │ │ │ └── view_changers_0.cpp │ │ └── viewchange │ │ │ ├── CMakeLists.txt │ │ │ └── basic_0.cpp │ ├── dependency_free_interface │ │ ├── CMakeLists.txt │ │ └── dependency_free_interface_test.py │ ├── memory │ │ ├── CMakeLists.txt │ │ ├── alias │ │ │ ├── CMakeLists.txt │ │ │ ├── graph │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── allocate_0.cpp │ │ │ │ ├── constructors_0.cpp │ │ │ │ └── dimshuffle_0.cpp │ │ │ ├── origins │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── alias_0.cpp │ │ │ │ └── contiguous_0.cpp │ │ │ ├── tensor │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── basic_0.cpp │ │ │ │ ├── broadcast_0.cpp │ │ │ │ ├── clone_0.cpp │ │ │ │ ├── color_0.cpp │ │ │ │ ├── concat_0.cpp │ │ │ │ ├── demo_0.cpp │ │ │ │ ├── dimshuffle_0.cpp │ │ │ │ ├── expand_0.cpp │ │ │ │ ├── index_0.cpp │ │ │ │ ├── modify_0.cpp │ │ │ │ ├── modify_1.cpp │ │ │ │ ├── modify_2.cpp │ │ │ │ ├── pad_0.cpp │ │ │ │ ├── reshape_0.cpp │ │ │ │ ├── reverse_0.cpp │ │ │ │ ├── settfill_0.cpp │ │ │ │ ├── slice_0.cpp │ │ │ │ ├── slices_0.cpp │ │ │ │ ├── subscript_0.cpp │ │ │ │ └── upsample_0.cpp │ │ │ └── util │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── jitter_0.cpp │ │ ├── chain │ │ │ ├── CMakeLists.txt │ │ │ ├── basic_0.cpp │ │ │ ├── bubble_dimshuffle_back_0.cpp │ │ │ ├── canonicalize_chain_based_0.cpp │ │ │ ├── canonicalize_op_based_0.cpp │ │ │ ├── canonicalize_reshape_op_0.cpp │ │ │ ├── hosttensor_0.cpp │ │ │ ├── mergecontiguoussametype_0.cpp │ │ │ ├── removeidentity_0.cpp │ │ │ ├── resize_0.cpp │ │ │ ├── reverse_chain_0.cpp │ │ │ └── settutil_0.cpp │ │ ├── inplace │ │ │ ├── CMakeLists.txt │ │ │ ├── aliased_0.cpp │ │ │ ├── allowmultigatealias_0.cpp │ │ │ ├── ambiguity_0.cpp │ │ │ ├── basic_0.cpp │ │ │ ├── binary_0.cpp │ │ │ ├── concat_0.cpp │ │ │ ├── constant_0.cpp │ │ │ ├── constraints_0.cpp │ │ │ ├── contains_0.cpp │ │ │ ├── crosslink_0.cpp │ │ │ ├── demo_0.cpp │ │ │ ├── dimshuffle_noalias_0.cpp │ │ │ ├── graph_0.cpp │ │ │ ├── graphs_comparison_0.cpp │ │ │ ├── pad_0.cpp │ │ │ ├── regionmapping_0.cpp │ │ │ ├── reverse_reshape_0.cpp │ │ │ ├── settsample_0.cpp │ │ │ ├── staggered_inplacing_0.cpp │ │ │ └── traversal_0.cpp │ │ ├── nest │ │ │ ├── CMakeLists.txt │ │ │ ├── disjointregions │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── basic_0.cpp │ │ │ ├── region │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── basic_shape_0.cpp │ │ │ │ ├── constructors_0.cpp │ │ │ │ ├── empty_full_0.cpp │ │ │ │ ├── equivalent_0.cpp │ │ │ │ ├── expand_0.cpp │ │ │ │ ├── get_complement_0.cpp │ │ │ │ ├── intersect_0.cpp │ │ │ │ ├── merge_0.cpp │ │ │ │ ├── permute_0.cpp │ │ │ │ ├── reduce_0.cpp │ │ │ │ ├── reshape_0.cpp │ │ │ │ ├── reshape_random_0.cpp │ │ │ │ ├── reverse_0.cpp │ │ │ │ ├── scalars_0.cpp │ │ │ │ ├── sett_operations_random_0.cpp │ │ │ │ ├── settsample_0.cpp │ │ │ │ ├── slice_0.cpp │ │ │ │ ├── subtract_0.cpp │ │ │ │ └── subtract_random_0.cpp │ │ │ ├── sett │ │ │ │ ├── CMakeLists.txt │ │ │ │ ├── basic_0.cpp │ │ │ │ ├── basic_1.cpp │ │ │ │ ├── canonicalize_0.cpp │ │ │ │ ├── canonicalize_merge_0.cpp │ │ │ │ ├── canonicalize_random_0.cpp │ │ │ │ ├── contains_0.cpp │ │ │ │ ├── disjoint_0.cpp │ │ │ │ ├── fill_0.cpp │ │ │ │ ├── find_0.cpp │ │ │ │ ├── find_get_ons_random_0.cpp │ │ │ │ ├── flatten_random_0.cpp │ │ │ │ ├── get_complement_0.cpp │ │ │ │ ├── get_on_0.cpp │ │ │ │ ├── get_ons_0.cpp │ │ │ │ ├── get_reverse_0.cpp │ │ │ │ ├── get_stripes_0.cpp │ │ │ │ ├── intersect_0.cpp │ │ │ │ ├── intersect_random_0.cpp │ │ │ │ ├── sample_0.cpp │ │ │ │ ├── sample_1.cpp │ │ │ │ ├── sample_fill_random_0.cpp │ │ │ │ ├── sample_random_0.cpp │ │ │ │ ├── subtract_random_0.cpp │ │ │ │ └── unflatten_0.cpp │ │ │ └── stripe │ │ │ │ ├── CMakeLists.txt │ │ │ │ └── basic_0.cpp │ │ └── unwind │ │ │ ├── CMakeLists.txt │ │ │ ├── greedy0 │ │ │ ├── CMakeLists.txt │ │ │ ├── calls_in_parallel_0.cpp │ │ │ ├── calls_in_series_0.cpp │ │ │ ├── calls_in_series_1.cpp │ │ │ ├── dynamic_0.cpp │ │ │ ├── flat_linear_0.cpp │ │ │ ├── group_conv_with_bias_0.cpp │ │ │ ├── length_tiebreaker_0.cpp │ │ │ ├── lower_0.cpp │ │ │ ├── lower_tiebreaker_0.cpp │ │ │ ├── matmul_0.cpp │ │ │ ├── multi_path_0.cpp │ │ │ ├── ops_0.cpp │ │ │ ├── order_matters_0.cpp │ │ │ ├── single_call_0.cpp │ │ │ ├── slice_numpy_0.cpp │ │ │ ├── subsample_numpy_0.cpp │ │ │ └── sum_like_0.cpp │ │ │ ├── mappings │ │ │ ├── CMakeLists.txt │ │ │ └── reshape_0.cpp │ │ │ └── score │ │ │ ├── CMakeLists.txt │ │ │ ├── score_0.cpp │ │ │ └── solution_0.cpp │ ├── outline │ │ ├── CMakeLists.txt │ │ └── linear │ │ │ ├── CMakeLists.txt │ │ │ └── basic_0.cpp │ ├── program │ │ ├── CMakeLists.txt │ │ ├── callstack │ │ │ ├── CMakeLists.txt │ │ │ ├── copy_classes_0.cpp │ │ │ └── querier_0.cpp │ │ ├── distributed │ │ │ ├── CMakeLists.txt │ │ │ └── distributed_0.cpp │ │ └── prune │ │ │ ├── CMakeLists.txt │ │ │ └── prune_0.cpp │ ├── schedule │ │ ├── CMakeLists.txt │ │ ├── connectedcomponents │ │ │ ├── CMakeLists.txt │ │ │ └── connectedcomponents_0.cpp │ │ ├── dfs │ │ │ ├── CMakeLists.txt │ │ │ └── dfs_0.cpp │ │ ├── scc │ │ │ ├── CMakeLists.txt │ │ │ └── scc_0.cpp │ │ ├── shift │ │ │ ├── CMakeLists.txt │ │ │ ├── alloc_partitioned_bins_0.cpp │ │ │ ├── alloc_simplifier_0.cpp │ │ │ ├── allocweight_0.cpp │ │ │ ├── attractions.cpp │ │ │ ├── bifurcate.cpp │ │ │ ├── bin_constraints.cpp │ │ │ ├── branch_doubling.cpp │ │ │ ├── change_reader_0.py │ │ │ ├── change_writer_0.cpp │ │ │ ├── constraint_diff_0.cpp │ │ │ ├── cycle_0.cpp │ │ │ ├── diamond_0.cpp │ │ │ ├── empty_0.cpp │ │ │ ├── filtered_schedule_0.cpp │ │ │ ├── get_merged_0.cpp │ │ │ ├── get_schedule_0.cpp │ │ │ ├── graph_basics_0.cpp │ │ │ ├── graph_comparisons_0.cpp │ │ │ ├── graph_hash.cpp │ │ │ ├── grid.cpp │ │ │ ├── inputs.cpp │ │ │ ├── kahn_decider_0.cpp │ │ │ ├── links_0.cpp │ │ │ ├── links_1.cpp │ │ │ ├── links_2.cpp │ │ │ ├── logging_0.cpp │ │ │ ├── op_0.cpp │ │ │ ├── random.cpp │ │ │ ├── recompute.cpp │ │ │ ├── schedulable.cpp │ │ │ ├── schedulecache_0.cpp │ │ │ ├── searchlimits.cpp │ │ │ ├── serialization_0.cpp │ │ │ ├── serialization_errors.cpp │ │ │ ├── serialization_fromfile0.cpp │ │ │ ├── solutioncache_0.cpp │ │ │ ├── summary_writer_0.cpp │ │ │ ├── summary_writer_1.cpp │ │ │ ├── tco_constrain_parallel_chains_0.cpp │ │ │ ├── tco_constrain_weight_separated_0.cpp │ │ │ ├── tco_constrain_weight_separated_1.cpp │ │ │ ├── tco_constrain_weight_separated_2.cpp │ │ │ ├── tco_constrain_weight_separated_3.cpp │ │ │ ├── tco_constrain_weight_separated_4.cpp │ │ │ ├── tco_link_close_tight_pairs_0.cpp │ │ │ ├── tco_link_tight_drops_0.cpp │ │ │ ├── tco_link_tight_drops_1.cpp │ │ │ ├── test_random.cpp │ │ │ ├── testgraphs │ │ │ │ └── testgraph0.json.in │ │ │ └── tight_pairs.cpp │ │ ├── supercon │ │ │ ├── CMakeLists.txt │ │ │ └── schedule_0.cpp │ │ ├── transitiveclosure │ │ │ ├── CMakeLists.txt │ │ │ ├── bitset_performance_0.cpp │ │ │ ├── correctness_0.cpp │ │ │ ├── durationbound_0.cpp │ │ │ ├── extremum_status_0.cpp │ │ │ ├── extremum_statuses_0.cpp │ │ │ ├── get_unconstrained_0.cpp │ │ │ ├── partitionedtransitiveclosure_0.cpp │ │ │ ├── performance_0.cpp │ │ │ ├── post_0.cpp │ │ │ └── remove_redundant_0.cpp │ │ └── vanilla │ │ │ ├── CMakeLists.txt │ │ │ ├── greedystack_0.cpp │ │ │ ├── vanilla_0.cpp │ │ │ └── vanilla_1.cpp │ ├── util │ │ ├── CMakeLists.txt │ │ ├── dtype │ │ │ ├── CMakeLists.txt │ │ │ └── dtype_0.cpp │ │ ├── interval │ │ │ ├── CMakeLists.txt │ │ │ └── interval_0.cpp │ │ ├── logging │ │ │ ├── CMakeLists.txt │ │ │ ├── logging_test_0.cpp │ │ │ ├── logging_test_1.cpp │ │ │ ├── manualtimepartitionlogger_0.cpp │ │ │ └── switchingtimepartitionlogger_0.cpp │ │ ├── misc │ │ │ ├── CMakeLists.txt │ │ │ ├── copybyclone_0.cpp │ │ │ ├── error_0.cpp │ │ │ ├── misc_0.cpp │ │ │ ├── permutation_0.cpp │ │ │ ├── string_col_0.cpp │ │ │ ├── typedwrappers_0.cpp │ │ │ ├── unisort_0.cpp │ │ │ └── where_0.cpp │ │ ├── ndarray │ │ │ ├── CMakeLists.txt │ │ │ └── broadcastsetter_0.cpp │ │ ├── serialization │ │ │ ├── CMakeLists.txt │ │ │ └── serialization_0.cpp │ │ └── shape │ │ │ ├── CMakeLists.txt │ │ │ ├── shape_0.cpp │ │ │ ├── shape_1.cpp │ │ │ ├── shape_block_0.cpp │ │ │ ├── shape_conv_0.cpp │ │ │ ├── shape_gather_0.cpp │ │ │ ├── shape_matmul_0.cpp │ │ │ ├── shape_permutation_0.cpp │ │ │ ├── shape_reshape_factorization_0.cpp │ │ │ ├── shape_slice_0.cpp │ │ │ └── shape_strides_0.cpp │ └── verify_cxx_11_interface │ │ ├── CMakeLists.txt │ │ └── verify_cxx_11_interface.cpp │ └── testutil │ ├── CMakeLists.txt │ ├── include │ └── testutil │ │ ├── common │ │ └── schedulable │ │ │ └── graph.hpp │ │ ├── memory │ │ ├── nest │ │ │ ├── randomregion.hpp │ │ │ └── randomsett.hpp │ │ └── unwind │ │ │ ├── creatorinserter.hpp │ │ │ ├── fullstate.hpp │ │ │ ├── graph.hpp │ │ │ └── op.hpp │ │ ├── program │ │ └── callstack │ │ │ ├── graph.hpp │ │ │ └── querier.hpp │ │ └── schedule │ │ ├── base │ │ └── randomdag.hpp │ │ ├── commandlineoptions.hpp │ │ ├── shift │ │ ├── bifurcate_generator.hpp │ │ ├── branch_doubling_generator.hpp │ │ ├── diamond_generator.hpp │ │ ├── grid_generator.hpp │ │ ├── randomgraph.hpp │ │ ├── recompute_generator.hpp │ │ └── shiftcommandlineoptions.hpp │ │ └── transitiveclosure │ │ ├── randomedges.hpp │ │ └── transitiveclosurecommandlineoptions.hpp │ └── src │ └── testutil │ ├── common │ └── schedulable │ │ └── graph.cpp │ ├── memory │ ├── nest │ │ ├── randomregion.cpp │ │ └── randomsett.cpp │ └── unwind │ │ ├── fullstate.cpp │ │ ├── graph.cpp │ │ └── op.cpp │ ├── program │ └── callstack │ │ └── graph.cpp │ └── schedule │ ├── base │ └── randomdag.cpp │ ├── commandlineoptions.cpp │ ├── shift │ ├── bifurcate_generator.cpp │ ├── branch_doubling_generator.cpp │ ├── diamond_generator.cpp │ ├── grid_generator.cpp │ ├── randomgraph.cpp │ ├── recompute_generator.cpp │ └── shiftcommandlineoptions.cpp │ └── transitiveclosure │ ├── randomedges.cpp │ └── transitiveclosurecommandlineoptions.cpp └── scripts ├── check_copyright.py ├── check_header_guard_spacing.py ├── format.sh ├── get_clang_format_version.py └── rewrite_error_files.py /.arcconfig: -------------------------------------------------------------------------------- 1 | { 2 | "phabricator.uri" : "https://phabricator.sourcevertex.net", 3 | "load": [ 4 | "arcanist_linters/clang-format-linter", 5 | "arcanist_linters/yapf_linter" 6 | ], 7 | "arc.land.onto.default": "master", 8 | "base": "git:merge-base(origin/master)" 9 | } 10 | -------------------------------------------------------------------------------- /.arclint: -------------------------------------------------------------------------------- 1 | { 2 | "linters": { 3 | "clang-format": { 4 | "type": "clang-format", 5 | "include": "(\\.(c|cpp|C|cc|c\\+\\+|cxx|h|hpp)$)" 6 | }, 7 | "yapf": { 8 | "type": "yapf", 9 | "include": "(\\.py$)" 10 | }, 11 | "text-rst": { 12 | "type": "text", 13 | "include": "(\\.(rst)$)", 14 | "severity": { 15 | "1": "autofix", 16 | "2": "warning", 17 | "3": "warning", 18 | "4": "autofix", 19 | "5": "disabled", 20 | "6": "warning", 21 | "7": "warning", 22 | "8": "autofix" 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # create ~/.local_gitignore or similar for personal ignores. see for example, 2 | # https://medium.com/@peter_graham/how-to-create-a-local-gitignore-1b19f083492b 3 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.10) 2 | project(poprithms) 3 | 4 | include(CTest) 5 | 6 | # Add an explicit exported symbols file (a linker flag) 7 | if(APPLE) 8 | string(APPEND CMAKE_SHARED_LINKER_FLAGS 9 | " -Wl,-exported_symbols_list," 10 | "${CMAKE_CURRENT_SOURCE_DIR}/exported_symbols_osx.lds") 11 | else() 12 | string(APPEND CMAKE_SHARED_LINKER_FLAGS 13 | " -Wl,--version-script," 14 | "${CMAKE_CURRENT_SOURCE_DIR}/exported_symbols_linux.lds") 15 | endif() 16 | 17 | option(POPRITHMS_BUILD_MOCKS "Build the poprithms mocks library" ON) 18 | option(POPRITHMS_USE_STACKTRACE "Enable boost stacktrace reports in error messages" ON) 19 | if (${POPRITHMS_USE_STACKTRACE}) 20 | # Building with Boost Stacktrace using the default header only implementation 21 | # Note this is only supported for any compiler on POSIX or MinGW. 22 | message(STATUS "Building poprithms with Boost Stacktrace") 23 | add_definitions(-DPOPRITHMS_USE_STACKTRACE -DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED) 24 | endif() 25 | 26 | add_subdirectory(poprithms) 27 | -------------------------------------------------------------------------------- /License.txt: -------------------------------------------------------------------------------- 1 | Copyright ©2020 Graphcore Limited 2 | 3 | Licensed under terms of MIT license. 4 | You may obtain a copy of the license at https://opensource.org/licenses/MIT 5 | 6 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 7 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 8 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 9 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 10 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 11 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | -------------------------------------------------------------------------------- /cbt.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : [ "boost" ], 3 | "optional_dependencies" : [ "googletest" ] 4 | } 5 | -------------------------------------------------------------------------------- /exported_symbols_linux.lds: -------------------------------------------------------------------------------- 1 | V0 { 2 | global: 3 | _ZN?pop*; 4 | _ZN??pop*; 5 | _ZNK?pop*; 6 | _ZNK??pop*; 7 | _ZTSN?pop*; 8 | _ZTSN??pop*; 9 | _ZTIN?pop*; 10 | _ZTIN??pop*; 11 | _ZTVN?pop*; 12 | _ZTVN??pop*; 13 | _ZN?mock*; 14 | _ZN??mock*; 15 | _ZNK?mock*; 16 | _ZNK??mock*; 17 | _ZTSN?mock*; 18 | _ZTSN??mock*; 19 | _ZTIN?mock*; 20 | _ZTIN??mock*; 21 | _ZTVN?mock*; 22 | _ZTVN??mock*; 23 | local: 24 | *; 25 | }; 26 | -------------------------------------------------------------------------------- /exported_symbols_osx.lds: -------------------------------------------------------------------------------- 1 | __ZN?pop* 2 | __ZN??pop* 3 | __ZNK?pop* 4 | __ZNK??pop* 5 | __ZTSN?pop* 6 | __ZTSN??pop* 7 | __ZTIN?pop* 8 | __ZTIN??pop* 9 | __ZTVN?pop* 10 | __ZTVN??pop* 11 | -------------------------------------------------------------------------------- /poprithms/cmake/EnableCompilerWarnings.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_COMPILER_WARNINGS) 2 | list(APPEND CMAKE_COMPILER_WARNINGS 3 | -Wall 4 | -pedantic 5 | -Wextra 6 | # T67853: 7 | # -Wweak-vtables 8 | -Wdisabled-optimization 9 | -Wshadow 10 | -Wformat=2 11 | -Wundef) 12 | 13 | # Previously, Weverything was used. But it is suggested at 14 | # clang.llvm.org/docs/UsersManual.html#cmdoption-weverything 15 | #that this is not required/recommended. 16 | # if (CMAKE_${COMPILER}_COMPILER_ID MATCHES "Clang") 17 | # list(APPEND CMAKE_COMPILER_WARNINGS 18 | # -Weverything 19 | # # These seem unavoidable: 20 | # -Wno-exit-time-destructors 21 | # -Wno-c++98-compat 22 | # -Wno-c++98-compat-pedantic 23 | # -Wno-padded 24 | # -Wno-weak-vtables 25 | # -Wno-global-constructors 26 | # # Overwrite -Werror for this warning, i.e. do not 27 | # # ever error for an unknown warning flag 28 | # -Wno-error=unknown-warning-option) 29 | # endif() 30 | 31 | add_compile_options(${CMAKE_COMPILER_WARNINGS}) 32 | -------------------------------------------------------------------------------- /poprithms/notes/common/compute/diagrams/all_reduce_and_redundant_compute-Page-1.drawio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/common/compute/diagrams/all_reduce_and_redundant_compute-Page-1.drawio.png -------------------------------------------------------------------------------- /poprithms/notes/common/compute/diagrams/all_reduce_and_redundant_compute-Page-2.drawio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/common/compute/diagrams/all_reduce_and_redundant_compute-Page-2.drawio.png -------------------------------------------------------------------------------- /poprithms/notes/memory/alias/diagrams/complex0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/alias/diagrams/complex0.png -------------------------------------------------------------------------------- /poprithms/notes/memory/alias/diagrams/numpystrides0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/alias/diagrams/numpystrides0.png -------------------------------------------------------------------------------- /poprithms/notes/memory/alias/diagrams/numpystrides1.drawio: -------------------------------------------------------------------------------- 1 | 5Zhdr5sgGMc/jZdNFISjl6ftebnZVbMs2c3ChCo5KIbSaffphxWqzjbZku6MeOxF4f/wIr8/eQwEcFO2L4rUxSdJmQhASNsAbgMAQIix+euUU69EEUh7JVecWm0Qdvwns2Jo1SOn7DBpqKUUmtdTMZNVxTI90YhSspk220sxnbUmOZsJu4yIufqFU124ZeB0CLwynhd26gQ89IGSuMZ2JYeCUNmMJPgUwI2SUvelst0w0dFzXPp+zzeilxdTrNJ/0gGvwmL38pa+tt9WUB8/f21xsorjfpgfRBztiu3b6pND0BRcs11Nsq7eGJ8DuC50KUwtMkVyqHvwe94yM9d6LyttjYxwV+dCbKSQ6jwc3CcZyzKjH7SSb2wU+Z6gGIUmYt+JKc3am6uNLgzN7mOyZFqdTBPXwWG3Gy+x1WYwMbZSMbLPacRum/wy8EDWFCzcvwGNlgoaewYaLxQ0CD0D/bBU0LFnoJOlgk48A50uFDT07GOIwoWCjj3L0ShaKmjPcjQC7w8adb9roPH5sSOM9P65kwGe5W4EF7rTkW+5e6knRuTZQQb9hxOjSym3EsftVHMHA7BvH8/5SfJx5oBZrp5CnzKqZMV+A20lInhemWpm8DCjrzt4PCPi0QZKTmk3zfqay0oeK9p5ug2v+HoHNy43cO7mDiQzO/AVO+A/s2N+3tx+HDvi9N3sMNXhVvIcG13uwqdf -------------------------------------------------------------------------------- /poprithms/notes/memory/alias/diagrams/numpystrides1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/alias/diagrams/numpystrides1.png -------------------------------------------------------------------------------- /poprithms/notes/memory/alias/diagrams/numpystrides2.drawio: -------------------------------------------------------------------------------- 1 | 5ZpPj6MgGMY/jccmKoJ6nP7Zmcucms0me9mwSpUMiqF0tPvpFytWXdtkN+mOhGkPlQcE+T30ldfWAZuieRa4yl95Spjju2njgK3j+76LkPpolXOneJ4fd0omaKq1QdjTX0SLrlZPNCXHSUPJOZO0mooJL0uSyImGheD1tNmBs+moFc7ITNgnmM3VbzSVeT8NFA8VL4RmuR468sOuosB9Yz2TY45TXo8ksHPARnAuu6Oi2RDW0uu5dOd9uVN7vTBBSvk3J6CVm++f3+KX5scKyNPX7w2KVkHQdfOO2UnPWF+tPPcI6pxKsq9w0pZr5bMD1rksmCp56hAfqw78gTZEjbU+8FJqIz3UliljG864uHQHDlFCkkTpRyn4GxnV/IxgAF1Vo6+JCEmau7P1rgzV6iO8IFKcVZP+hB67XniRLtaDiYGW8pF9vYb1ssmuHQ9k1YGG+y+goa2gkWGgkaWgfdcw0KGtoAPDQEe2go4MAx1bChoYdjOErqWgA8NiNPRsBW1YjIb+x4OG7fsWaHR56R5Gevd6kAGGxW4ILF3p0LTYbWvGCA1LZOACGWMfUu4Fjvuh5gEGINNunvNM8mnmgJqunEKfMip5Sf4ArSXMaFaqYqLwEKWvW3g0wexJVxQ0Tdth1rdcFvxUpq2nW/eGrw9w4/oErn9y50czO9ANO8B/s2Oeb24/jx1BbJodC2Sli+54kGk7Hluz1dCwHU//tbIPtGE7HrRAtrpoSIkM2/Ggz5bFRoY9RkALZLHLGmDYTRXNs9vdzAFrN5lh+GGbTFUcfvq+1I3+QQB2vwE= -------------------------------------------------------------------------------- /poprithms/notes/memory/alias/diagrams/numpystrides2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/alias/diagrams/numpystrides2.png -------------------------------------------------------------------------------- /poprithms/notes/memory/alias/diagrams/sett0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/alias/diagrams/sett0.png -------------------------------------------------------------------------------- /poprithms/notes/memory/alias/diagrams/sett1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/alias/diagrams/sett1.png -------------------------------------------------------------------------------- /poprithms/notes/memory/alias/diagrams/sett2.drawio.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/alias/diagrams/sett2.drawio.png -------------------------------------------------------------------------------- /poprithms/notes/memory/alias/diagrams/sett2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/alias/diagrams/sett2.png -------------------------------------------------------------------------------- /poprithms/notes/memory/alias/diagrams/sett3.drawio: -------------------------------------------------------------------------------- 1 | 3VpNj5swEP01HCNhjI193XS7e+kpqir1UrngBLQmRo5TSH99ncWEoNVKXYnSMSfsN/58HvxmBBHe1t2TEU35RRdSRUlcdBH+FCVJwglyjyty6RFEEe6Rg6kKj43ArvotPRh79FwV8jRpaLVWtmqmYK6PR5nbCSaM0e202V6r6ayNOMg3wC4X6i36rSps6VFE+Wh4ltWh9FOzJOsNtRga+52cSlHo9g7CjxHeGq1tX6q7rVRX9gZe+n6f37HeFmbk0f5NB7qJy93TC3/ufmywPX/93lG2SSntx/kl1Nlv2S/XXgYO2rKycteI/Fpv3UFH+KG0tXI15Iri1PTM76tOuske9vpo/Umi9FqvlNpqpc3rcHjPcpnnDj9Zo1/kneUnIymJncWvSRoru3e3i24kOveTupbWXFwT3wF72r3jMV9tx0NMPVTeHd+ACe82h9u4I7Ou4Mn9ENHZvyd6BtoyaLSxlfonQtCY5kE4KCLAeBveGOi8cWi8oSB4AyckWbLSGxGc9mQ4CA/F0JQkS1fqoRiY9lCyANNz8AZMeyghQfCWAtMeShbIFufgDZiSUBJG8keAKQklC2R/c/AGThfCyOUINF2gYeRyFJou0DByOQpNF+gCudwMvGXQdIGtNcPIoCkJCyNSzqApCVvrdxUGTXtYGLE1g6Y9LIzYmoPTnjBiaw5NSYYbenU3IoemPTyMaBzF0KSELxCO/5+PzfFi6uOq4z8tr7a7X4Pw4x8= -------------------------------------------------------------------------------- /poprithms/notes/memory/alias/diagrams/sett3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/alias/diagrams/sett3.png -------------------------------------------------------------------------------- /poprithms/notes/memory/alias/diagrams/sett4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/alias/diagrams/sett4.png -------------------------------------------------------------------------------- /poprithms/notes/memory/alias/diagrams/sett5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/alias/diagrams/sett5.png -------------------------------------------------------------------------------- /poprithms/notes/memory/alias/diagrams/sett6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/alias/diagrams/sett6.png -------------------------------------------------------------------------------- /poprithms/notes/memory/alias/diagrams/stripes0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/alias/diagrams/stripes0.png -------------------------------------------------------------------------------- /poprithms/notes/memory/unwind/diagrams/Readme.md: -------------------------------------------------------------------------------- 1 | These diagrams were generated on the website https://app.diagrams.net 2 | The source code of this project is available at https://github.com/jgraph/drawio 3 | and is distributed under the Apache v2 licencse. 4 | 5 | For each diagram, there are 2 files: 6 | 1) an xml file with a .drawio extension, which can be opened and edited in the above project. 7 | 2) a png file corresponding to the .drawio file, which is included in the .md file for the user to see. 8 | -------------------------------------------------------------------------------- /poprithms/notes/memory/unwind/diagrams/broadcastadd0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/unwind/diagrams/broadcastadd0.png -------------------------------------------------------------------------------- /poprithms/notes/memory/unwind/diagrams/broadcastadd1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/unwind/diagrams/broadcastadd1.png -------------------------------------------------------------------------------- /poprithms/notes/memory/unwind/diagrams/broadcastadd2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/unwind/diagrams/broadcastadd2.png -------------------------------------------------------------------------------- /poprithms/notes/memory/unwind/diagrams/call0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/unwind/diagrams/call0.png -------------------------------------------------------------------------------- /poprithms/notes/memory/unwind/diagrams/call1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/unwind/diagrams/call1.png -------------------------------------------------------------------------------- /poprithms/notes/memory/unwind/diagrams/call2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/unwind/diagrams/call2.png -------------------------------------------------------------------------------- /poprithms/notes/memory/unwind/diagrams/fixedpoint0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/unwind/diagrams/fixedpoint0.png -------------------------------------------------------------------------------- /poprithms/notes/memory/unwind/diagrams/fixedpoint1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/unwind/diagrams/fixedpoint1.png -------------------------------------------------------------------------------- /poprithms/notes/memory/unwind/diagrams/matmul0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/unwind/diagrams/matmul0.png -------------------------------------------------------------------------------- /poprithms/notes/memory/unwind/diagrams/matmul1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/unwind/diagrams/matmul1.png -------------------------------------------------------------------------------- /poprithms/notes/memory/unwind/diagrams/objectivefunction0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/unwind/diagrams/objectivefunction0.png -------------------------------------------------------------------------------- /poprithms/notes/memory/unwind/diagrams/playground.drawio: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /poprithms/notes/memory/unwind/diagrams/unbroadcastadd0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/unwind/diagrams/unbroadcastadd0.png -------------------------------------------------------------------------------- /poprithms/notes/memory/unwind/diagrams/unbroadcastadd1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/unwind/diagrams/unbroadcastadd1.png -------------------------------------------------------------------------------- /poprithms/notes/memory/unwind/diagrams/unwinding0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/unwind/diagrams/unwinding0.png -------------------------------------------------------------------------------- /poprithms/notes/memory/unwind/diagrams/unwinding1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/unwind/diagrams/unwinding1.png -------------------------------------------------------------------------------- /poprithms/notes/memory/unwind/diagrams/unwinding2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/unwind/diagrams/unwinding2.png -------------------------------------------------------------------------------- /poprithms/notes/memory/unwind/diagrams/unwinding3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/unwind/diagrams/unwinding3.png -------------------------------------------------------------------------------- /poprithms/notes/memory/unwind/diagrams/unwinding4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/unwind/diagrams/unwinding4.png -------------------------------------------------------------------------------- /poprithms/notes/memory/unwind/diagrams/valuedpair0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/memory/unwind/diagrams/valuedpair0.png -------------------------------------------------------------------------------- /poprithms/notes/schedule/shift/adversary/animation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/schedule/shift/adversary/animation.gif -------------------------------------------------------------------------------- /poprithms/notes/schedule/shift/adversary/dag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/schedule/shift/adversary/dag.png -------------------------------------------------------------------------------- /poprithms/notes/schedule/shift/adversary/demo.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | The graph being scheduled is shown below. The grey boxes denote allocations, with the number in the box denoting the allocation's size. The circles denote the nodes (ops). 4 | 5 | ![The graph](./dag.png) 6 | 7 | The initial (random) schedule is 8 | 9 | ```0 10 9 5 4 1 2 6 15 7 12 16 17 3 21 8 18 26 11 13 23 20 28 24 25 19 29 14 27 22``` 10 | 11 | The sequence of sum-liveness reducing rotations (shifts) looks like: 12 | 13 | 14 | 15 | and the final schedule, after all rotations are applied is, 16 | 17 | ```0 3 4 10 1 7 5 12 18 9 26 16 17 6 21 8 11 2 14 13 15 19 22 23 25 20 27 28 29 24``` -------------------------------------------------------------------------------- /poprithms/notes/schedule/shift/bifurcating/animation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/schedule/shift/bifurcating/animation.gif -------------------------------------------------------------------------------- /poprithms/notes/schedule/shift/bifurcating/dag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/schedule/shift/bifurcating/dag.png -------------------------------------------------------------------------------- /poprithms/notes/schedule/shift/bifurcating/demo.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | The graph being scheduled is shown below. The grey boxes denote allocations, with the number in the box denoting the allocation's size. The circles denote the nodes (ops). 4 | 5 | ![The graph](./dag.png) 6 | 7 | The initial (random) schedule is 8 | 9 | ```0 1 2 4 9 19 5 10 6 13 12 3 39 8 17 35 40 7 27 28 18 37 56 26 55 22 58 53 75 11 67 24 36 20 57 65 76 15 16 50 31 54 38 14 74 30 21 34 25 46 62 29 51 33 41 49 45 23 72 47 32 61 48 78 42 44 71 83 85 68 81 70 66 60 43 63 69 59 64 82 52 79 88 73 80 87 91 84 77 89 86 90 92 93 94``` 10 | 11 | The sequence of sum-liveness reducing rotations (shifts) looks like: 12 | 13 | 14 | 15 | and the final schedule, after all rotations are applied is, 16 | 17 | ```0 2 1 3 4 10 9 22 45 46 70 21 43 44 69 82 19 39 40 67 20 42 41 68 81 88 7 8 17 36 35 65 18 37 38 66 80 15 32 31 63 16 33 34 64 79 87 91 5 6 14 13 27 28 55 56 75 57 58 76 85 29 60 59 77 30 62 61 78 86 90 12 26 53 54 74 25 51 52 73 84 11 24 23 47 48 71 49 50 72 83 89 92 93 94``` -------------------------------------------------------------------------------- /poprithms/notes/schedule/shift/grid/animation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/schedule/shift/grid/animation.gif -------------------------------------------------------------------------------- /poprithms/notes/schedule/shift/grid/dag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/schedule/shift/grid/dag.png -------------------------------------------------------------------------------- /poprithms/notes/schedule/shift/grid/demo.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | The graph being scheduled is shown below. The grey boxes denote allocations, with the number in the box denoting the allocation's size. The circles denote the nodes (ops). 4 | 5 | ![The graph](./dag.png) 6 | 7 | The initial (random) schedule is 8 | 9 | ```0 1 8 14 2 3 9 26 4 27 20 32 21 10 15 16 5 17 33 11 6 44 22 28 38 29 45 46 23 7 24 50 25 18 39 19 34 40 35 36 47 30 12 37 31 51 13 41 42 52 43 53 48 49 54 55 56 57 58 59 60 61 62 63``` 10 | 11 | The sequence of sum-liveness reducing rotations (shifts) looks like: 12 | 13 | 14 | 15 | and the final schedule, after all rotations are applied is, 16 | 17 | ```0 8 9 10 11 12 1 14 2 3 20 21 22 23 24 26 4 5 32 33 34 35 36 37 38 39 40 41 42 43 6 7 44 45 46 47 50 51 48 52 53 54 55 49 56 57 58 59 27 28 29 30 31 60 25 61 15 16 17 18 19 62 13 63``` -------------------------------------------------------------------------------- /poprithms/notes/schedule/shift/ladderclimbing.md: -------------------------------------------------------------------------------- 1 | This page describes ladder climbing (1-shifts, 2-shifts, etc). Coming soon. 2 | -------------------------------------------------------------------------------- /poprithms/notes/schedule/shift/optimizations.md: -------------------------------------------------------------------------------- 1 | A discussion of the optimizations, coming soon. 2 | -------------------------------------------------------------------------------- /poprithms/notes/schedule/shift/recompute/animation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/schedule/shift/recompute/animation.gif -------------------------------------------------------------------------------- /poprithms/notes/schedule/shift/recompute/dag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/schedule/shift/recompute/dag.png -------------------------------------------------------------------------------- /poprithms/notes/schedule/shift/recompute/demo.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | The graph being scheduled is shown below. The grey boxes denote allocations, with the number in the box denoting the allocation's size. The circles denote the nodes (ops). 4 | 5 | ![The graph](./dag.png) 6 | 7 | The initial (random) schedule is 8 | 9 | ```0 2 4 6 1 3 9 7 12 10 16 15 5 8 14 18 21 11 19 13 17 20 22 24 25 26 29 23 28 32 31 34 36 37 38 27 40 43 41 30 33 35 39 42 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61``` 10 | 11 | The sequence of sum-liveness reducing rotations (shifts) looks like: 12 | 13 | 14 | 15 | and the final schedule, after all rotations are applied is, 16 | 17 | ```0 1 5 8 11 13 17 20 22 23 27 30 33 35 39 42 44 45 24 28 31 34 36 40 43 46 37 41 47 38 48 49 25 29 32 50 51 26 52 53 2 6 9 12 14 18 21 54 15 19 55 16 56 57 3 7 10 58 59 4 60 61``` -------------------------------------------------------------------------------- /poprithms/notes/schedule/shift/tree/animation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/schedule/shift/tree/animation.gif -------------------------------------------------------------------------------- /poprithms/notes/schedule/shift/tree/dag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/notes/schedule/shift/tree/dag.png -------------------------------------------------------------------------------- /poprithms/notes/schedule/shift/tree/demo.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | The graph being scheduled is shown below. The grey boxes denote allocations, with the number in the box denoting the allocation's size. The circles denote the nodes (ops). 4 | 5 | ![The graph](./dag.png) 6 | 7 | The initial (random) schedule is 8 | 9 | ```0 6 10 11 5 12 17 3 4 2 7 8 15 1 22 26 28 31 25 9 16 14 18 13 19 29 23 30 20 21 27 32 24 33 36 42 34 35 39 37 40 44 41 45 47 43 46 38 48 49``` 10 | 11 | The sequence of sum-liveness reducing rotations (shifts) looks like: 12 | 13 | 14 | 15 | and the final schedule, after all rotations are applied is, 16 | 17 | ```2 3 1 0 6 10 11 12 17 4 7 5 8 15 22 29 28 26 31 25 23 30 14 18 9 13 16 20 19 21 24 27 32 37 33 40 36 42 34 35 38 39 41 43 49 44 48 45 46 47``` -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/autodiff/automatic/call.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_AUTODIFF_AUTOMATIC_CALL_HPP 3 | #define POPRITHMS_AUTODIFF_AUTOMATIC_CALL_HPP 4 | 5 | #include 6 | #include 7 | 8 | namespace poprithms { 9 | namespace autodiff { 10 | namespace automatic { 11 | 12 | class CallDifferentiator { 13 | 14 | public: 15 | /** 16 | * Create input gradients for the call op #callOpId by extending the 17 | * sub-graph #toExtend with a call to a gradient sub-graph. 18 | * */ 19 | static OptionalTensorIds 20 | createInGrads(OpId callOpId, 21 | IAutomaticMutator &, 22 | const IAutomaticQuerier &, 23 | const poprithms::autodiff::core::ToGradGraph &, 24 | const GradInfos &, 25 | SubGraphId toExtend); 26 | }; 27 | 28 | } // namespace automatic 29 | } // namespace autodiff 30 | } // namespace poprithms 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/common/compute/copyoptions.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | 3 | #ifndef POPRITHMS_COMMON_COMPUTE_COPYOPTIONS_HPP 4 | #define POPRITHMS_COMMON_COMPUTE_COPYOPTIONS_HPP 5 | 6 | #include 7 | 8 | namespace poprithms { 9 | namespace common { 10 | namespace compute { 11 | /** 12 | * Options for ops which copy between host and ipu. 13 | * */ 14 | class CopyBetweenHostAndIpuOptions { 15 | 16 | public: 17 | CopyBetweenHostAndIpuOptions() = default; 18 | ~CopyBetweenHostAndIpuOptions() = default; 19 | 20 | uint64_t bufferingDepth() const { return bufferingDepth_; } 21 | CopyBetweenHostAndIpuOptions &bufferingDepth(uint64_t v) { 22 | bufferingDepth_ = v; 23 | return *this; 24 | } 25 | 26 | bool operator==(const CopyBetweenHostAndIpuOptions &rhs) const { 27 | return t() == rhs.t(); 28 | } 29 | 30 | bool operator<(const CopyBetweenHostAndIpuOptions &rhs) const { 31 | return t() < rhs.t(); 32 | } 33 | 34 | private: 35 | std::tuple t() const { return bufferingDepth_; } 36 | uint64_t bufferingDepth_ = 1ull; 37 | }; 38 | 39 | } // namespace compute 40 | } // namespace common 41 | } // namespace poprithms 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/common/compute/devicetype.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | 3 | #ifndef POPRITHMS_COMMON_COMPUTE_DEVICETYPE_HPP 4 | #define POPRITHMS_COMMON_COMPUTE_DEVICETYPE_HPP 5 | 6 | #include 7 | #include 8 | 9 | namespace poprithms { 10 | namespace common { 11 | namespace compute { 12 | 13 | /** 14 | * The basic device types in a standard Graphcore system. 15 | * */ 16 | enum class DeviceType { Host = 0, Ipu, Remote }; 17 | 18 | using DeviceTypes = std::vector; 19 | 20 | std::ostream &operator<<(std::ostream &, DeviceType); 21 | std::ostream &operator<<(std::ostream &, const DeviceTypes &); 22 | 23 | } // namespace compute 24 | } // namespace common 25 | } // namespace poprithms 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/common/compute/gradopinids.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_COMMON_COMPUTE_GRADOPINIDS_HPP 3 | #define POPRITHMS_COMMON_COMPUTE_GRADOPINIDS_HPP 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | namespace poprithms { 10 | namespace common { 11 | namespace compute { 12 | 13 | using poprithms::common::multiout::OptionalTensorId; 14 | using poprithms::common::multiout::OptionalTensorIds; 15 | using poprithms::common::multiout::TensorId; 16 | using poprithms::common::multiout::TensorIds; 17 | 18 | using GradOpInIds = 19 | poprithms::autodiff::automatic::OpIn; 20 | 21 | } // namespace compute 22 | } // namespace common 23 | } // namespace poprithms 24 | #endif 25 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/common/compute/host.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | 3 | #ifndef POPRITHMS_COMMON_COMPUTE_HOST_HPP 4 | #define POPRITHMS_COMMON_COMPUTE_HOST_HPP 5 | 6 | #include 7 | 8 | namespace poprithms { 9 | namespace common { 10 | namespace compute { 11 | 12 | /** 13 | * The host device type. 14 | * */ 15 | class Host : public Device { 16 | public: 17 | Host(DeviceId id) : Device(id, DeviceType::Host) {} 18 | std::unique_ptr clone() const final; 19 | 20 | private: 21 | /** 22 | * There is no restriction on the shape or type of host tensor, so these 23 | * methods return true. 24 | * */ 25 | bool canStoreShape(const Shape &) const final { return true; } 26 | bool canStoreDType(DType) const final { return true; } 27 | }; 28 | 29 | } // namespace compute 30 | } // namespace common 31 | } // namespace poprithms 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/common/compute/hosttensor.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_COMMON_COMPUTE_HOSTTENSOR_HPP 3 | #define POPRITHMS_COMMON_COMPUTE_HOSTTENSOR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace common { 9 | namespace compute { 10 | 11 | using HostTensor = poprithms::compute::host::Tensor; 12 | using HostTensors = std::vector; 13 | 14 | /** A host tensor where operator== is defined via numerical equivalence. */ 15 | class ComparableHostTensor { 16 | public: 17 | ComparableHostTensor(const HostTensor &t_) : t(t_) {} 18 | bool operator==(const ComparableHostTensor &rhs) const { 19 | return t.numericallyIdenticalTo(rhs.tensor()); 20 | } 21 | HostTensor tensor() const { return t; } 22 | 23 | private: 24 | HostTensor t; 25 | }; 26 | 27 | using ComparableHostTensors = std::vector; 28 | 29 | } // namespace compute 30 | } // namespace common 31 | } // namespace poprithms 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/common/compute/matmuloptions.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | 3 | #ifndef POPRITHMS_COMMON_COMPUTE_MATMULOPTIONS_HPP 4 | #define POPRITHMS_COMMON_COMPUTE_MATMULOPTIONS_HPP 5 | 6 | #include 7 | 8 | namespace poprithms { 9 | namespace common { 10 | namespace compute { 11 | 12 | struct MatMulOptions { 13 | // Currently there are no options for matmul, this is a just placeholder for 14 | // the future. 15 | public: 16 | bool operator==(const MatMulOptions &) const { return true; } 17 | }; 18 | 19 | } // namespace compute 20 | } // namespace common 21 | } // namespace poprithms 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/common/compute/prune/pruner.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_COMMON_COMPUTE_PRUNE_PRUNER_HPP 3 | #define POPRITHMS_COMMON_COMPUTE_PRUNE_PRUNER_HPP 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include 11 | 12 | namespace poprithms { 13 | namespace common { 14 | namespace compute { 15 | 16 | /** 17 | * Prune a compute::Graph. 18 | * 19 | * Note that control deps are not transferred while pruning. 20 | * */ 21 | class Pruner { 22 | public: 23 | /** 24 | * Do not prune any tensors in #retain. All other tensors can 25 | * be pruned if they are determined to not have any effect on the tensors in 26 | * #retain. 27 | * */ 28 | static void prune(Graph &g, const TensorIds &retain) { 29 | pruneButPreserveUnpruneableRefs(g, retain); 30 | } 31 | 32 | /** 33 | * Do not prune any host tensors. 34 | * */ 35 | static void preserveHostTensors(Graph &g) { prune(g, g.hostTensorIds()); } 36 | 37 | private: 38 | static TensorIds getUnprunenableRefs(const Graph &); 39 | static void pruneButPreserveUnpruneableRefs(Graph &, TensorIds retain); 40 | }; 41 | 42 | } // namespace compute 43 | } // namespace common 44 | } // namespace poprithms 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/common/compute/testutil/misctraintester.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_COMMON_COMPUTE_TESTUTIL_MISCTRAINTESTER_HPP 3 | #define POPRITHMS_COMMON_COMPUTE_TESTUTIL_MISCTRAINTESTER_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace common { 9 | namespace compute { 10 | namespace testutil { 11 | 12 | /** 13 | * Miscellaneous training examples. 14 | * */ 15 | class MiscTrainTester : public PolyExecutableTester { 16 | public: 17 | MiscTrainTester(); 18 | virtual ~MiscTrainTester(); 19 | 20 | void testRepeatedAddInput(); 21 | 22 | void all() { testRepeatedAddInput(); } 23 | }; 24 | 25 | } // namespace testutil 26 | } // namespace compute 27 | } // namespace common 28 | } // namespace poprithms 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/common/multiout/ioindices.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_COMMON_MULTIOUT_IOINDICES_HPP 3 | #define POPRITHMS_COMMON_MULTIOUT_IOINDICES_HPP 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | namespace poprithms { 11 | namespace common { 12 | namespace multiout { 13 | 14 | using InIndex = poprithms::util::TypedInteger<'i', uint64_t>; 15 | using OutIndex = poprithms::util::TypedInteger<'o', uint64_t>; 16 | 17 | using OutIndices = std::vector; 18 | using InIndices = std::vector; 19 | 20 | using ContiguousOutIndexSubset = poprithms::util::ContiguousSubset; 21 | using ContiguousInIndexSubset = poprithms::util::ContiguousSubset; 22 | 23 | } // namespace multiout 24 | } // namespace common 25 | } // namespace poprithms 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/common/multiout/logging.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_MEMORY_COMMON_MULTIOUT_HPP 3 | #define POPRITHMS_MEMORY_COMMON_MULTIOUT_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace memory { 9 | namespace inplace { 10 | 11 | poprithms::logging::Logger &log(); 12 | 13 | } // namespace inplace 14 | } // namespace memory 15 | } // namespace poprithms 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/common/multiout/opid.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_COMMON_MULTIOUT_OPID_HPP 3 | #define POPRITHMS_COMMON_MULTIOUT_OPID_HPP 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | namespace poprithms { 11 | namespace common { 12 | namespace multiout { 13 | 14 | using OpId = poprithms::util::TypedInteger<'O', int64_t>; 15 | using OpIds = std::vector; 16 | std::ostream &operator<<(std::ostream &, const OpIds &); 17 | 18 | } // namespace multiout 19 | } // namespace common 20 | } // namespace poprithms 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/common/multiout/util.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_COMMON_MULTIOUT_UTIL_UTIL_HPP 3 | #define POPRITHMS_COMMON_MULTIOUT_UTIL_UTIL_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace common { 9 | namespace multiout { 10 | namespace util { 11 | 12 | template Ids ids(const Ts &ts) { 13 | Ids ids_; 14 | ids_.reserve(ts.size()); 15 | for (const auto &t : ts) { 16 | ids_.push_back(t.id()); 17 | } 18 | return ids_; 19 | } 20 | 21 | /** 22 | * Given a map M0 with keys as TensorIds and values as some numeric type, 23 | * accumulate the values by each tensors producing op. For example, if #m0 is 24 | * {(0,0):5, (0,1):6, (1,0):3} the returned map is {0:11, 1:3}. 25 | * */ 26 | template M1 sumOverOutTensors(const M0 &m0) { 27 | M1 m1; 28 | for (const auto &key_value : m0) { 29 | const auto &k = key_value.first; 30 | const auto &v = key_value.second; 31 | auto found = m1.find(k.opId()); 32 | if (found == m1.cend()) { 33 | m1.insert({k.opId(), v}); 34 | } else { 35 | found->second += v; 36 | } 37 | } 38 | return m1; 39 | } 40 | 41 | } // namespace util 42 | } // namespace multiout 43 | } // namespace common 44 | } // namespace poprithms 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/compute/host/regionutil.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_COMPUTE_HOST_REGIONUTIL_HPP 3 | #define POPRITHMS_COMPUTE_HOST_REGIONUTIL_HPP 4 | 5 | #include 6 | #include 7 | 8 | namespace poprithms { 9 | namespace compute { 10 | namespace host { 11 | 12 | /** 13 | * Transformations of tensors which involve a nest::Region. 14 | * 15 | * Design note: not making these Tensor member functions, as the Tensor class 16 | * is already large and tries to match the numpy ndarray API where possible. 17 | * */ 18 | class RegionUtil { 19 | 20 | public: 21 | /** 22 | * \return true if all elements of the tensor #t in the region #r are zero. 23 | * */ 24 | static bool allZero(const Tensor &t, const memory::nest::Region &r); 25 | }; 26 | 27 | } // namespace host 28 | } // namespace compute 29 | } // namespace poprithms 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/memory/alias/logging.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_MEMORY_ALIAS_LOGGING_HPP 3 | #define POPRITHMS_MEMORY_ALIAS_LOGGING_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace memory { 9 | namespace alias { 10 | 11 | poprithms::logging::Logger &log(); 12 | 13 | } // namespace alias 14 | } // namespace memory 15 | } // namespace poprithms 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/memory/alias/usings.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_MEMORY_ALIAS_ALIASUSINGS_HPP 3 | #define POPRITHMS_MEMORY_ALIAS_ALIASUSINGS_HPP 4 | 5 | #include 6 | 7 | #include 8 | 9 | namespace poprithms { 10 | namespace memory { 11 | namespace alias { 12 | 13 | using InIndex = poprithms::util::TypedInteger<'i', uint64_t>; 14 | using OutIndex = poprithms::util::TypedInteger<'o', uint64_t>; 15 | using AllocId = poprithms::util::TypedInteger<'a', uint32_t>; 16 | using Color = poprithms::util::TypedInteger<'c', uint32_t>; 17 | using Colors = std::vector; 18 | using TensorId = poprithms::util::TypedInteger<'t', uint32_t>; 19 | using TensorIds = std::vector; 20 | 21 | } // namespace alias 22 | } // namespace memory 23 | } // namespace poprithms 24 | 25 | #endif 26 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/memory/chain/logging.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_MEMORY_CHAIN_LOGGING_HPP 3 | #define POPRITHMS_MEMORY_CHAIN_LOGGING_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace memory { 9 | namespace chain { 10 | 11 | poprithms::logging::Logger &log(); 12 | 13 | } // namespace chain 14 | } // namespace memory 15 | } // namespace poprithms 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/memory/inplace/color.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_MEMORY_INPLACE_COLOR_HPP 3 | #define POPRITHMS_MEMORY_INPLACE_COLOR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace memory { 9 | namespace inplace { 10 | 11 | static const alias::Color ConstantColor = 0; 12 | static const alias::Color VariableColor = 1; 13 | 14 | } // namespace inplace 15 | } // namespace memory 16 | } // namespace poprithms 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/memory/inplace/constantpadding.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_MEMORY_INPLACE_CONSTANT_PADDING_HPP 3 | #define POPRITHMS_MEMORY_INPLACE_CONSTANT_PADDING_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace memory { 9 | namespace inplace { 10 | 11 | /// This enum class defines whether the padding Tensor(s) wrappend around a 12 | /// Tensor are Variable or Constant. see Graph::pad 13 | enum class ConstantPadding { 14 | No = 0, ///< Pad with Variable Tensor(s) 15 | Yes ///< Pad with Constant Tensor(s) 16 | }; 17 | std::ostream &operator<<(std::ostream &, ConstantPadding); 18 | 19 | } // namespace inplace 20 | } // namespace memory 21 | } // namespace poprithms 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/memory/inplace/constraint.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_MEMORY_INPLACE_CONSTRAINT_HPP 3 | #define POPRITHMS_MEMORY_INPLACE_CONSTRAINT_HPP 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | namespace poprithms { 11 | namespace memory { 12 | namespace inplace { 13 | 14 | using common::multiout::OpId; 15 | using common::multiout::OpIds; 16 | using Constraint = std::pair; 17 | using Constraints = std::vector; 18 | 19 | } // namespace inplace 20 | } // namespace memory 21 | } // namespace poprithms 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/memory/inplace/logging.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_MEMORY_INPLACE_LOGGING_HPP 3 | #define POPRITHMS_MEMORY_INPLACE_LOGGING_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace memory { 9 | namespace inplace { 10 | 11 | poprithms::logging::Logger &log(); 12 | 13 | } // namespace inplace 14 | } // namespace memory 15 | } // namespace poprithms 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/memory/inplace/padding.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_MEMORY_INPLACE_PADDING_HPP 3 | #define POPRITHMS_MEMORY_INPLACE_PADDING_HPP 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | namespace poprithms { 10 | namespace memory { 11 | namespace inplace { 12 | 13 | using LowerPadding = 14 | util::TypedVector; 15 | 16 | using UpperPadding = 17 | util::TypedVector; 18 | 19 | } // namespace inplace 20 | } // namespace memory 21 | } // namespace poprithms 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/memory/inplace/tensormap.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_MEMORY_INPLACE_TENSORMAP_HPP 3 | #define POPRITHMS_MEMORY_INPLACE_TENSORMAP_HPP 4 | 5 | #include 6 | #include 7 | 8 | namespace poprithms { 9 | namespace memory { 10 | namespace inplace { 11 | 12 | using common::multiout::TensorId; 13 | using common::multiout::TensorIds; 14 | 15 | using ToAliasGraph = std::vector>; 16 | using FromAliasGraph = TensorIds; 17 | 18 | /** Map TensorIds between 19 | * 1) poprithms::memory::inplace::Graph, and 20 | * 2) poprithms::memory::alias::Graph. 21 | * */ 22 | struct TensorMap { 23 | ToAliasGraph toAliasGraph; 24 | FromAliasGraph fromAliasGraph; 25 | void insert(const TensorId &, alias::TensorId); 26 | 27 | alias::TensorId toAliasGraphId(const TensorId &) const; 28 | std::vector toAliasGraphIds(const TensorIds &) const; 29 | 30 | TensorId fromAliasGraphId(alias::TensorId) const; 31 | TensorIds fromAliasGraphIds(const std::vector &) const; 32 | }; 33 | 34 | } // namespace inplace 35 | } // namespace memory 36 | } // namespace poprithms 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/memory/nest/logging.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_MEMORY_NEST_LOGGING_HPP 3 | #define POPRITHMS_MEMORY_NEST_LOGGING_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace memory { 9 | namespace nest { 10 | 11 | poprithms::logging::Logger &log(); 12 | 13 | } // namespace nest 14 | } // namespace memory 15 | } // namespace poprithms 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/memory/unwind/logging.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_MEMORY_INPLACE_LOGGING_HPP 3 | #define POPRITHMS_MEMORY_INPLACE_LOGGING_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace memory { 9 | namespace inplace { 10 | 11 | poprithms::logging::Logger &log(); 12 | 13 | } // namespace inplace 14 | } // namespace memory 15 | } // namespace poprithms 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/outline/linear/logging.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_OUTLINE_LINEAR_LOGGING_HPP 3 | #define POPRITHMS_OUTLINE_LINEAR_LOGGING_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace outline { 9 | namespace linear { 10 | 11 | poprithms::logging::Logger &log(); 12 | 13 | } // namespace linear 14 | } // namespace outline 15 | } // namespace poprithms 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/program/callstack/calleeindex.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_PROGRAM_CALLSTACK_CALLEEINDEX_HPP 3 | #define POPRITHMS_PROGRAM_CALLSTACK_CALLEEINDEX_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace program { 9 | namespace callstack { 10 | 11 | /** 12 | * The id of a sub-graph within an op with callees. For example, the 13 | * unique callee graph in a call op has id CalleeIndex(0). The callee graphs 14 | * in a switch op are CalleeIndex(0)...CalleeIndex(n_cases -1). 15 | * 16 | * Is it necessary to identify callees by index, why can't they just be 17 | * identified by a global sub-graph (program) id? Because an op might use a 18 | * single sub-graph in mulitple cases, with only the input/output tensors 19 | * changing. 20 | * */ 21 | using CalleeIndex = poprithms::util::TypedInteger<'C', uint32_t>; 22 | using CalleeIndices = std::vector; 23 | 24 | } // namespace callstack 25 | } // namespace program 26 | } // namespace poprithms 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/program/callstack/stackedio.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_PROGRAM_CALLSTACK_STACKEDIO_HPP 3 | #define POPRITHMS_PROGRAM_CALLSTACK_STACKEDIO_HPP 4 | 5 | namespace poprithms { 6 | namespace program { 7 | namespace callstack { 8 | 9 | enum class IsStackedCopy { No = 0, Yes }; 10 | enum class StackedCopyOrder { Up = 0, Down }; 11 | 12 | } // namespace callstack 13 | } // namespace program 14 | } // namespace poprithms 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/program/callstack/stacktensorid.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_PROGRAM_CALLSTACK_STACKTENSORID_HPP 3 | #define POPRITHMS_PROGRAM_CALLSTACK_STACKTENSORID_HPP 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | namespace poprithms { 10 | namespace program { 11 | namespace callstack { 12 | 13 | /** 14 | * A Tensor within a CallStack. 15 | * */ 16 | class StackTensorId 17 | : public util::ValuedTuple> { 18 | public: 19 | StackTensorId(const TensorId &id, const CallStack &st) 20 | : ValuedTuple({id, st}) {} 21 | TensorId tId() const { return get<0, TensorId>(); } 22 | const CallStack &callStack() const { return get<1, CallStack>(); } 23 | void append(std::ostream &) const; 24 | }; 25 | 26 | using StackTensorIds = std::vector; 27 | std::ostream &operator<<(std::ostream &, const StackTensorId &); 28 | std::ostream &operator<<(std::ostream &, const StackTensorIds &); 29 | 30 | } // namespace callstack 31 | } // namespace program 32 | } // namespace poprithms 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/program/callstack/stackutil.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_PROGRAM_CALLSTACK_STACKUTIL_HPP 3 | #define POPRITHMS_PROGRAM_CALLSTACK_STACKUTIL_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace program { 9 | namespace callstack { 10 | 11 | class StackUtil { 12 | public: 13 | /** 14 | * \return The number of time each TensorId appears in #stIds. 15 | * */ 16 | static std::map getCounts(const StackTensorIds &stIds); 17 | 18 | /** 19 | * \return The set of TensorIds which appear in the StackTensorIds #stIds. 20 | * */ 21 | static std::set tensorIds(const StackTensorIds &stIds); 22 | 23 | /** 24 | * Create StackTensorIds by combining the TensorIds #tIds with the 25 | * CallStack #callStack. 26 | * */ 27 | static StackTensorIds inScope(const TensorIds &tIds, 28 | const CallStack &callStack); 29 | 30 | static StackTensorIds inMainScope(const TensorIds &tIds) { 31 | return inScope(tIds, CallStack({})); 32 | } 33 | }; 34 | 35 | } // namespace callstack 36 | } // namespace program 37 | } // namespace poprithms 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/program/distributed/codelocation.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_PROGRAM_DISTRIBUTED_CODELOCATION_HPP 3 | #define POPRITHMS_PROGRAM_DISTRIBUTED_CODELOCATION_HPP 4 | 5 | #include 6 | #include 7 | 8 | namespace poprithms { 9 | namespace program { 10 | namespace distributed { 11 | 12 | enum class CodeLocation { None, Ipu, Host }; 13 | std::ostream &operator<<(std::ostream &, CodeLocation); 14 | 15 | } // namespace distributed 16 | } // namespace program 17 | } // namespace poprithms 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/schedule/shift/ischedulecache.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_SCHEDULE_SHIFT_ISCHEDULECACHE_HPP 3 | #define POPRITHMS_SCHEDULE_SHIFT_ISCHEDULECACHE_HPP 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | namespace poprithms { 13 | namespace schedule { 14 | namespace shift { 15 | 16 | class ScheduledGraph; 17 | 18 | /** 19 | * Abstract base class for reading and writing solutions (schedules). 20 | * */ 21 | class IScheduleCache { 22 | 23 | public: 24 | virtual ~IScheduleCache(); 25 | IScheduleCache(); 26 | 27 | virtual std::pair> 28 | findExactStart(const Graph &g, const RotationTermination &r) const = 0; 29 | 30 | virtual void writeExactStart(Graph &&g, 31 | const RotationTermination &rt, 32 | const std::vector &soln) = 0; 33 | 34 | private: 35 | virtual void noWeakVTables(); 36 | }; 37 | 38 | } // namespace shift 39 | } // namespace schedule 40 | } // namespace poprithms 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/schedule/shift/logging.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_SCHEDULE_SHIFT_LOGGING_HPP 3 | #define POPRITHMS_SCHEDULE_SHIFT_LOGGING_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace schedule { 9 | namespace shift { 10 | 11 | poprithms::logging::Logger &log(); 12 | 13 | } // namespace shift 14 | } // namespace schedule 15 | } // namespace poprithms 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/schedule/shift/opalloc.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_SCHEDULE_SHIFT_OPALLOC_HPP 3 | #define POPRITHMS_SCHEDULE_SHIFT_OPALLOC_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace schedule { 9 | namespace shift { 10 | 11 | class OpAlloc { 12 | public: 13 | OpAlloc(OpAddress o, AllocAddress a) : op(o), alloc(a) {} 14 | OpAddress op; 15 | AllocAddress alloc; 16 | }; 17 | 18 | } // namespace shift 19 | } // namespace schedule 20 | } // namespace poprithms 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/schedule/shift/rotationalgo.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_SCHEDULE_SHIFT_ROTATIONALGO_HPP 3 | #define POPRITHMS_SCHEDULE_SHIFT_ROTATIONALGO_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace schedule { 9 | namespace shift { 10 | 11 | /// Implementations of the sum-liveness minimizing algorithm. They differ only 12 | /// in time to solution, the final schedule obtained using these is identical. 13 | /// RIPPLE is much faster. 14 | enum class RotationAlgo { 15 | SIMPLE, ///< A simple implementation, for debugging and understanding 16 | RIPPLE ///< An optimized implementation which eliminates certain redundant 17 | ///< computations. It's name derives from the way it re-uses results 18 | ///< using dynamic programming across consecutive schedule indices. 19 | }; 20 | 21 | std::ostream &operator<<(std::ostream &, RotationAlgo); 22 | 23 | } // namespace shift 24 | } // namespace schedule 25 | } // namespace poprithms 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/schedule/shift/shiftandcost.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_SCHEDULE_SHIFT_SHIFTANDCOST_HPP 3 | #define POPRITHMS_SCHEDULE_SHIFT_SHIFTANDCOST_HPP 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | namespace poprithms { 11 | namespace schedule { 12 | namespace shift { 13 | 14 | class ShiftAndCost { 15 | public: 16 | ShiftAndCost(ScheduleIndex i, AllocWeight c) : shift(i), cost(c) {} 17 | 18 | void append(std::ostream &ost) const; 19 | 20 | AllocWeight getCost() const { return cost; } 21 | ScheduleIndex getShift() const { return shift; } 22 | 23 | bool operator==(const ShiftAndCost &rhs) const { 24 | return shift == rhs.shift && cost == rhs.cost; 25 | } 26 | 27 | bool operator!=(const ShiftAndCost &rhs) const { 28 | return !(operator==(rhs)); 29 | } 30 | 31 | private: 32 | ScheduleIndex shift; 33 | AllocWeight cost; 34 | }; 35 | 36 | std::ostream &operator<<(std::ostream &ost, const ShiftAndCost &); 37 | 38 | } // namespace shift 39 | } // namespace schedule 40 | } // namespace poprithms 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/schedule/shift/shiftusings.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_SCHEDULE_SHIFT_SHIFTUSINGS 3 | #define POPRITHMS_SCHEDULE_SHIFT_SHIFTUSINGS 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace schedule { 9 | namespace shift { 10 | 11 | using AllocAddress = uint64_t; 12 | using OpAddress = uint64_t; 13 | using Fraction = double; 14 | using ScheduleIndex = int; 15 | 16 | } // namespace shift 17 | } // namespace schedule 18 | } // namespace poprithms 19 | 20 | #endif 21 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/schedule/shift/trackentry.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_SCHEDULE_SHIFT_TRACKENTRY_HPP 3 | #define POPRITHMS_SCHEDULE_SHIFT_TRACKENTRY_HPP 4 | 5 | #include 6 | #include 7 | 8 | namespace poprithms { 9 | namespace schedule { 10 | namespace shift { 11 | 12 | class TrackEntry { 13 | public: 14 | TrackEntry(ScheduleIndex a, AllocWeight b, AllocWeight c, bool d) 15 | : entryTime(a), entryWeight(b), incrWeight(c), live(d) {} 16 | 17 | TrackEntry(const TrackEntry &) = default; 18 | TrackEntry(TrackEntry &&) = default; 19 | 20 | TrackEntry &operator=(const TrackEntry &) = default; 21 | TrackEntry &operator=(TrackEntry &&) = default; 22 | 23 | // when registered 24 | ScheduleIndex entryTime; 25 | 26 | // cost when registered 27 | AllocWeight entryWeight; 28 | 29 | // amount to increment cumulative cost at each iteration 30 | AllocWeight incrWeight; 31 | 32 | bool live; 33 | }; 34 | 35 | } // namespace shift 36 | } // namespace schedule 37 | } // namespace poprithms 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/schedule/supercon/logging.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_SCHEDULE_SUPER_LOGGING_HPP 3 | #define POPRITHMS_SCHEDULE_SUPER_LOGGING_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace schedule { 9 | namespace supercon { 10 | 11 | poprithms::logging::Logger &log(); 12 | 13 | } // namespace supercon 14 | } // namespace schedule 15 | } // namespace poprithms 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/schedule/transitiveclosure/logging.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_IR_LOGGING_HPP 3 | #define POPRITHMS_IR_LOGGING_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace schedule { 9 | namespace transitiveclosure { 10 | 11 | poprithms::logging::Logger &log(); 12 | 13 | } // namespace transitiveclosure 14 | } // namespace schedule 15 | } // namespace poprithms 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/schedule/vanilla/types.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_SCHEDULE_VANILLA_TYPES_HPP 3 | #define POPRITHMS_SCHEDULE_VANILLA_TYPES_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace schedule { 9 | namespace vanilla { 10 | 11 | enum class ErrorIfCycle { 12 | No = 0, ///< Do not error if there is a cycle, but return the partial 13 | ///< schedule of whatever could be scheduled. 14 | Yes ///< Throw an error if there is a cycle. 15 | }; 16 | 17 | enum class VerifyEdges { 18 | No = 0, ///< Do no checks that edges are valid 19 | Yes ///< Check that edges are valid. In particular, check that all edges 20 | ///< terminate at valid nodes. 21 | }; 22 | 23 | template using Edges = std::vector>; 24 | 25 | } // namespace vanilla 26 | } // namespace schedule 27 | } // namespace poprithms 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/util/hashcombine.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_UTIL_HASHCOMBINE_HPP 3 | #define POPRITHMS_UTIL_HASHCOMBINE_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace util { 9 | 10 | /** 11 | * Merge the hash of #v into the (running) hash value, #seed. 12 | * */ 13 | template inline void hash_combine(std::size_t &seed, const T &v) { 14 | // 2^32 / phi = 0x9e3779b9 for the curious. Chosen as a random sequence of 15 | // bits by someone, now everyone (eg boost) seems to use it. 16 | // [from stackoverflow question 4948780] 17 | std::hash hasher_; 18 | seed ^= hasher_(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2); 19 | } 20 | 21 | } // namespace util 22 | } // namespace poprithms 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/util/map.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_UTIL_MAP_HPP 3 | #define POPRITHMS_UTIL_MAP_HPP 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | namespace poprithms { 11 | namespace util { 12 | 13 | /** 14 | * \return a vector of Values. The vector is of the same size as the 15 | * iterable container, #keys, and contains values from the Map #m. 16 | * Specifically, if #values is the returned vector, then 17 | * values[i] = m[keys[i]]. 18 | * */ 19 | template 20 | std::vector getValues(const Keys &keys, Map &&m) { 21 | std::vector vals; 22 | vals.reserve(keys.size()); 23 | for (const auto &k : keys) { 24 | const auto found = m.find(k); 25 | if (found == m.cend()) { 26 | std::ostringstream oss; 27 | oss << "Failed in getValues with Keys=" << keys << ". Did not find key " 28 | << k << " in the Map 'm' of size " << m.size(); 29 | throw poprithms::error::error("util", oss.str()); 30 | } 31 | vals.push_back(found->second); 32 | } 33 | return vals; 34 | } 35 | 36 | } // namespace util 37 | } // namespace poprithms 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/util/printiter.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_UTIL_PRINTITER_HPP 3 | #define POPRITHMS_UTIL_PRINTITER_HPP 4 | 5 | #include 6 | #include 7 | 8 | namespace poprithms { 9 | namespace util { 10 | 11 | // If t = {1,2,4,5}, appends "(1,2,4,5)" to os. 12 | template void append(std::ostream &os, const std::vector &t) { 13 | os << '('; 14 | if (t.size() > 0) { 15 | // note that std::cbegin is only introduced in C++14, so using std::begin 16 | // to ensure C++11 API. 17 | auto t0 = std::begin(t); 18 | os << *t0; 19 | ++t0; 20 | while (t0 != std::end(t)) { 21 | os << ',' << *t0; 22 | ++t0; 23 | } 24 | } 25 | os << ')'; 26 | } 27 | 28 | template std::string getStr(const std::vector &X) { 29 | std::ostringstream ost; 30 | append(ost, X); 31 | return ost.str(); 32 | } 33 | 34 | extern template void append<>(std::ostream &, const std::vector &); 35 | extern template void append<>(std::ostream &, const std::vector &); 36 | extern template void append<>(std::ostream &, const std::vector &); 37 | extern template void append<>(std::ostream &, 38 | const std::vector &); 39 | } // namespace util 40 | } // namespace poprithms 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /poprithms/poprithms/include/poprithms/util/unisort.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_UTIL_UNISORT_HPP 3 | #define POPRITHMS_UTIL_UNISORT_HPP 4 | 5 | #include 6 | #include 7 | 8 | namespace poprithms { 9 | namespace util { 10 | 11 | template std::vector unisorted(const std::vector &x) { 12 | std::vector y = x; 13 | std::sort(y.begin(), y.end()); 14 | auto last = std::unique(y.begin(), y.end()); 15 | y.erase(last, y.cend()); 16 | return y; 17 | } 18 | 19 | } // namespace util 20 | } // namespace poprithms 21 | 22 | #endif 23 | -------------------------------------------------------------------------------- /poprithms/poprithms/poprithms-config.cmake: -------------------------------------------------------------------------------- 1 | include(CMakeFindDependencyMacro) 2 | 3 | get_filename_component(poprithms_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) 4 | 5 | if (NOT TARGET poprithms) 6 | include("${poprithms_CMAKE_DIR}/poprithms-targets.cmake") 7 | endif() 8 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/autodiff/autodiff/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | namespace poprithms { 5 | namespace autodiff { 6 | 7 | poprithms::error::error error(const std::string &what) { 8 | static const std::string name("autodiff"); 9 | return poprithms::error::error(name, what); 10 | } 11 | 12 | } // namespace autodiff 13 | } // namespace poprithms 14 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/autodiff/autodiff/error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_AUTODIFF_AUTODIFF_ERROR_HPP 3 | #define POPRITHMS_AUTODIFF_AUTODIFF_ERROR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace autodiff { 9 | 10 | poprithms::error::error error(const std::string &what); 11 | 12 | } 13 | } // namespace poprithms 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/autodiff/core/summary.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | 3 | #include 4 | 5 | namespace poprithms { 6 | namespace autodiff { 7 | namespace core { 8 | 9 | TensorIds Summary::allTensorIds() const { 10 | TensorIds x = gradsIn_; 11 | x.insert(x.end(), checkpointsIn_.cbegin(), checkpointsIn_.cend()); 12 | x.insert(x.end(), targetGrads_.cbegin(), targetGrads_.cend()); 13 | return x; 14 | } 15 | 16 | } // namespace core 17 | 18 | } // namespace autodiff 19 | } // namespace poprithms 20 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/autodiff/guide/graphinfo.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | 3 | #include 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace autodiff { 9 | namespace guide { 10 | 11 | TensorId GraphInfo::inTensorId(const OpTraversal &ot) const { 12 | return inTensorId(ot.opId(), ot.inIndex()); 13 | } 14 | 15 | bool GraphInfo::gradientPropagates(const TensorId &id) const { 16 | for (uint64_t i = 0; i < nInTensors(id.opId()); ++i) { 17 | if (gradientPropagates( 18 | OpTraversal{InIndex(i), id.opId(), id.outIndex()})) { 19 | return true; 20 | } 21 | } 22 | return false; 23 | } 24 | 25 | TensorIds GraphInfo::outTensorIds(OpId opId) const { 26 | TensorIds outIds; 27 | const auto nOuts = nOutTensors(opId); 28 | outIds.reserve(nOuts); 29 | for (uint64_t o = 0; o < nOuts; ++o) { 30 | outIds.push_back({opId, o}); 31 | } 32 | return outIds; 33 | } 34 | 35 | void GraphInfo::noWeakVTables() { 36 | throw error(error::error::weakVTableMessage()); 37 | } 38 | 39 | } // namespace guide 40 | } // namespace autodiff 41 | } // namespace poprithms 42 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/coloring/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | namespace poprithms { 5 | namespace coloring { 6 | 7 | namespace { 8 | constexpr const char *const nspace("coloring"); 9 | } 10 | 11 | poprithms::error::error error(const std::string &what) { 12 | return poprithms::error::error(nspace, what); 13 | } 14 | 15 | poprithms::error::error error(error::Code code, const std::string &what) { 16 | return poprithms::error::error(nspace, code, what); 17 | } 18 | 19 | } // namespace coloring 20 | } // namespace poprithms 21 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/coloring/error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_COLORING_ERROR_HPP 3 | #define POPRITHMS_COLORING_ERROR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace coloring { 9 | 10 | poprithms::error::error error(const std::string &what); 11 | poprithms::error::error error(error::Code code, const std::string &what); 12 | 13 | } // namespace coloring 14 | } // namespace poprithms 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/common/CMakeLists.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/graphcore/poprithms/7396145c967e913ff7c538656f75b3305ebfe350/poprithms/poprithms/src/poprithms/common/CMakeLists.txt -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/common/compute/devicetype.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | 3 | #include 4 | #include 5 | 6 | namespace poprithms { 7 | namespace common { 8 | namespace compute { 9 | 10 | std::ostream &operator<<(std::ostream &ost, DeviceType dt) { 11 | switch (dt) { 12 | case DeviceType::Remote: { 13 | ost << "Remote"; 14 | break; 15 | } 16 | 17 | case DeviceType::Host: { 18 | ost << "Host"; 19 | break; 20 | } 21 | 22 | case DeviceType::Ipu: { 23 | ost << "Ipu"; 24 | break; 25 | } 26 | } 27 | 28 | return ost; 29 | } 30 | 31 | std::ostream &operator<<(std::ostream &oss, const DeviceTypes &dts) { 32 | poprithms::util::append(oss, dts); 33 | return oss; 34 | } 35 | 36 | } // namespace compute 37 | } // namespace common 38 | } // namespace poprithms 39 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/common/compute/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | 3 | #include 4 | 5 | namespace poprithms { 6 | namespace common { 7 | namespace compute { 8 | 9 | namespace { 10 | constexpr const char *const nspace("common::compute"); 11 | } 12 | 13 | poprithms::error::error error(const std::string &what) { 14 | return poprithms::error::error(nspace, what); 15 | } 16 | 17 | poprithms::error::error error(error::Code code, const std::string &what) { 18 | return poprithms::error::error(nspace, code, what); 19 | } 20 | 21 | } // namespace compute 22 | } // namespace common 23 | } // namespace poprithms 24 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/common/compute/error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_COMMON_COMPUTE_ERROR_HPP 3 | #define POPRITHMS_COMMON_COMPUTE_ERROR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace common { 9 | namespace compute { 10 | 11 | poprithms::error::error error(const std::string &what); 12 | poprithms::error::error error(error::Code code, const std::string &what); 13 | 14 | } // namespace compute 15 | } // namespace common 16 | } // namespace poprithms 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/common/compute/ops/ops.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | // This file is a collection of implementations of ops which do not have much 11 | // code to implement. This prevents multiple very small translation units 12 | // which can adversely effect compile time. 13 | namespace poprithms { 14 | namespace common { 15 | namespace compute { 16 | 17 | /** 18 | * 19 | * Nop 20 | * */ 21 | UpOp Nop::cloneWithState(const State &s) const { 22 | return std::make_unique(s); 23 | } 24 | 25 | } // namespace compute 26 | } // namespace common 27 | } // namespace poprithms 28 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/common/multiout/consumptionid.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace poprithms { 9 | namespace common { 10 | namespace multiout { 11 | 12 | void ConsumptionId::append(std::ostream &ost) const { 13 | ost << "(op=" << opId() << ",in=" << inIndex() << ')'; 14 | } 15 | 16 | std::string ConsumptionId::str() const { 17 | std::ostringstream oss; 18 | oss << *this; 19 | return oss.str(); 20 | } 21 | 22 | std::ostream &operator<<(std::ostream &ost, const ConsumptionId &c) { 23 | c.append(ost); 24 | return ost; 25 | } 26 | 27 | std::ostream &operator<<(std::ostream &ost, 28 | const ConsumptionIds &consumptionIds) { 29 | util::append(ost, consumptionIds); 30 | return ost; 31 | } 32 | 33 | } // namespace multiout 34 | } // namespace common 35 | } // namespace poprithms 36 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/common/multiout/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | namespace poprithms { 5 | namespace common { 6 | namespace multiout { 7 | 8 | namespace { 9 | constexpr const char *const nspace("common::multiout"); 10 | } 11 | 12 | poprithms::error::error error(const std::string &what) { 13 | return poprithms::error::error(nspace, what); 14 | } 15 | 16 | poprithms::error::error error(error::Code code, const std::string &what) { 17 | return poprithms::error::error(nspace, code, what); 18 | } 19 | 20 | } // namespace multiout 21 | } // namespace common 22 | } // namespace poprithms 23 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/common/multiout/error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_COMMON_MULTIOUT_ERROR_HPP 3 | #define POPRITHMS_COMMON_MULTIOUT_ERROR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace common { 9 | namespace multiout { 10 | 11 | poprithms::error::error error(const std::string &what); 12 | poprithms::error::error error(error::Code code, const std::string &what); 13 | 14 | } // namespace multiout 15 | } // namespace common 16 | } // namespace poprithms 17 | 18 | #endif -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/common/multiout/logging.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | #include 4 | 5 | namespace poprithms { 6 | namespace common { 7 | namespace multiout { 8 | 9 | poprithms::logging::Logger &log() { 10 | static poprithms::logging::Logger logger("common::multiout"); 11 | return logger; 12 | } 13 | 14 | } // namespace multiout 15 | } // namespace common 16 | } // namespace poprithms 17 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/common/multiout/opid.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | 8 | namespace poprithms { 9 | namespace common { 10 | namespace multiout { 11 | 12 | std::ostream &operator<<(std::ostream &ost, const OpIds &opIds) { 13 | poprithms::util::append(ost, opIds); 14 | return ost; 15 | } 16 | 17 | } // namespace multiout 18 | } // namespace common 19 | } // namespace poprithms 20 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/common/multiout/optionaltensorid.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | namespace poprithms { 8 | namespace common { 9 | namespace multiout { 10 | 11 | const TensorId &OptionalTensorId::value() const { 12 | if (!has_value()) { 13 | throw error( 14 | "Invalid call to OptionalTensorId::value(). has_value() is false."); 15 | } 16 | return id; 17 | } 18 | 19 | void OptionalTensorId::append(std::ostream &ost) const { 20 | if (has_value()) { 21 | ost << id; 22 | } else { 23 | ost << "none"; 24 | } 25 | } 26 | 27 | std::ostream &operator<<(std::ostream &ost, const OptionalTensorId &ot) { 28 | ot.append(ost); 29 | return ost; 30 | } 31 | 32 | std::ostream &operator<<(std::ostream &ost, const OptionalTensorIds &ids) { 33 | util::append(ost, ids); 34 | return ost; 35 | } 36 | 37 | std::vector 38 | OptionalTensorId::fromTensorIds(const TensorIds &tIds) { 39 | std::vector otIds; 40 | otIds.reserve(tIds.size()); 41 | for (const auto &tId : tIds) { 42 | otIds.push_back(tId); 43 | } 44 | return otIds; 45 | } 46 | 47 | } // namespace multiout 48 | } // namespace common 49 | } // namespace poprithms 50 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/common/multiout/optraversal.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | #include 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | namespace poprithms { 10 | namespace common { 11 | namespace multiout { 12 | 13 | std::ostream &operator<<(std::ostream &ost, const OpTraversal &id) { 14 | id.append(ost); 15 | return ost; 16 | } 17 | std::string OpTraversal::str() const { 18 | std::ostringstream oss; 19 | oss << *this; 20 | return oss.str(); 21 | } 22 | std::ostream &operator<<(std::ostream &ost, const OpTraversals &ids) { 23 | util::append(ost, ids); 24 | return ost; 25 | } 26 | void OpTraversal::append(std::ostream &ost) const { 27 | ost << '('; 28 | ost << "in=" << inIndex() << ','; 29 | ost << "op=" << opId(); 30 | ost << ",out=" << outIndex(); 31 | ost << ')'; 32 | } 33 | 34 | } // namespace multiout 35 | } // namespace common 36 | } // namespace poprithms 37 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/common/schedulable/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | namespace poprithms { 5 | namespace common { 6 | namespace schedulable { 7 | 8 | namespace { 9 | constexpr const char *const nspace("common::schedulable"); 10 | } 11 | 12 | poprithms::error::error error(const std::string &what) { 13 | return poprithms::error::error(nspace, what); 14 | } 15 | 16 | poprithms::error::error error(error::Code code, const std::string &what) { 17 | return poprithms::error::error(nspace, code, what); 18 | } 19 | 20 | } // namespace schedulable 21 | } // namespace common 22 | } // namespace poprithms 23 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/common/schedulable/error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_COMMON_SCHEDULABLE_ERROR_HPP 3 | #define POPRITHMS_COMMON_SCHEDULABLE_ERROR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace common { 9 | namespace schedulable { 10 | 11 | poprithms::error::error error(const std::string &what); 12 | poprithms::error::error error(error::Code code, const std::string &what); 13 | 14 | } // namespace schedulable 15 | } // namespace common 16 | } // namespace poprithms 17 | 18 | #endif -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/common/schedulable/subgraphid.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | 3 | #include 4 | #include 5 | 6 | namespace poprithms { 7 | namespace common { 8 | namespace schedulable { 9 | 10 | std::ostream &operator<<(std::ostream &ost, const SubGraphIds &ids) { 11 | util::append(ost, ids); 12 | return ost; 13 | } 14 | std::ostream &operator<<(std::ostream &ost, const SubGraphId &id) { 15 | ost << id.get_u32(); 16 | return ost; 17 | } 18 | 19 | } // namespace schedulable 20 | } // namespace common 21 | } // namespace poprithms 22 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/compute/host/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | namespace poprithms { 5 | namespace compute { 6 | namespace host { 7 | 8 | namespace { 9 | constexpr const char *const nspace("compute::host"); 10 | } 11 | 12 | poprithms::error::error error(const std::string &what) { 13 | return poprithms::error::error(nspace, what); 14 | } 15 | 16 | poprithms::error::error error(error::Code code, const std::string &what) { 17 | return poprithms::error::error(nspace, code, what); 18 | } 19 | 20 | } // namespace host 21 | } // namespace compute 22 | } // namespace poprithms 23 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/compute/host/error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_COMPUTE_HOST_ERROR_HPP 3 | #define POPRITHMS_COMPUTE_HOST_ERROR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace compute { 9 | namespace host { 10 | 11 | poprithms::error::error error(const std::string &what); 12 | poprithms::error::error error(error::Code code, const std::string &what); 13 | 14 | } // namespace host 15 | } // namespace compute 16 | } // namespace poprithms 17 | 18 | #endif -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/compute/host/origindata.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | #include 4 | 5 | namespace poprithms { 6 | namespace compute { 7 | namespace host { 8 | 9 | std::vector OriginDataHelper::getIota_i64(uint64_t N) { 10 | std::vector iotic(N); 11 | std::iota(iotic.begin(), iotic.end(), 0); 12 | return iotic; 13 | } 14 | 15 | void OriginDataHelper::assertSameBinaryOpNelms(uint64_t n0, 16 | uint64_t n1, 17 | const BaseData &td) { 18 | if (n0 != n1) { 19 | std::ostringstream oss; 20 | oss << "Failure in assertSameBinaryOpNelms: " << n0 << " != " << n1 21 | << " for " << td; 22 | throw error(oss.str()); 23 | } 24 | } 25 | 26 | std::vector OriginDataHelper::float16ToUint16( 27 | const std::vector &asIeeeFloat16) { 28 | const auto N = asIeeeFloat16.size(); 29 | std::vector asUint16s; 30 | asUint16s.reserve(N); 31 | for (uint64_t i = 0; i < N; ++i) { 32 | asUint16s.push_back(asIeeeFloat16[i].bit16()); 33 | } 34 | return asUint16s; 35 | } 36 | 37 | } // namespace host 38 | } // namespace compute 39 | } // namespace poprithms 40 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/compute/host/regionutil.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #include 3 | #include 4 | 5 | namespace poprithms { 6 | namespace compute { 7 | namespace host { 8 | 9 | bool RegionUtil::allZero(const poprithms::compute::host::Tensor &t, 10 | const poprithms::memory::nest::Region &r) { 11 | return TensorMapper::settSample(t, r).allZero(); 12 | } 13 | 14 | } // namespace host 15 | } // namespace compute 16 | } // namespace poprithms 17 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/compute/host/types/bool.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | namespace poprithms { 10 | namespace compute { 11 | namespace host { 12 | 13 | template class ViewChange; 14 | template class TypedData; 15 | template class ViewData; 16 | template class OriginData; 17 | template class AllocData; 18 | template class PointerData; 19 | template BaseDataSP 20 | TypedConcat::go(const ConstDataPtrs &, const Shapes &, uint64_t); 21 | template BaseDataSP 22 | TypedConcat_::go(const ConstDataPtrs &, const Shapes &, uint64_t); 23 | 24 | } // namespace host 25 | } // namespace compute 26 | } // namespace poprithms 27 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/logging/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | namespace poprithms { 5 | namespace logging { 6 | 7 | namespace { 8 | constexpr const char *const nspace("logging"); 9 | } 10 | 11 | poprithms::error::error error(const std::string &what) { 12 | return poprithms::error::error(nspace, what); 13 | } 14 | 15 | poprithms::error::error error(error::Code code, const std::string &what) { 16 | return poprithms::error::error(nspace, code, what); 17 | } 18 | 19 | } // namespace logging 20 | } // namespace poprithms 21 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/logging/error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_LOGGING_ERROR_HPP 3 | #define POPRITHMS_LOGGING_ERROR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace logging { 9 | 10 | poprithms::error::error error(const std::string &what); 11 | poprithms::error::error error(error::Code code, const std::string &what); 12 | 13 | } // namespace logging 14 | } // namespace poprithms 15 | 16 | #endif -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/memory/alias/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | namespace poprithms { 5 | namespace memory { 6 | namespace alias { 7 | 8 | namespace { 9 | constexpr const char *const nspace("memory::alias"); 10 | } 11 | 12 | poprithms::error::error error(const std::string &what) { 13 | return poprithms::error::error(nspace, what); 14 | } 15 | 16 | poprithms::error::error error(error::Code code, const std::string &what) { 17 | return poprithms::error::error(nspace, code, what); 18 | } 19 | 20 | } // namespace alias 21 | } // namespace memory 22 | } // namespace poprithms 23 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/memory/alias/error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_MEMORY_ALIAS_ERROR_HPP 3 | #define POPRITHMS_MEMORY_ALIAS_ERROR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace memory { 9 | namespace alias { 10 | 11 | poprithms::error::error error(const std::string &what); 12 | poprithms::error::error error(error::Code code, const std::string &what); 13 | 14 | } // namespace alias 15 | } // namespace memory 16 | } // namespace poprithms 17 | 18 | #endif -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/memory/alias/logging.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Graphcore Ltd. All rights reserved. 2 | #include 3 | #include 4 | 5 | namespace poprithms { 6 | namespace memory { 7 | namespace alias { 8 | 9 | poprithms::logging::Logger &log() { 10 | static poprithms::logging::Logger logger("memory::alias"); 11 | return logger; 12 | } 13 | 14 | } // namespace alias 15 | } // namespace memory 16 | } // namespace poprithms 17 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/memory/chain/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | namespace poprithms { 5 | namespace memory { 6 | namespace chain { 7 | 8 | namespace { 9 | constexpr const char *const nspace("memory::chain"); 10 | } 11 | 12 | poprithms::error::error error(const std::string &what) { 13 | return poprithms::error::error(nspace, what); 14 | } 15 | 16 | poprithms::error::error error(error::Code code, const std::string &what) { 17 | return poprithms::error::error(nspace, code, what); 18 | } 19 | 20 | } // namespace chain 21 | } // namespace memory 22 | } // namespace poprithms 23 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/memory/chain/error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_MEMORY_CHAIN_ERROR_HPP 3 | #define POPRITHMS_MEMORY_CHAIN_ERROR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace memory { 9 | namespace chain { 10 | 11 | poprithms::error::error error(const std::string &what); 12 | poprithms::error::error error(error::Code code, const std::string &what); 13 | 14 | } // namespace chain 15 | } // namespace memory 16 | } // namespace poprithms 17 | 18 | #endif -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/memory/chain/logging.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | #include 4 | 5 | namespace poprithms { 6 | namespace memory { 7 | namespace chain { 8 | 9 | poprithms::logging::Logger &log() { 10 | static poprithms::logging::Logger logger("memory::chain"); 11 | return logger; 12 | } 13 | 14 | } // namespace chain 15 | } // namespace memory 16 | } // namespace poprithms 17 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/memory/chain/settutil.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | #include 5 | namespace poprithms { 6 | namespace memory { 7 | namespace chain { 8 | 9 | void NonNativeSettSampler::assertNonZeroRank(uint64_t inRank) const { 10 | if (inRank == 0) { 11 | throw error("Rank 0 input to settSampleFinalDimenion - not permitted."); 12 | } 13 | } 14 | 15 | void NonNativeSettSampler::assertSubCalledRank(const Shape &subCalledShape, 16 | uint64_t inRank) const { 17 | if (subCalledShape.rank_u64() != inRank + 1) { 18 | std::ostringstream oss; 19 | oss << "Expected the Shape of the return " 20 | << "from recursive call to have rank " << inRank + 1 << ", not " 21 | << subCalledShape.rank_u64(); 22 | throw error(oss.str()); 23 | } 24 | } 25 | 26 | } // namespace chain 27 | } // namespace memory 28 | } // namespace poprithms 29 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/memory/inplace/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | namespace poprithms { 5 | namespace memory { 6 | namespace inplace { 7 | 8 | namespace { 9 | constexpr const char *const nspace("memory::inplace"); 10 | } 11 | 12 | poprithms::error::error error(const std::string &what) { 13 | return poprithms::error::error(nspace, what); 14 | } 15 | 16 | poprithms::error::error error(error::Code code, const std::string &what) { 17 | return poprithms::error::error(nspace, code, what); 18 | } 19 | 20 | } // namespace inplace 21 | } // namespace memory 22 | } // namespace poprithms 23 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/memory/inplace/error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_MEMORY_INPLACE_ERROR_HPP 3 | #define POPRITHMS_MEMORY_INPLACE_ERROR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace memory { 9 | namespace inplace { 10 | 11 | poprithms::error::error error(const std::string &what); 12 | poprithms::error::error error(error::Code code, const std::string &what); 13 | 14 | } // namespace inplace 15 | } // namespace memory 16 | } // namespace poprithms 17 | 18 | #endif -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/memory/inplace/logging.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Graphcore Ltd. All rights reserved. 2 | #include 3 | #include 4 | 5 | namespace poprithms { 6 | namespace memory { 7 | namespace inplace { 8 | 9 | poprithms::logging::Logger &log() { 10 | static poprithms::logging::Logger logger("memory::inplace"); 11 | return logger; 12 | } 13 | 14 | } // namespace inplace 15 | } // namespace memory 16 | } // namespace poprithms 17 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/memory/inplace/proposal.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | #include 5 | #include 6 | 7 | namespace poprithms { 8 | namespace memory { 9 | namespace inplace { 10 | 11 | void Proposal::append(std::ostream &ost) const { 12 | ost << "(id=" << aliasGateId() << ", index=" << inIndex() << ')'; 13 | } 14 | 15 | std::ostream &operator<<(std::ostream &ost, const Proposal &p) { 16 | p.append(ost); 17 | return ost; 18 | } 19 | 20 | Proposals Proposal::open0(const OpIds &ids) { 21 | Proposals ps; 22 | ps.reserve(ids.size()); 23 | for (const auto &id : ids) { 24 | ps.push_back({id, 0}); 25 | } 26 | return ps; 27 | } 28 | 29 | Proposals Proposal::open0(const TensorIds &ids) { 30 | Proposals ps; 31 | ps.reserve(ids.size()); 32 | for (const auto &id : ids) { 33 | ps.push_back({id.opId(), 0}); 34 | } 35 | return ps; 36 | } 37 | 38 | Proposal::Proposal(const Tensor &tid, InIndex index) 39 | : Proposal(tid.opId(), index) {} 40 | 41 | } // namespace inplace 42 | } // namespace memory 43 | } // namespace poprithms 44 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/memory/nest/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | namespace poprithms { 5 | namespace memory { 6 | namespace nest { 7 | 8 | namespace { 9 | constexpr const char *const nspace("memory::nest"); 10 | } 11 | 12 | poprithms::error::error error(const std::string &what) { 13 | return poprithms::error::error(nspace, what); 14 | } 15 | 16 | poprithms::error::error error(error::Code code, const std::string &what) { 17 | return poprithms::error::error(nspace, code, what); 18 | } 19 | 20 | } // namespace nest 21 | } // namespace memory 22 | } // namespace poprithms 23 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/memory/nest/error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_MEMORY_NEST_ERROR_HPP 3 | #define POPRITHMS_MEMORY_NEST_ERROR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace memory { 9 | namespace nest { 10 | 11 | poprithms::error::error error(const std::string &what); 12 | poprithms::error::error error(error::Code code, const std::string &what); 13 | 14 | } // namespace nest 15 | } // namespace memory 16 | } // namespace poprithms 17 | 18 | #endif -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/memory/nest/logging.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Graphcore Ltd. All rights reserved. 2 | #include 3 | #include 4 | 5 | namespace poprithms { 6 | namespace memory { 7 | namespace nest { 8 | 9 | poprithms::logging::Logger &log() { 10 | static poprithms::logging::Logger logger("memory::nest"); 11 | return logger; 12 | } 13 | 14 | } // namespace nest 15 | } // namespace memory 16 | } // namespace poprithms 17 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/memory/unwind/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | namespace poprithms { 5 | namespace memory { 6 | namespace unwind { 7 | 8 | namespace { 9 | constexpr const char *const nspace("memory::unwind"); 10 | } 11 | 12 | poprithms::error::error error(const std::string &what) { 13 | return poprithms::error::error(nspace, what); 14 | } 15 | 16 | poprithms::error::error error(error::Code code, const std::string &what) { 17 | return poprithms::error::error(nspace, code, what); 18 | } 19 | 20 | } // namespace unwind 21 | } // namespace memory 22 | } // namespace poprithms 23 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/memory/unwind/error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_MEMORY_UNWIND_ERROR_HPP 3 | #define POPRITHMS_MEMORY_UNWIND_ERROR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace memory { 9 | namespace unwind { 10 | 11 | poprithms::error::error error(const std::string &what); 12 | poprithms::error::error error(error::Code code, const std::string &what); 13 | 14 | } // namespace unwind 15 | } // namespace memory 16 | } // namespace poprithms 17 | 18 | #endif -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/memory/unwind/logging.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | #include 4 | 5 | namespace poprithms { 6 | namespace memory { 7 | namespace unwind { 8 | 9 | poprithms::logging::Logger &log() { 10 | static poprithms::logging::Logger logger("memory::unwind"); 11 | return logger; 12 | } 13 | 14 | } // namespace unwind 15 | } // namespace memory 16 | } // namespace poprithms 17 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/memory/unwind/lower.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | #include 5 | 6 | #include 7 | 8 | namespace poprithms { 9 | namespace memory { 10 | namespace unwind { 11 | 12 | void loweringShapeAssert(const Shape &a, 13 | const Shape &b, 14 | const std::string &ctxt) { 15 | if (a != b) { 16 | std::ostringstream oss; 17 | oss << "Failed in loweringShapeAssert with Shapes " << a << " and " << b 18 | << ". The context provided is: " << ctxt; 19 | throw error(oss.str()); 20 | } 21 | } 22 | 23 | } // namespace unwind 24 | } // namespace memory 25 | } // namespace poprithms 26 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/ndarray/broadcastsetter.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include "ndarray/error.hpp" 3 | 4 | #include 5 | 6 | namespace poprithms { 7 | namespace ndarray { 8 | 9 | void BroadcastSetter::assertSumeNumElms(uint64_t creation, uint64_t dst) { 10 | if (creation != dst) { 11 | std::ostringstream oss; 12 | oss << "The Tensor created has " << creation << " elements" 13 | << ", but the target tensor has " << dst 14 | << ". Something has gone wrong in srcToDst."; 15 | throw error(oss.str()); 16 | } 17 | } 18 | 19 | } // namespace ndarray 20 | } // namespace poprithms 21 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/ndarray/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | namespace poprithms { 5 | namespace ndarray { 6 | 7 | namespace { 8 | constexpr const char *const nspace("ndarray"); 9 | } 10 | 11 | poprithms::error::error error(const std::string &what) { 12 | return poprithms::error::error(nspace, what); 13 | } 14 | 15 | poprithms::error::error error(error::Code code, const std::string &what) { 16 | return poprithms::error::error(nspace, code, what); 17 | } 18 | 19 | } // namespace ndarray 20 | } // namespace poprithms 21 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/ndarray/error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_NDARRAY_ERROR_HPP 3 | #define POPRITHMS_NDARRAY_ERROR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace ndarray { 9 | 10 | poprithms::error::error error(const std::string &what); 11 | poprithms::error::error error(error::Code code, const std::string &what); 12 | 13 | } // namespace ndarray 14 | } // namespace poprithms 15 | 16 | #endif -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/ndarray/serializer.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_NDARRAY_SERIALIZER_HPP 3 | #define POPRITHMS_NDARRAY_SERIALIZER_HPP 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | namespace poprithms { 12 | namespace ndarray { 13 | 14 | class BoostSerializer { 15 | 16 | public: 17 | template 18 | // Serialize a Shape object 19 | static void serialize(Archive &a, ndarray::Shape &shape, uint32_t version); 20 | }; 21 | 22 | } // namespace ndarray 23 | } // namespace poprithms 24 | 25 | namespace boost { 26 | namespace serialization { 27 | 28 | using namespace poprithms; 29 | 30 | void serialize(boost::archive::text_iarchive &a, 31 | ndarray::Shape &t, 32 | const uint32_t version) { 33 | (void)version; 34 | poprithms::ndarray::BoostSerializer::serialize(a, t, version); 35 | } 36 | 37 | void serialize(boost::archive::text_oarchive &a, 38 | ndarray::Shape &t, 39 | const uint32_t version) { 40 | (void)version; 41 | poprithms::ndarray::BoostSerializer::serialize(a, t, version); 42 | } 43 | 44 | } // namespace serialization 45 | } // namespace boost 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/outline/linear/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | namespace poprithms { 5 | namespace outline { 6 | namespace linear { 7 | 8 | namespace { 9 | constexpr const char *const nspace("outline::linear"); 10 | } 11 | 12 | poprithms::error::error error(const std::string &what) { 13 | return poprithms::error::error(nspace, what); 14 | } 15 | 16 | poprithms::error::error error(error::Code code, const std::string &what) { 17 | return poprithms::error::error(nspace, code, what); 18 | } 19 | 20 | } // namespace linear 21 | } // namespace outline 22 | } // namespace poprithms 23 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/outline/linear/error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_OUTLINE_LINEAR_ERROR_HPP 3 | #define POPRITHMS_OUTLINE_LINEAR_ERROR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace outline { 9 | namespace linear { 10 | 11 | poprithms::error::error error(const std::string &what); 12 | poprithms::error::error error(error::Code code, const std::string &what); 13 | 14 | } // namespace linear 15 | } // namespace outline 16 | } // namespace poprithms 17 | 18 | #endif -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/outline/linear/linearusings.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Graphcore Ltd. All rights reserved. 2 | #include 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | 10 | namespace poprithms { 11 | namespace outline { 12 | namespace linear { 13 | 14 | std::ostream &operator<<(std::ostream &ost, DType t) { 15 | switch (t) { 16 | case DType::INT32: { 17 | ost << std::string("INT32"); 18 | break; 19 | } 20 | case DType::FLOAT32: { 21 | ost << std::string("FLOAT32"); 22 | break; 23 | } 24 | case DType::FLOAT16: { 25 | ost << std::string("FLOAT16"); 26 | break; 27 | } 28 | case DType::N: 29 | throw error("N is not a DType"); 30 | } 31 | 32 | return ost; 33 | } 34 | 35 | } // namespace linear 36 | } // namespace outline 37 | } // namespace poprithms 38 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/outline/linear/logging.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Graphcore Ltd. All rights reserved. 2 | #include 3 | #include 4 | 5 | namespace poprithms { 6 | namespace outline { 7 | namespace linear { 8 | 9 | poprithms::logging::Logger &log() { 10 | static poprithms::logging::Logger logger("outline::linear"); 11 | return logger; 12 | } 13 | 14 | } // namespace linear 15 | } // namespace outline 16 | } // namespace poprithms 17 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/outline/linear/tensor.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Graphcore Ltd. All rights reserved. 2 | #include 3 | #include 4 | 5 | namespace poprithms { 6 | namespace outline { 7 | namespace linear { 8 | 9 | void Tensor::append(std::ostream &ost) const { 10 | ost << "debugStr:" << debugStr() << " id:" << id() << " type:" << type() 11 | << " shape:("; 12 | poprithms::util::append(ost, shape()); 13 | ost << ')'; 14 | } 15 | 16 | std::ostream &operator<<(std::ostream &ost, const Tensor &t) { 17 | t.append(ost); 18 | return ost; 19 | } 20 | 21 | } // namespace linear 22 | } // namespace outline 23 | } // namespace poprithms 24 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/program/callstack/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | namespace poprithms { 5 | namespace program { 6 | namespace callstack { 7 | 8 | namespace { 9 | constexpr const char *const nspace("program::callstack"); 10 | } 11 | 12 | poprithms::error::error error(const std::string &what) { 13 | return poprithms::error::error(nspace, what); 14 | } 15 | 16 | poprithms::error::error error(error::Code code, const std::string &what) { 17 | return poprithms::error::error(nspace, code, what); 18 | } 19 | 20 | } // namespace callstack 21 | } // namespace program 22 | } // namespace poprithms 23 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/program/callstack/error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_PROGRAM_CALLSTACK_ERROR_HPP 3 | #define POPRITHMS_PROGRAM_CALLSTACK_ERROR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace program { 9 | namespace callstack { 10 | 11 | poprithms::error::error error(const std::string &what); 12 | poprithms::error::error error(error::Code code, const std::string &what); 13 | 14 | } // namespace callstack 15 | } // namespace program 16 | } // namespace poprithms 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/program/distributed/codelocation.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | 3 | #include "error.hpp" 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace program { 9 | namespace distributed { 10 | 11 | std::ostream &operator<<(std::ostream &ost, CodeLocation cl) { 12 | switch (cl) { 13 | case CodeLocation::Host: { 14 | ost << "Host"; 15 | return ost; 16 | } 17 | case CodeLocation::Ipu: { 18 | ost << "Ipu"; 19 | return ost; 20 | } 21 | case CodeLocation::None: { 22 | ost << "None"; 23 | return ost; 24 | } 25 | } 26 | 27 | throw error("unrecognised CodeLocation in operator<<"); 28 | } 29 | 30 | } // namespace distributed 31 | } // namespace program 32 | } // namespace poprithms 33 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/program/distributed/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | namespace poprithms { 5 | namespace program { 6 | namespace distributed { 7 | 8 | namespace { 9 | constexpr const char *const nspace("program::distributed"); 10 | } 11 | 12 | poprithms::error::error error(const std::string &what) { 13 | return poprithms::error::error(nspace, what); 14 | } 15 | 16 | poprithms::error::error error(error::Code code, const std::string &what) { 17 | return poprithms::error::error(nspace, code, what); 18 | } 19 | 20 | } // namespace distributed 21 | } // namespace program 22 | } // namespace poprithms 23 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/program/distributed/error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_PROGRAM_DISTRIBUTED_ERROR_HPP 3 | #define POPRITHMS_PROGRAM_DISTRIBUTED_ERROR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace program { 9 | namespace distributed { 10 | 11 | poprithms::error::error error(const std::string &what); 12 | poprithms::error::error error(error::Code code, const std::string &what); 13 | 14 | } // namespace distributed 15 | } // namespace program 16 | } // namespace poprithms 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/program/pipeline/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | namespace poprithms { 5 | namespace program { 6 | namespace pipeline { 7 | 8 | namespace { 9 | constexpr const char *const nspace("program::pipeline"); 10 | } 11 | 12 | poprithms::error::error error(const std::string &what) { 13 | return poprithms::error::error(nspace, what); 14 | } 15 | 16 | poprithms::error::error error(error::Code code, const std::string &what) { 17 | return poprithms::error::error(nspace, code, what); 18 | } 19 | 20 | } // namespace pipeline 21 | } // namespace program 22 | } // namespace poprithms 23 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/program/pipeline/error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_PROGRAM_PIPELINE_ERROR_HPP 3 | #define POPRITHMS_PROGRAM_PIPELINE_ERROR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace program { 9 | namespace pipeline { 10 | 11 | poprithms::error::error error(const std::string &what); 12 | poprithms::error::error error(error::Code code, const std::string &what); 13 | 14 | } // namespace pipeline 15 | } // namespace program 16 | } // namespace poprithms 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/program/prune/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | namespace poprithms { 5 | namespace program { 6 | namespace prune { 7 | 8 | namespace { 9 | constexpr const char *const nspace("program::prune"); 10 | } 11 | 12 | poprithms::error::error error(const std::string &what) { 13 | return poprithms::error::error(nspace, what); 14 | } 15 | 16 | poprithms::error::error error(error::Code code, const std::string &what) { 17 | return poprithms::error::error(nspace, code, what); 18 | } 19 | 20 | } // namespace prune 21 | } // namespace program 22 | } // namespace poprithms 23 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/program/prune/error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_PROGRAM_PRUNE_ERROR_HPP 3 | #define POPRITHMS_PROGRAM_PRUNE_ERROR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace program { 9 | namespace prune { 10 | 11 | poprithms::error::error error(const std::string &what); 12 | poprithms::error::error error(error::Code code, const std::string &what); 13 | 14 | } // namespace prune 15 | } // namespace program 16 | } // namespace poprithms 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/schedule/connectedcomponents/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | namespace poprithms { 5 | namespace schedule { 6 | namespace connectedcomponents { 7 | 8 | namespace { 9 | constexpr const char *const nspace("schedule::connectedcomponents"); 10 | } 11 | 12 | poprithms::error::error error(const std::string &what) { 13 | return poprithms::error::error(nspace, what); 14 | } 15 | 16 | poprithms::error::error error(error::Code code, const std::string &what) { 17 | return poprithms::error::error(nspace, code, what); 18 | } 19 | 20 | } // namespace connectedcomponents 21 | } // namespace schedule 22 | } // namespace poprithms 23 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/schedule/connectedcomponents/error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_SCHEDULE_CONNECTEDCOMPONENTS_ERROR_HPP 3 | #define POPRITHMS_SCHEDULE_CONNECTEDCOMPONENTS_ERROR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace schedule { 9 | namespace connectedcomponents { 10 | 11 | poprithms::error::error error(const std::string &what); 12 | poprithms::error::error error(error::Code code, const std::string &what); 13 | 14 | } // namespace connectedcomponents 15 | } // namespace schedule 16 | } // namespace poprithms 17 | 18 | #endif -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/schedule/dfs/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | namespace poprithms { 5 | namespace schedule { 6 | namespace dfs { 7 | 8 | namespace { 9 | constexpr const char *const nspace("schedule::dfs"); 10 | } 11 | 12 | poprithms::error::error error(const std::string &what) { 13 | return poprithms::error::error(nspace, what); 14 | } 15 | 16 | poprithms::error::error error(error::Code code, const std::string &what) { 17 | return poprithms::error::error(nspace, code, what); 18 | } 19 | 20 | } // namespace dfs 21 | } // namespace schedule 22 | } // namespace poprithms 23 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/schedule/dfs/error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_SCHEDULE_DFS_ERROR_HPP 3 | #define POPRITHMS_SCHEDULE_DFS_ERROR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace schedule { 9 | namespace dfs { 10 | 11 | poprithms::error::error error(const std::string &what); 12 | poprithms::error::error error(error::Code code, const std::string &what); 13 | 14 | } // namespace dfs 15 | } // namespace schedule 16 | } // namespace poprithms 17 | 18 | #endif -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/schedule/scc/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | namespace poprithms { 5 | namespace schedule { 6 | namespace scc { 7 | 8 | namespace { 9 | constexpr const char *const nspace("schedule::scc"); 10 | } 11 | 12 | poprithms::error::error error(const std::string &what) { 13 | return poprithms::error::error(nspace, what); 14 | } 15 | 16 | poprithms::error::error error(error::Code code, const std::string &what) { 17 | return poprithms::error::error(nspace, code, what); 18 | } 19 | 20 | } // namespace scc 21 | } // namespace schedule 22 | } // namespace poprithms 23 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/schedule/scc/error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_SCHEDULE_SCC_ERROR_HPP 3 | #define POPRITHMS_SCHEDULE_SCC_ERROR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace schedule { 9 | namespace scc { 10 | 11 | poprithms::error::error error(const std::string &what); 12 | poprithms::error::error error(error::Code code, const std::string &what); 13 | 14 | } // namespace scc 15 | } // namespace schedule 16 | } // namespace poprithms 17 | 18 | #endif -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/schedule/shift/alloc.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | 11 | namespace poprithms { 12 | namespace schedule { 13 | namespace shift { 14 | 15 | void Alloc::insertOp(OpAddress opAddress) { 16 | auto it = std::lower_bound(ops.begin(), ops.end(), opAddress); 17 | if (it == ops.end() || opAddress != *it) { 18 | ops.insert(it, opAddress); 19 | } 20 | } 21 | 22 | void Alloc::appendSerialization(std::ostream &ost) const { 23 | ost << "{\"address\":" << address << ",\"weight\":"; 24 | weight.appendSerialization(ost); 25 | ost << '}'; 26 | } 27 | 28 | std::ostream &operator<<(std::ostream &ost, const Alloc &alloc) { 29 | ost << alloc.getAddress() << " ops="; 30 | util::append(ost, alloc.getOps()); 31 | ost << " weight=" << alloc.getWeight(); 32 | return ost; 33 | } 34 | 35 | size_t Alloc::hash() const { 36 | size_t hash = 0u; 37 | boost::hash_combine(hash, getTuple()); 38 | return hash; 39 | } 40 | 41 | size_t hash_value(const Alloc &a) { return a.hash(); } 42 | 43 | } // namespace shift 44 | } // namespace schedule 45 | } // namespace poprithms 46 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/schedule/shift/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | namespace poprithms { 5 | namespace schedule { 6 | namespace shift { 7 | 8 | namespace { 9 | constexpr const char *const nspace("schedule::shift"); 10 | } 11 | 12 | poprithms::error::error error(const std::string &what) { 13 | return poprithms::error::error(nspace, what); 14 | } 15 | 16 | poprithms::error::error error(error::Code code, const std::string &what) { 17 | return poprithms::error::error(nspace, code, what); 18 | } 19 | 20 | } // namespace shift 21 | } // namespace schedule 22 | } // namespace poprithms 23 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/schedule/shift/error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_SCHEDULE_SHIFT_ERROR_HPP 3 | #define POPRITHMS_SCHEDULE_SHIFT_ERROR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace schedule { 9 | namespace shift { 10 | 11 | poprithms::error::error error(const std::string &what); 12 | poprithms::error::error error(error::Code code, const std::string &what); 13 | 14 | } // namespace shift 15 | } // namespace schedule 16 | } // namespace poprithms 17 | 18 | #endif -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/schedule/shift/graphserialization.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_SCHEDULE_SHIFT_GRAPHSERIALIZATION 3 | #define POPRITHMS_SCHEDULE_SHIFT_GRAPHSERIALIZATION 4 | 5 | #include 6 | 7 | #include 8 | 9 | namespace poprithms { 10 | namespace schedule { 11 | namespace shift { 12 | namespace serialization { 13 | 14 | Graph fromSerializationString(const std::string &serialization); 15 | 16 | } // namespace serialization 17 | } // namespace shift 18 | } // namespace schedule 19 | } // namespace poprithms 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/schedule/shift/greedykahn.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | 3 | #include 4 | #include 5 | 6 | namespace poprithms { 7 | namespace schedule { 8 | namespace shift { 9 | 10 | // We hide the implementation in a translation unit to reduce the size of the 11 | // scheduledgraph.cpp translation unit, which is by the largest in this 12 | // project. This means re-compile times are a bit quicker (this is quite a 13 | // large template to compile). 14 | std::vector 15 | greedyKahn(const vanilla::Edges &fwdEdges, 16 | const vanilla::Priorities &priorities, 17 | const vanilla::Links &links, 18 | const std::vector &sizes, 19 | const vanilla::Edges &allocsToNodes, 20 | vanilla::ErrorIfCycle eic, 21 | vanilla::VerifyEdges ve) { 22 | return poprithms::schedule::vanilla::greedy:: 23 | kahn( 24 | fwdEdges, priorities, links, sizes, allocsToNodes, eic, ve); 25 | } 26 | 27 | } // namespace shift 28 | } // namespace schedule 29 | } // namespace poprithms 30 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/schedule/shift/greedykahn.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_SCHEDULE_SHIFT_GREEDYKAHN_HPP 3 | #define POPRITHMS_SCHEDULE_SHIFT_GREEDYKAHN_HPP 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | namespace poprithms { 14 | namespace schedule { 15 | namespace shift { 16 | 17 | std::vector 18 | greedyKahn(const vanilla::Edges &fwdEdges, 19 | const vanilla::Priorities &priorities, 20 | const vanilla::Links &links, 21 | const std::vector &sizes, 22 | const vanilla::Edges &allocsToNodes, 23 | vanilla::ErrorIfCycle eic, 24 | vanilla::VerifyEdges ve); 25 | 26 | } 27 | } // namespace schedule 28 | } // namespace poprithms 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/schedule/shift/logging.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | #include 4 | 5 | namespace poprithms { 6 | namespace schedule { 7 | namespace shift { 8 | 9 | poprithms::logging::Logger &log() { 10 | static poprithms::logging::Logger logger("shift"); 11 | return logger; 12 | } 13 | 14 | } // namespace shift 15 | } // namespace schedule 16 | } // namespace poprithms 17 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/schedule/shift/shiftandcost.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | 3 | #include 4 | 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | namespace poprithms { 11 | namespace schedule { 12 | namespace shift { 13 | 14 | void ShiftAndCost::append(std::ostream &ost) const { 15 | ost << "shift:" << shift << " cost:" << cost; 16 | } 17 | 18 | std::ostream &operator<<(std::ostream &ost, const ShiftAndCost &x) { 19 | x.append(ost); 20 | return ost; 21 | } 22 | 23 | } // namespace shift 24 | } // namespace schedule 25 | } // namespace poprithms 26 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/schedule/shift/updatefromfirstfinal.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_SCHEDULE_SHIFT_UPDATEFROMFIRSTFINAL_HPP 3 | #define POPRITHMS_SCHEDULE_SHIFT_UPDATEFROMFIRSTFINAL_HPP 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | namespace poprithms { 10 | namespace schedule { 11 | namespace shift { 12 | 13 | void updateFromFirstFinal(AllocWeight &lwr, 14 | AllocWeight &upp, 15 | const AllocWeight &w, 16 | const std::tuple ff); 18 | 19 | } 20 | } // namespace schedule 21 | } // namespace poprithms 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/schedule/supercon/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | namespace poprithms { 5 | namespace schedule { 6 | namespace supercon { 7 | 8 | namespace { 9 | constexpr const char *const nspace("schedule::supercon"); 10 | } 11 | 12 | poprithms::error::error error(const std::string &what) { 13 | return poprithms::error::error(nspace, what); 14 | } 15 | 16 | poprithms::error::error error(error::Code code, const std::string &what) { 17 | return poprithms::error::error(nspace, code, what); 18 | } 19 | 20 | } // namespace supercon 21 | } // namespace schedule 22 | } // namespace poprithms 23 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/schedule/supercon/error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_SCHEDULE_SUPERCON_ERROR_HPP 3 | #define POPRITHMS_SCHEDULE_SUPERCON_ERROR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace schedule { 9 | namespace supercon { 10 | 11 | poprithms::error::error error(const std::string &what); 12 | poprithms::error::error error(error::Code code, const std::string &what); 13 | 14 | } // namespace supercon 15 | } // namespace schedule 16 | } // namespace poprithms 17 | 18 | #endif -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/schedule/supercon/logging.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Graphcore Ltd. All rights reserved. 2 | #include 3 | #include 4 | 5 | namespace poprithms { 6 | namespace schedule { 7 | namespace supercon { 8 | 9 | poprithms::logging::Logger &log() { 10 | static poprithms::logging::Logger logger("supercon"); 11 | return logger; 12 | } 13 | 14 | } // namespace supercon 15 | } // namespace schedule 16 | } // namespace poprithms 17 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/schedule/transitiveclosure/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | namespace poprithms { 5 | namespace schedule { 6 | namespace transitiveclosure { 7 | 8 | namespace { 9 | constexpr const char *const nspace("schedule::transitiveclosure"); 10 | } 11 | 12 | poprithms::error::error error(const std::string &what) { 13 | return poprithms::error::error(nspace, what); 14 | } 15 | 16 | poprithms::error::error error(error::Code code, const std::string &what) { 17 | return poprithms::error::error(nspace, code, what); 18 | } 19 | 20 | } // namespace transitiveclosure 21 | } // namespace schedule 22 | } // namespace poprithms 23 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/schedule/transitiveclosure/error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_SCHEDULE_TRANSITIVECLOSURE_ERROR_HPP 3 | #define POPRITHMS_SCHEDULE_TRANSITIVECLOSURE_ERROR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace schedule { 9 | namespace transitiveclosure { 10 | 11 | poprithms::error::error error(const std::string &what); 12 | poprithms::error::error error(error::Code code, const std::string &what); 13 | 14 | } // namespace transitiveclosure 15 | } // namespace schedule 16 | } // namespace poprithms 17 | 18 | #endif -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/schedule/transitiveclosure/logging.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Graphcore Ltd. All rights reserved. 2 | #include 3 | #include 4 | 5 | namespace poprithms { 6 | namespace schedule { 7 | namespace transitiveclosure { 8 | 9 | poprithms::logging::Logger &log() { 10 | static poprithms::logging::Logger logger("pm"); 11 | return logger; 12 | } 13 | 14 | } // namespace transitiveclosure 15 | } // namespace schedule 16 | } // namespace poprithms 17 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/schedule/vanilla/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | namespace poprithms { 5 | namespace schedule { 6 | namespace vanilla { 7 | 8 | namespace { 9 | constexpr const char *const nspace("schedule::vanilla"); 10 | } 11 | 12 | poprithms::error::error error(const std::string &what) { 13 | return poprithms::error::error(nspace, what); 14 | } 15 | 16 | poprithms::error::error error(error::Code code, const std::string &what) { 17 | return poprithms::error::error(nspace, code, what); 18 | } 19 | 20 | } // namespace vanilla 21 | } // namespace schedule 22 | } // namespace poprithms 23 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/schedule/vanilla/error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_SCHEDULE_VANILLA_ERROR_HPP 3 | #define POPRITHMS_SCHEDULE_VANILLA_ERROR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace schedule { 9 | namespace vanilla { 10 | 11 | poprithms::error::error error(const std::string &what); 12 | poprithms::error::error error(error::Code code, const std::string &what); 13 | 14 | } // namespace vanilla 15 | } // namespace schedule 16 | } // namespace poprithms 17 | 18 | #endif -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/util/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | namespace poprithms { 5 | namespace util { 6 | 7 | namespace { 8 | constexpr const char *const nspace("util"); 9 | } 10 | 11 | poprithms::error::error error(const std::string &what) { 12 | return poprithms::error::error(nspace, what); 13 | } 14 | 15 | poprithms::error::error error(error::Code code, const std::string &what) { 16 | return poprithms::error::error(nspace, code, what); 17 | } 18 | 19 | } // namespace util 20 | } // namespace poprithms 21 | -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/util/error.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2021 Graphcore Ltd. All rights reserved. 2 | #ifndef POPRITHMS_UTIL_ERROR_HPP 3 | #define POPRITHMS_UTIL_ERROR_HPP 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace util { 9 | 10 | poprithms::error::error error(const std::string &what); 11 | poprithms::error::error error(error::Code code, const std::string &what); 12 | 13 | } // namespace util 14 | } // namespace poprithms 15 | 16 | #endif -------------------------------------------------------------------------------- /poprithms/poprithms/src/poprithms/util/printiter.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2020 Graphcore Ltd. All rights reserved. 2 | #include 3 | #include 4 | 5 | #include 6 | 7 | namespace poprithms { 8 | namespace util { 9 | 10 | template void append<>(std::ostream &, const std::vector &); 11 | template void append<>(std::ostream &, const std::vector &); 12 | template void append<>(std::ostream &, const std::vector &); 13 | template void append<>(std::ostream &, const std::vector &); 14 | 15 | } // namespace util 16 | } // namespace poprithms 17 | -------------------------------------------------------------------------------- /poprithms/tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(testutil) 2 | 3 | add_subdirectory(tests) 4 | 5 | add_subdirectory(regression) 6 | 7 | -------------------------------------------------------------------------------- /poprithms/tests/googletests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include(EnableCompilerWarnings) 2 | 3 | add_subdirectory(example) 4 | add_subdirectory(autodiff) 5 | add_subdirectory(common) 6 | -------------------------------------------------------------------------------- /poprithms/tests/googletests/autodiff/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(automatic) 2 | -------------------------------------------------------------------------------- /poprithms/tests/googletests/autodiff/automatic/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | find_package(GTest REQUIRED CONFIG) 3 | 4 | include(GoogleTest) 5 | function(add_gtest name source) 6 | add_executable(${name} ${source}) 7 | target_link_libraries( 8 | ${name} 9 | poprithms-autodiff 10 | GTest::gtest 11 | GTest::gmock 12 | GTest::gtest_main) 13 | add_test(${name} ${name}) 14 | target_include_directories(${name} PRIVATE ${POPRITHMS_MOCKS_DIR}/include) 15 | 16 | endfunction() 17 | 18 | add_gtest(autodiff_automatic_gradinfos_0 gradinfos_0.cpp) 19 | 20 | 21 | -------------------------------------------------------------------------------- /poprithms/tests/googletests/autodiff/automatic/gradinfos_0.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #include 3 | 4 | #include 5 | 6 | using ::testing::AtLeast; 7 | TEST(AutodiffAutomatic, GradInfos0) { 8 | using namespace poprithms::autodiff::automatic; 9 | GradInfos gInfos; 10 | EXPECT_THROW(gInfos.grad(OpId(0), 0), poprithms::error::error) 11 | << "No Ops have grads set"; 12 | 13 | EXPECT_THROW(gInfos.at(SubGraphId::createSubGraphId(0)), 14 | poprithms::error::error) 15 | << "No sub-graph 0"; 16 | } 17 | -------------------------------------------------------------------------------- /poprithms/tests/googletests/common/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(compute) 2 | -------------------------------------------------------------------------------- /poprithms/tests/googletests/common/compute/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(GTest REQUIRED CONFIG) 2 | 3 | include(GoogleTest) 4 | function(add_gtest name source) 5 | add_executable(${name} ${source}) 6 | target_link_libraries( 7 | ${name} 8 | # link to the whole of poprithms (common::compute will probably use most of 9 | # poprithms, so no advantage to linking to the subset used like done in other 10 | # projects): 11 | poprithms 12 | GTest::gtest 13 | GTest::gmock 14 | GTest::gtest_main) 15 | # Note that this is not needed as the test is added with ctest 16 | # gtest_discover_tests(${name}) 17 | add_test(${name} ${name}) 18 | target_include_directories(${name} PRIVATE ${POPRITHMS_MOCKS_DIR}/include) 19 | 20 | endfunction() 21 | 22 | add_gtest(common_compute_basic_functionality_0 basic_functionality_0.cpp) 23 | add_gtest(common_compute_call_0 call_0.cpp) 24 | add_gtest(common_compute_simexecutable_0 simexecutable_0.cpp) 25 | add_gtest(common_compute_interdevicecopy_0 interdevicecopy_0.cpp) 26 | add_gtest(common_compute_train_misc_0 train_misc_0.cpp) 27 | 28 | 29 | -------------------------------------------------------------------------------- /poprithms/tests/googletests/example/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | find_package(GTest REQUIRED CONFIG) 3 | 4 | include(GoogleTest) 5 | function(add_gtest name source) 6 | add_executable(${name} ${source}) 7 | target_link_libraries( 8 | ${name} 9 | poprithms_mock 10 | poprithms 11 | GTest::gtest 12 | GTest::gmock 13 | GTest::gtest_main) 14 | add_test(${name} ${name}) 15 | target_include_directories(${name} PRIVATE ${POPRITHMS_MOCKS_DIR}/include) 16 | 17 | endfunction() 18 | 19 | add_gtest(googletest_example_0 googletest_example_0.cpp) 20 | 21 | 22 | -------------------------------------------------------------------------------- /poprithms/tests/googletests/example/googletest_example_0.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | 3 | #include 4 | #include 5 | 6 | // We're testing that we can find the directory containing the mocks, and that 7 | // we can create and run a google test with ctest. Consider removing this test 8 | // when real tests arrive. 9 | namespace { 10 | 11 | class MockTensorTester { 12 | public: 13 | static void getRank(const mock::poprithms::memory::alias::MockTensor &t) { 14 | auto x = t.shape().rank_u64(); 15 | (void)x; 16 | } 17 | }; 18 | 19 | class Marionette { 20 | public: 21 | virtual ~Marionette() = default; 22 | virtual void step() const = 0; 23 | }; 24 | 25 | class MockMarionette : public Marionette { 26 | public: 27 | MOCK_METHOD(void, step, (), (const, override)); 28 | }; 29 | 30 | class Puppeteer { 31 | public: 32 | const Marionette &f; 33 | Puppeteer(const Marionette &f_) : f(f_) {} 34 | void walk(uint64_t dst) { 35 | for (uint64_t i = 0; i < dst; ++i) { 36 | f.step(); 37 | } 38 | } 39 | }; 40 | } // namespace 41 | 42 | using ::testing::AtLeast; 43 | TEST(PuppeteerTest, Walking) { 44 | MockMarionette m; 45 | uint64_t nSteps{10}; 46 | EXPECT_CALL(m, step()).Times(AtLeast(nSteps)); 47 | Puppeteer painter(m); 48 | painter.walk(nSteps + 1); 49 | } 50 | -------------------------------------------------------------------------------- /poprithms/tests/mocks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | find_package(GTest REQUIRED CONFIG) 4 | add_subdirectory(src) 5 | -------------------------------------------------------------------------------- /poprithms/tests/mocks/include/mock/memory/alias/mockgraph.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #ifndef MOCKS_POPRITHMS_MEMORY_ALIAS_GRAPH_HPP 3 | #define MOCKS_POPRITHMS_MEMORY_ALIAS_GRAPH_HPP 4 | 5 | #include 6 | 7 | #include 8 | 9 | namespace mock::poprithms::memory::alias { 10 | 11 | class MockGraph { 12 | public: 13 | MockGraph(); 14 | virtual ~MockGraph(); 15 | 16 | MOCK_METHOD(::poprithms::memory::alias::TensorId, 17 | allocate, 18 | (::poprithms::ndarray::Shape, 19 | ::poprithms::memory::alias::Color)); 20 | MOCK_METHOD(::poprithms::memory::alias::TensorId, 21 | clone, 22 | (::poprithms::memory::alias::TensorId, 23 | ::poprithms::memory::alias::CloneColorMethod)); 24 | }; 25 | 26 | extern MockGraph *mockAliasGraph_; 27 | 28 | inline ::poprithms::memory::alias::TensorId makeTensor(std::size_t id) { 29 | return ::poprithms::memory::alias::TensorId(id); 30 | } 31 | 32 | } // namespace mock::poprithms::memory::alias 33 | #endif // MOCKS_POPRITHMS_MEMORY_ALIAS_GRAPH_HPP 34 | -------------------------------------------------------------------------------- /poprithms/tests/mocks/include/mock/memory/alias/mockgraphfixture.hpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 Graphcore Ltd. All rights reserved. 2 | #ifndef MOCKS_POPRITHMS_MEMORY_ALIAS_GRAPH_FIXTURE_HPP 3 | #define MOCKS_POPRITHMS_MEMORY_ALIAS_GRAPH_FIXTURE_HPP 4 | 5 | #include 6 | 7 | namespace mock::poprithms::memory::alias { 8 | 9 | template