1ods_def<MatmulOp>: 2def matmul(A: f32(M, K), B: f32(K, N)) -> (C: f32(M, N)) { 3 C(m, n) = std_addf<k>(std_mulf(A(m, k), B(k, n))); 4} 5 6ods_def<MatvecOp>: 7def matvec(A: f32(M, N), y: f32(N)) -> (x: f32(M)) { 8 x(m) = std_addf<n>(std_mulf(A(m, n), y(n))); 9} 10 11ods_def<VecmatOp>: 12def vecmat(y: f32(M), A: f32(M, N)) -> (x: f32(N)) { 13 x(n) = std_addf<m>(std_mulf(y(m), A(m, n))); 14} 15 16ods_def<DotOp>: 17def dot(A: f32(M), B: f32(M)) -> (C: f32()) { 18 C() = std_addf<m>(std_mulf(A(m), B(m))); 19} 20 21ods_def<BatchMatmulOp>: 22def batch_matmul(A: f32(Batch, M, K), B: f32(Batch, K, N)) -> (C: f32(Batch, M, N)) { 23 C(b, m, n) = std_addf<k>(std_mulf(A(b, m, k), B(b, k, n))); 24} 25 26ods_def<ConvWOp>: 27def conv_1d(I: f32(W), K: f32(KW)) -> (O: f32(W)) { 28 O(w) = std_addf<kw>(std_mulf(I(w + kw), K(kw))); 29} 30 31ods_def<ConvNWCOp>: 32def conv_1d_nwc(I: f32(N, W, C), K: f32(F, KW, C)) -> (O: f32(N, W, F)) { 33 O(n, w, f) = std_addf<kw>(std_mulf(I(n, w + kw, c), K(f, kw, c))); 34} 35 36ods_def<ConvNCWOp>: 37def conv_1d_ncw(I: f32(N, C, W), K: f32(F, C, KW)) -> (O: f32(N, F, W)) { 38 O(n, f, w) = std_addf<kw>(std_mulf(I(n, c, w + kw), K(f, c, kw))); 39} 40 41ods_def<ConvHWOp>: 42def conv_2d(I: f32(H, W), K: f32(KH, KW)) -> (O: f32(H, W)) { 43 O(h, w) = std_addf<kh, kw>(std_mulf(I(h + kh, w + kw), K(kh, kw))); 44} 45 46ods_def<ConvNHWCOp>: 47def conv_2d_nhwc(I: f32(N, H, W, C), K: f32(F, KH, KW, C)) -> (O: f32(N, H, W, F)) { 48 O(n, h, w, f) = std_addf<kh, kw>(std_mulf( 49 I(n, h + kh, w + kw, c), K(f, kh, kw, c))); 50} 51 52ods_def<ConvNCHWOp>: 53def conv_2d_nchw(I: f32(N, C, H, W), K: f32(F, C, KH, KW)) -> (O: f32(N, F, H, W)) { 54 O(n, f, h, w) = std_addf<kh, kw>(std_mulf( 55 I(n, c, h + kh, w + kw), K(f, c, kh, kw))); 56} 57 58ods_def<ConvDHWOp>: 59def conv_3d(I: f32(D, H, W), K: f32(KD, KH, KW)) -> (O: f32(D, H, W)) { 60 O(d, h, w) = std_addf<kd, kh, kw>(std_mulf( 61 I(d + kd, h + kh, w + kw), K(kd, kh, kw))); 62} 63 64ods_def<ConvNDHWCOp>: 65def conv_3d_ndhwc(I: f32(N, D, H, W, C), K: f32(F, KD, KH, KW, C)) -> (O: f32(N, D, H, W, F)) { 66 O(n, d, h, w, f) = std_addf<kd, kh, kw>(std_mulf( 67 I(n, d + kd, h + kh, w + kw, c), K(f, kd, kh, kw, c))); 68} 69 70ods_def<ConvNCDHWOp>: 71def conv_3d_ncdhw(I: f32(N, C, D, H, W), K: f32(F, C, KD, KH, KW)) -> (O: f32(N, F, D, H, W)) { 72 O(n, f, d, h, w) = std_addf<kd, kh, kw>(std_mulf( 73 I(n, c, d + kd, h + kh, w + kw), K(f, c, kd, kh, kw))); 74} 75