udf.rst 1.2 KB
Newer Older
Mufei Li's avatar
Mufei Li committed
1
2
.. _apiudf:

3
dgl.udf
Mufei Li's avatar
Mufei Li committed
4
5
6
==================================================

.. currentmodule:: dgl.udf
7

8
9
User-defined functions (UDFs) are flexible ways to configure message passing computation.
There are two types of UDFs in DGL:
10
11
12
13
14
15
16

* **Node UDF** of signature ``NodeBatch -> dict``. The argument represents
  a batch of nodes. The returned dictionary should have ``str`` type key and ``tensor``
  type values.
* **Edge UDF** of signature ``EdgeBatch -> dict``. The argument represents
  a batch of edges. The returned dictionary should have ``str`` type key and ``tensor``
  type values.
Mufei Li's avatar
Mufei Li committed
17

18
The size of the batch dimension is determined by the DGL framework
19
20
21
for good efficiency and small memory footprint. Users should not make
assumption in the batch dimension.

Mufei Li's avatar
Mufei Li committed
22
23
24
25
26
27
28
29
30
31
32
33
34
EdgeBatch
---------

The class that can represent a batch of edges.

.. autosummary::
    :toctree: ../../generated/

    EdgeBatch.src
    EdgeBatch.dst
    EdgeBatch.data
    EdgeBatch.edges
    EdgeBatch.batch_size
35
    EdgeBatch.__len__
Mufei Li's avatar
Mufei Li committed
36
37
38
39
40
41
42
43
44
45
46
47
48

NodeBatch
---------

The class that can represent a batch of nodes.

.. autosummary::
    :toctree: ../../generated/

    NodeBatch.data
    NodeBatch.mailbox
    NodeBatch.nodes
    NodeBatch.batch_size
49
    NodeBatch.__len__