summaryrefslogtreecommitdiffstats
path: root/config-model/src/test/derived/tensor/tensor.sd
blob: 3a5fda3ac5d981a4dc933c6cd70d292d3ed5c4bf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
schema tensor {

  document tensor {
    field f1 type tensor(x[3]) {
      indexing: summary
    }
    field f2 type tensor<float>(x[2],y[1]) {
      indexing: attribute
    }
    field f3 type tensor<double>(x{}) {
      indexing: attribute | summary
    }
    field f4 type tensor(x[10],y[10]) {
      indexing: attribute | summary
    }
    field f5 type tensor<float>(x[10]) {
      indexing: attribute | summary
    }
    field f6 type float {
      indexing: attribute
    }
    field f7 type tensor<int8>(p{},x[5]) {
      indexing: attribute
    }
  }
  
  rank-profile profile1 {

    first-phase {
      expression: sum(map(attribute(f4),f(x)(x*x)) + reduce(random(x[2],y[3]), count) * rename(attribute(f4), (x, y), (y, x)))
    }
  
  }

  rank-profile profile2 {

    first-phase {
      expression: sum(matmul(attribute(f4), diag(x[10],y[10],z[3]), x))
    }
  
  }

  rank-profile profile3 {

    first-phase {
      expression: sum(joinedtensors())
    }

    function joinedtensors() {
        expression: tensor(i[10])(i) * attribute(f4)
    }

  }

  rank-profile profile4 {

    first-phase {
      expression: sum(attribute(f5))
    }
  
  }

  rank-profile profile5 {

    first-phase {
      expression: sum(tensor<float>(d0[1],x[2]):[[attribute(f6), sum(attribute(f5))]])
    }

  }

  rank-profile profile6 {

    first-phase {
      expression: sum(tensor<float>(d0[1],x[2]):[[attribute(f6), sum(joinedtensors())]])
    }

    function joinedtensors() {
        expression: tensor(i[10])(i) * attribute(f4)
    }

  }

  rank-profile profile7 {

    first-phase {
      expression: sum(reshaped() * literal())
    }

    function reshaped() {
      expression: tensor<float>(d0[1],x[2])(attribute(f2){x:1-x, y:d0})
    }

    function literal() {
      expression: tensor<float>(key{}):{ 'foo':0.5, bar:1.2, "han's":3.1}
    }

  }

  rank-profile profile8 {

    first-phase {
      expression: sum(tensor(d0[1])(attribute(f3){x:functionNotLabel()}))
    }

    function functionNotLabel() {
      expression: 3
    }

  }

  rank-profile profile9 {

    # shadow refers to the generate index and shadow() to the function
    first-phase {
      expression: sum(tensor(shadow[1])(attribute(f3){x: shadow + shadow() }))
    }

    function shadow() {
      expression: 3
    }

  }

  rank-profile with-unpack {
    inputs {
      query(para) tensor<float>(p{})
      query(qvec) tensor<float>(x[40])
    }
    function myunpack() {
      expression: unpack_bits(attribute(f7))
    }
    first-phase {
      expression: sum(query(para)*myunpack*query(qvec))
    }
  }

}