File size: 10,334 Bytes
e89a301
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
[
  {
    "function_name": "__init__",
    "file_path": "canonical.py (ARC class)",
    "function_calls": [
      {
        "function_call_name": "super",
        "functionality": "Initialize the base class for ARC, which is nn.Module.",
        "input": "ARC, self",
        "output": "None",
        "location_or_namespace": "builtins"
      },
      {
        "function_call_name": "nn.ModuleList",
        "functionality": "Container module for storing an ordered list of submodules (used for storing layers).",
        "input": "",
        "output": "ModuleList object",
        "location_or_namespace": "torch.nn"
      },
      {
        "function_call_name": "getattr",
        "functionality": "Return the named attribute of an object (used here to get activation function by name).",
        "input": "nn, activation",
        "output": "activation function",
        "location_or_namespace": "builtins"
      },
      {
        "function_call_name": "nn.Linear",
        "functionality": "Applies a linear transformation to the incoming data.",
        "input": "in_features, out_features",
        "output": "Linear layer",
        "location_or_namespace": "torch.nn"
      },
      {
        "function_call_name": "nn.Dropout",
        "functionality": "Randomly zeroes some of the elements of the input tensor with probability dropout_rate.",
        "input": "dropout_rate",
        "output": "Dropout module",
        "location_or_namespace": "torch.nn"
      },
      {
        "function_call_name": "nn.Identity",
        "functionality": "A placeholder identity operator that is argument-insensitive.",
        "input": "",
        "output": "Identity module",
        "location_or_namespace": "torch.nn"
      },
      {
        "function_call_name": "CrossAttn",
        "functionality": "",
        "input": "h_feats * num_hops",
        "output": "CrossAttn object",
        "location_or_namespace": "canonical.py"
      }
    ]
  },
  {
    "function_name": "forward",
    "file_path": "canonical.py (ARC class)",
    "function_calls": [
      {
        "function_call_name": "self.dropout",
        "functionality": "",
        "input": "x",
        "output": "Tensor after dropout or identity",
        "location_or_namespace": "canonical.py"
      },
      {
        "function_call_name": "layer",
        "functionality": "",
        "input": "x",
        "output": "Transformed tensor",
        "location_or_namespace": ""
      },
      {
        "function_call_name": "self.act",
        "functionality": "",
        "input": "x",
        "output": "Activated tensor",
        "location_or_namespace": ""
      },
      {
        "function_call_name": "torch.hstack",
        "functionality": "Stack tensors in sequence horizontally (column wise).",
        "input": "residual_list",
        "output": "Stacked tensor",
        "location_or_namespace": "torch"
      }
    ]
  },
  {
    "function_name": "__init__",
    "file_path": "canonical.py (CrossAttn class)",
    "function_calls": [
      {
        "function_call_name": "super",
        "functionality": "Initialize the base class for CrossAttn, which is nn.Module.",
        "input": "CrossAttn, self",
        "output": "None",
        "location_or_namespace": "builtins"
      },
      {
        "function_call_name": "nn.Linear",
        "functionality": "Applies a linear transformation to the incoming data.",
        "input": "embedding_dim, embedding_dim",
        "output": "Linear layer",
        "location_or_namespace": "torch.nn"
      }
    ]
  },
  {
    "function_name": "cross_attention",
    "file_path": "canonical.py (CrossAttn class)",
    "function_calls": [
      {
        "function_call_name": "self.Wq",
        "functionality": "",
        "input": "query_X",
        "output": "Transformed query tensor",
        "location_or_namespace": "canonical.py"
      },
      {
        "function_call_name": "self.Wk",
        "functionality": "",
        "input": "support_X",
        "output": "Transformed key tensor",
        "location_or_namespace": "canonical.py"
      },
      {
        "function_call_name": "torch.matmul",
        "functionality": "Performs matrix multiplication between input tensors.",
        "input": "Q, K.transpose(0, 1)",
        "output": "Matrix product",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "torch.sqrt",
        "functionality": "Computes the square root of each element in the input tensor.",
        "input": "torch.tensor(self.embedding_dim, dtype=torch.float32)",
        "output": "Tensor with sqrt computed",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "F.softmax",
        "functionality": "Applies the Softmax function to an n-dimensional input tensor rescaling them so that the element of the n-dimensional output tensor lie in the range [0, 1] and sum to 1.",
        "input": "attention_scores, dim=1",
        "output": "Softmaxed tensor",
        "location_or_namespace": "torch.nn.functional"
      },
      {
        "function_call_name": "torch.matmul",
        "functionality": "Performs matrix multiplication between input tensors.",
        "input": "attention_weights, support_X",
        "output": "Weighted query embeddings",
        "location_or_namespace": "torch"
      }
    ]
  },
  {
    "function_name": "get_train_loss",
    "file_path": "canonical.py (CrossAttn class)",
    "function_calls": [
      {
        "function_call_name": "torch.nonzero",
        "functionality": "Returns a tensor containing the indices of non-zero elements.",
        "input": "(y == 1) or (y == 0)",
        "output": "Indices tensor",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "random.sample",
        "functionality": "Return a k length list of unique elements chosen from the population sequence.",
        "input": "all_negative_indices, len(positive_indices)",
        "output": "Random sample list",
        "location_or_namespace": "random"
      },
      {
        "function_call_name": "torch.vstack",
        "functionality": "Stack tensors in sequence vertically (row wise).",
        "input": "[query_p_embed, query_n_embed]",
        "output": "Stacked tensor",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "set",
        "functionality": "Returns a new set object, optionally with elements taken from iterable.",
        "input": "all_negative_indices",
        "output": "Set object",
        "location_or_namespace": "builtins"
      },
      {
        "function_call_name": "random.sample",
        "functionality": "Return a k length list of unique elements chosen from the population sequence.",
        "input": "remaining_negative_indices, num_prompt",
        "output": "Random sample list",
        "location_or_namespace": "random"
      },
      {
        "function_call_name": "torch.tensor",
        "functionality": "Constructs a tensor object.",
        "input": "support_indices",
        "output": "Tensor",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "to",
        "functionality": "Moves and/or casts the parameters and buffers.",
        "input": "y.device",
        "output": "Tensor on device",
        "location_or_namespace": "torch.Tensor"
      },
      {
        "function_call_name": "self.cross_attention",
        "functionality": "Computes cross-attention between query and support embeddings.",
        "input": "query_embed, support_embed",
        "output": "Weighted query embeddings",
        "location_or_namespace": "canonical.py"
      },
      {
        "function_call_name": "torch.ones",
        "functionality": "Returns a tensor filled with the scalar value 1.",
        "input": "[len(negative_indices)]",
        "output": "Tensor of ones",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "torch.ones",
        "functionality": "Returns a tensor filled with the scalar value 1 (negated for abnormal).",
        "input": "[len(positive_indices)]",
        "output": "Tensor of ones",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "to",
        "functionality": "Moves and/or casts the parameters and buffers.",
        "input": "y.device",
        "output": "Tensor on device",
        "location_or_namespace": "torch.Tensor"
      },
      {
        "function_call_name": "F.cosine_embedding_loss",
        "functionality": "Measures the loss given input tensors and a label tensor.",
        "input": "(query_n_embed, tilde_n_embeds, yp) or (query_p_embed, tilde_p_embeds, yn)",
        "output": "Scalar loss",
        "location_or_namespace": "torch.nn.functional"
      },
      {
        "function_call_name": "torch.mean",
        "functionality": "Computes the mean of input tensor.",
        "input": "loss_qp + loss_qn",
        "output": "Mean value",
        "location_or_namespace": "torch"
      }
    ]
  },
  {
    "function_name": "get_test_score",
    "file_path": "canonical.py (CrossAttn class)",
    "function_calls": [
      {
        "function_call_name": "torch.nonzero",
        "functionality": "Returns a tensor containing the indices of non-zero elements.",
        "input": "(prompt_mask == True) & (y == 0) or (prompt_mask == False)",
        "output": "Indices tensor",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "self.cross_attention",
        "functionality": "Computes cross-attention between query and support embeddings.",
        "input": "query_embed, n_support_embed",
        "output": "Weighted query embeddings",
        "location_or_namespace": "canonical.py"
      },
      {
        "function_call_name": "torch.sqrt",
        "functionality": "Computes the square root of each element in the input tensor.",
        "input": "torch.sum(diff ** 2, dim=1)",
        "output": "Tensor with sqrt computed",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "torch.sum",
        "functionality": "Returns the sum of each row of the input tensor.",
        "input": "diff ** 2, dim=1",
        "output": "Sum tensor",
        "location_or_namespace": "torch"
      }
    ]
  }
]