Skip to content

Draft: Introduction of Tiling

Maxence Naud requested to merge tiling into main

(Optional) but should be done someday

  • Update previous recipies from return type void to std::set<std::shared_ptr<Node>>
  • Update GraphView oldNodeGraphView->replaceWith({newNodes}) member function to ``aGraphView->replace({oldNodes}, {newNodes}). Add an option to replace in every GraphView?

Essential for tiling

User interface

  • ability to specify teh size of an outputTensor from one branch (or the number of slices for each dimension)
  • Possibility to tile a Node or a set of Nodes. The size of consecutive input/output Tensors is automatically computed

backprop_receptive_field.svg

Functionalities

  • create computeReceptiveField() member function. This function is only valid for Tensor-based Operators
    • Conv
    • ReLU

Conv_receptive_field.svg

  • Implement TensorView for backends and OperatorImpls able to handle them
  • General Tiling recipie
    • Specify the type of tiling
      • Horizontal tiling
      • Vertical tiling
    • Transform the Graph
      • Add Slice Operator with right dimensions
      • Re-order slices in the right order with Concat. Two consecutive Concat for tiling both vertical and horizontal?.
      • Replace old Nodes with tiled Nodes (GraphView::replace)
    • Specify several Nodes
  • Individual Operators needed
    • Slice: to extract specific scope in memory from a Data object
    • Concat: concatenate several memory slices into one coherent Data object
flowchart LR

subgraph Tile with view on initial Tensor
    direction LR
    Tensor3((" ")) --> c5("Conv 1.1") & c6("Conv 1.2") & c7("Conv 1.3") & c8("Conv 1.4")

    c5 --> r1(ReLU 2.1)
    c6 --> r2(ReLU 2.2)
    c7 --> r3(ReLU 2.3)
    c8 --> r4(ReLU 2.4)
    r1 & r2 & r3 & r4 --> concat2(Concat)
end

subgraph Tile with Slice
    direction LR
    Tensor1((" ")) --> s1("Slice 1") & s2("Slice 2") & s3("Slice 3") & s4("Slice 4")
    s1 --> c1(Conv 1.1)
    s2 --> c2(Conv 1.2)
    s3 --> c3(Conv 1.3)
    s4 --> c4(Conv 1.4)

    c1 --> r5(ReLU 2.1)
    c2 --> r6(ReLU 2.2)
    c3 --> r7(ReLU 2.3)
    c4 --> r8(ReLU 2.4)
    r5 & r6 & r7 & r8 --> concat1(Concat)
end

subgraph Initial
    direction LR
    Tensor2((" ")) --> Conv("Conv 1") --> ReLU("ReLU 1")
end

Expected user interface

auto g = importONNX("a/path.onnx");

for (auto& individualConv : g->match("Conv")) {
    auto tiledConv = tiling(individualConv);
    g->replace(individualConv, tiledConv);
}
Edited by Maxence Naud

Merge request reports