File size: 12,592 Bytes
83e8056
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
[
  {
    "function_name": "__init__",
    "file_path": "graphmetro/moe_model.py",
    "function_calls": [
      {
        "function_call_name": "super().__init__",
        "functionality": "Initializes the base nn.Module class.",
        "input": "()",
        "output": "None",
        "location_or_namespace": "torch.nn.Module"
      },
      {
        "function_call_name": "len",
        "functionality": "Returns the number of items in a dictionary.",
        "input": "trans_func_dict",
        "output": "int",
        "location_or_namespace": "builtins"
      },
      {
        "function_call_name": "list",
        "functionality": "Converts dictionary values to a list.",
        "input": "trans_func_dict.values()",
        "output": "list",
        "location_or_namespace": "builtins"
      },
      {
        "function_call_name": "list",
        "functionality": "Converts dictionary keys to a list.",
        "input": "trans_func_dict.keys()",
        "output": "list",
        "location_or_namespace": "builtins"
      },
      {
        "function_call_name": "range",
        "functionality": "Generates a sequence of numbers.",
        "input": "self.num_experts",
        "output": "range",
        "location_or_namespace": "builtins"
      }
    ]
  },
  {
    "function_name": "_aggregate",
    "file_path": "graphmetro/moe_model.py",
    "function_calls": [
      {
        "function_call_name": "self.experts[i].encoder",
        "functionality": "Encodes the graph data for a specific expert.",
        "input": "data.x, data.edge_index, data.edge_attr, data.batch",
        "output": "torch.Tensor",
        "location_or_namespace": ""
      },
      {
        "function_call_name": "unsqueeze",
        "functionality": "Adds a dimension to a tensor.",
        "input": "dim=-1",
        "output": "torch.Tensor",
        "location_or_namespace": "torch.Tensor"
      },
      {
        "function_call_name": "append",
        "functionality": "Adds an element to a list.",
        "input": "emb",
        "output": "None",
        "location_or_namespace": "builtins.list"
      },
      {
        "function_call_name": "torch.concat",
        "functionality": "Concatenates a sequence of tensors along a given dimension.",
        "input": "embs, dim=-1",
        "output": "torch.Tensor",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "size",
        "functionality": "Returns the size of the tensor.",
        "input": "0",
        "output": "torch.Size",
        "location_or_namespace": "torch.Tensor"
      },
      {
        "function_call_name": "torch.unique",
        "functionality": "Returns the unique elements of a tensor.",
        "input": "data.batch",
        "output": "torch.Tensor",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "len",
        "functionality": "Returns the length of an object.",
        "input": "torch.unique(data.batch)",
        "output": "int",
        "location_or_namespace": "builtins"
      },
      {
        "function_call_name": "isinstance",
        "functionality": "Checks if an object is an instance of a class.",
        "input": "weights_or_labels, (int, np.int64)",
        "output": "bool",
        "location_or_namespace": "builtins"
      },
      {
        "function_call_name": "torch.LongTensor",
        "functionality": "Creates a LongTensor.",
        "input": "[weights_or_labels for _ in range(length)]",
        "output": "torch.Tensor",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "len",
        "functionality": "Returns the length of an object.",
        "input": "weights_or_labels.size()",
        "output": "int",
        "location_or_namespace": "builtins"
      },
      {
        "function_call_name": "copy.deepcopy",
        "functionality": "Creates a deep copy of an object.",
        "input": "weights_or_labels",
        "output": "torch.Tensor",
        "location_or_namespace": "copy"
      },
      {
        "function_call_name": "torch.zeros",
        "functionality": "Creates a tensor filled with zeros.",
        "input": "(length, self.num_experts)",
        "output": "torch.Tensor",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "to",
        "functionality": "Moves the tensor to a specified device.",
        "input": "cfg.device",
        "output": "torch.Tensor",
        "location_or_namespace": "torch.Tensor"
      },
      {
        "function_call_name": "range",
        "functionality": "Generates a sequence of numbers.",
        "input": "length",
        "output": "range",
        "location_or_namespace": "builtins"
      },
      {
        "function_call_name": "argmax",
        "functionality": "Returns the indices of the maximum values along a dimension.",
        "input": "dim=1",
        "output": "torch.Tensor",
        "location_or_namespace": "torch.Tensor"
      },
      {
        "function_call_name": "bool",
        "functionality": "Casts the tensor to boolean type.",
        "input": "()",
        "output": "torch.Tensor",
        "location_or_namespace": "torch.Tensor"
      },
      {
        "function_call_name": "torch.zeros_like",
        "functionality": "Creates a tensor filled with zeros, with the same size as input.",
        "input": "weights_or_labels",
        "output": "torch.Tensor",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "unsqueeze",
        "functionality": "Adds a dimension to a tensor.",
        "input": "dim=2",
        "output": "torch.Tensor",
        "location_or_namespace": "torch.Tensor"
      },
      {
        "function_call_name": "torch.bmm",
        "functionality": "Performs batch matrix-matrix product.",
        "input": "embs, weights",
        "output": "torch.Tensor",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "squeeze",
        "functionality": "Removes a dimension from a tensor.",
        "input": "dim=-1",
        "output": "torch.Tensor",
        "location_or_namespace": "torch.Tensor"
      }
    ]
  },
  {
    "function_name": "get_expert_weights",
    "file_path": "graphmetro/moe_model.py",
    "function_calls": [
      {
        "function_call_name": "self.gating_model",
        "functionality": "Computes expert weights using the gating model.",
        "input": "trans_data.x, trans_data.edge_index, trans_data.edge_attr, trans_data.batch",
        "output": "torch.Tensor",
        "location_or_namespace": ""
      },
      {
        "function_call_name": "softmax",
        "functionality": "Applies the softmax function.",
        "input": "dim=-1",
        "output": "torch.Tensor",
        "location_or_namespace": "torch.Tensor"
      }
    ]
  },
  {
    "function_name": "forward",
    "file_path": "graphmetro/moe_model.py",
    "function_calls": [
      {
        "function_call_name": "self.get_expert_weights",
        "functionality": "Computes expert weights using the gating model.",
        "input": "trans_data, softmax=True",
        "output": "torch.Tensor",
        "location_or_namespace": "graphmetro/moe_model.py"
      },
      {
        "function_call_name": "argmax",
        "functionality": "Returns the indices of the maximum values along a dimension.",
        "input": "dim=-1",
        "output": "torch.Tensor",
        "location_or_namespace": "torch.Tensor"
      },
      {
        "function_call_name": "view",
        "functionality": "Returns a new tensor with the same data but different size.",
        "input": "-1",
        "output": "torch.Tensor",
        "location_or_namespace": "torch.Tensor"
      },
      {
        "function_call_name": "self._aggregate",
        "functionality": "Aggregates expert outputs based on weights.",
        "input": "trans_data, expert_weights, hard",
        "output": "torch.Tensor",
        "location_or_namespace": "graphmetro/moe_model.py"
      },
      {
        "function_call_name": "self.classifier",
        "functionality": "Classifies the aggregated embedding.",
        "input": "new_z",
        "output": "torch.Tensor",
        "location_or_namespace": ""
      },
      {
        "function_call_name": "torch.zeros_like",
        "functionality": "Creates a tensor filled with zeros, with the same size as input.",
        "input": "expert_weights",
        "output": "torch.Tensor",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "range",
        "functionality": "Generates a sequence of numbers.",
        "input": "expert_weights.size(0)",
        "output": "range",
        "location_or_namespace": "builtins"
      }
    ]
  },
  {
    "function_name": "losses",
    "file_path": "graphmetro/moe_model.py",
    "function_calls": [
      {
        "function_call_name": "self.get_expert_weights",
        "functionality": "Computes expert weights using the gating model.",
        "input": "trans_data, softmax=False",
        "output": "torch.Tensor",
        "location_or_namespace": "graphmetro/moe_model.py"
      },
      {
        "function_call_name": "repeat",
        "functionality": "Repeats the tensor along specified dimensions.",
        "input": "expert_weights.size(0), 1",
        "output": "torch.Tensor",
        "location_or_namespace": "torch.Tensor"
      },
      {
        "function_call_name": "to",
        "functionality": "Moves the tensor to a specified device.",
        "input": "cfg.device",
        "output": "torch.Tensor",
        "location_or_namespace": "torch.Tensor"
      },
      {
        "function_call_name": "print",
        "functionality": "Prints objects to the text stream.",
        "input": "'Added pos_weight=5'",
        "output": "None",
        "location_or_namespace": "builtins"
      },
      {
        "function_call_name": "F.binary_cross_entropy_with_logits",
        "functionality": "Computes Binary Cross Entropy loss with logits.",
        "input": "expert_weights, target, pos_weight=torch.Tensor([4.]).to(expert_weights.device)",
        "output": "torch.Tensor",
        "location_or_namespace": "torch.nn.functional"
      },
      {
        "function_call_name": "torch.Tensor",
        "functionality": "Creates a Tensor.",
        "input": "[4.]",
        "output": "torch.Tensor",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "sigmoid",
        "functionality": "Applies the sigmoid function.",
        "input": "()",
        "output": "torch.Tensor",
        "location_or_namespace": "torch.Tensor"
      },
      {
        "function_call_name": "float",
        "functionality": "Casts the tensor to float type.",
        "input": "()",
        "output": "torch.Tensor",
        "location_or_namespace": "torch.Tensor"
      },
      {
        "function_call_name": "mean",
        "functionality": "Computes the mean of the tensor.",
        "input": "()",
        "output": "torch.Tensor",
        "location_or_namespace": "torch.Tensor"
      },
      {
        "function_call_name": "detach",
        "functionality": "Detaches the tensor from the computation graph.",
        "input": "()",
        "output": "torch.Tensor",
        "location_or_namespace": "torch.Tensor"
      },
      {
        "function_call_name": "softmax",
        "functionality": "Applies the softmax function.",
        "input": "dim=-1",
        "output": "torch.Tensor",
        "location_or_namespace": "torch.Tensor"
      },
      {
        "function_call_name": "self._aggregate",
        "functionality": "Aggregates expert outputs based on weights.",
        "input": "trans_data, expert_weights_detached, hard",
        "output": "torch.Tensor",
        "location_or_namespace": "graphmetro/moe_model.py"
      },
      {
        "function_call_name": "torch.unique",
        "functionality": "Returns the unique elements of a tensor.",
        "input": "data.batch",
        "output": "torch.Tensor",
        "location_or_namespace": "torch"
      },
      {
        "function_call_name": "len",
        "functionality": "Returns the length of an object.",
        "input": "torch.unique(data.batch)",
        "output": "int",
        "location_or_namespace": "builtins"
      },
      {
        "function_call_name": "torch.linalg.norm",
        "functionality": "Computes the matrix or vector norm.",
        "input": "new_zs - gt_zs_base, 'fro'",
        "output": "torch.Tensor",
        "location_or_namespace": "torch.linalg"
      }
    ]
  }
]