Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
balancap committed Oct 11, 2023
1 parent 953e355 commit 8a74f79
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 11 deletions.
19 changes: 8 additions & 11 deletions tessellate_ipu/core/vertex/tile_hessenberg_vertex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ static constexpr size_t MIN_ALIGN = 8;
class HessenbergCorrectionVectorVertex : public MultiVertex {
public:
using T = float;
Input<Vector<T, poplar::VectorLayout::SPAN, MIN_ALIGN>> Rcol; // (N,) R column.
Input<Vector<T, poplar::VectorLayout::ONE_PTR, MIN_ALIGN>> sdiag; // (N,) R diag. sign.
Input<Vector<int, poplar::VectorLayout::ONE_PTR, MIN_ALIGN>>
cidx;
Input<Vector<T, poplar::VectorLayout::SPAN, MIN_ALIGN>>
Rcol; // (N,) R column.
Input<Vector<T, poplar::VectorLayout::ONE_PTR, MIN_ALIGN>>
sdiag; // (N,) R diag. sign.
Input<Vector<int, poplar::VectorLayout::ONE_PTR, MIN_ALIGN>> cidx;

Output<Vector<T, poplar::VectorLayout::ONE_PTR, MIN_ALIGN>>
v; // (N,) QR correction vector (not normalized)
Output<Vector<T, poplar::VectorLayout::ONE_PTR, MIN_ALIGN>>
vrescale; // (1,) QR correction vector rescaling (2 / norm)


// Use static variables as easy sync. mechanisms between worker threads.
// see: https://graphcore.slack.com/archives/C013LPHPX61/p1647443852989259
static T shared_partial_sqnorms[6];
Expand Down Expand Up @@ -142,23 +142,20 @@ class [[poplar::constraint(
scale1; // (1,) first scaling factor.
Input<Vector<T, poplar::VectorLayout::ONE_PTR, MIN_ALIGN>>
scale2; // (1,) 2nd scaling factor.
Input<Vector<int, poplar::VectorLayout::ONE_PTR, MIN_ALIGN>>
start_idx_;
Input<Vector<int, poplar::VectorLayout::ONE_PTR, MIN_ALIGN>> start_idx_;

Input<Vector<IndexType, poplar::VectorLayout::ONE_PTR, MIN_ALIGN>>
worker_offsets; // (7,) threads work size + 1.



bool compute(unsigned wid) {
// Always assuming size % 2 == 0
constexpr unsigned ptr_step = 1;
const IndexType wstart = worker_offsets[wid];
const IndexType wend = worker_offsets[wid + 1];
const IndexType wsize = wend - wstart;

IndexType start_idx = start_idx_[0]; // X start idx. Must be a multiple of 4 (for bank
// alignment aspects).
IndexType start_idx = start_idx_[0]; // X start idx. Must be a multiple of
// 4 (for bank alignment aspects).

// Set the $TAS register with the proper scale.
const T s = -scale1[0] * scale2[0];
Expand Down
43 changes: 43 additions & 0 deletions tessellate_ipu/core/vertex/tile_small_dot.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (c) 2023 Graphcore Ltd. All rights reserved.
#include "tile_small_dot.hpp"

#include <poplar/HalfFloat.hpp>
#include <poplar/Vertex.hpp>

// class [[poplar::constraint("elem(*x) != elem(*y)")]] DotProduct1dVertex
// : public MultiVertex {
class Rotation2dVertex : public MultiVertex {
public:
using T = float;
using T2 = float2;
// Using `uint16` seems to be generating more efficient loops?
using IndexType = unsigned short;

static constexpr size_t MIN_ALIGN = 8;

Input<Vector<T, poplar::VectorLayout::ONE_PTR, MIN_ALIGN>>
inrow0; // (N,) first input row vector
Input<Vector<T, poplar::VectorLayout::ONE_PTR, MIN_ALIGN>>
inrow1; // (N,) second input row vector

Input<Vector<T, poplar::VectorLayout::ONE_PTR>>
cs; // (2,) rotation cosinus/sinus values

Input<Vector<IndexType, poplar::VectorLayout::ONE_PTR>>
worker_offsets; // (7,) number threads + 1.

Output<Vector<T, poplar::VectorLayout::ONE_PTR>>
outrow0; // (N,) first input row vector
Output<Vector<T, poplar::VectorLayout::ONE_PTR>>
outrow1; // (N,) first input row vector

bool compute(unsigned wid) {
// Always assuming size % 2 == 0
const IndexType wstart = worker_offsets[wid];
const IndexType wend = worker_offsets[wid + 1];
const IndexType wsize = wend - wstart;


return true;
}
};
5 changes: 5 additions & 0 deletions tessellate_ipu/core/vertex/tile_small_dot.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Copyright (c) 2023 Graphcore Ltd. All rights reserved.
// #include <poplar/HalfFloat.hpp>
// #include <poplar/Vertex.hpp>

#include "intrinsics_utils.hpp"
1 change: 1 addition & 0 deletions tessellate_ipu/lax/tile_lax_small_dot.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
tile_map_remove_ipu_attributes,
)
from tessellate_ipu.core.tile_interpreter_vertex_utils import make_num_elements_per_worker

# from tessellate_ipu.lib.pytessellate_ipu_core import ( # noqa: F401
# IpuVertexAttributeI32,
# ipuGetTransformedInRowStride,
Expand Down

0 comments on commit 8a74f79

Please sign in to comment.