PaddlePaddle 2.4 Release: New Sparse, Graph, and Audio APIs
PaddlePaddle 2.4 introduces 167 new APIs—including sparse computing (paddle.sparse), graph learning (paddle.geometric), and audio processing (paddle.audio) modules—enabling efficient sparse model training and inference, graph message‑passing, advanced audio feature extraction, plus fresh loss functions, tensor utilities, and expanded vision transforms.
PaddlePaddle framework version 2.4 has been officially released. Compared with 2.3, it adds 167 functional APIs, including new sparse computing (paddle.sparse), graph learning (paddle.geometric) and audio processing (paddle.audio) modules.
The release emphasizes support for sparse model training and inference, covering common sparse operations such as unary, binary, matrix and vector calculations, data reshaping, and sparse network layers. Example sparse APIs are listed (e.g., paddle.sparse.sin, paddle.sparse.add, paddle.sparse.matmul, paddle.sparse.nn.Conv3D, etc.).
Code examples demonstrate creating COO and CSR sparse tensors and applying ReLU:
# 稀疏COO Tensor
coo = paddle.sparse.sparse_coo_tensor(
indices=[[0,1,2],
[1,2,0]],
values=[1.,2.,3.],
shape=[3,3])
out = paddle.sparse.nn.functional.relu(coo)
# 稀疏CSR Tensor
csr = paddle.sparse.sparse_csr_tensor(
crows=[0,1,2,3],
cols=[1,2,0],
values=[1.,2.,3.],
shape=[3,3])
out = paddle.sparse.nn.functional.relu(csr)Mixed dense‑sparse multiplication is also supported:
# COO * dense -> dense
coo = paddle.sparse.sparse_coo_tensor(...)
dense = paddle.rand([3,2])
out = paddle.sparse.matmul(coo, dense)
# CSR * dense -> dense
csr = paddle.sparse.sparse_csr_tensor(...)
out = paddle.sparse.matmul(csr, dense)
# dense * dense -> sparse (masked matmul)
x = paddle.rand([3,5])
y = paddle.rand([5,4])
mask = paddle.sparse.sparse_csr_tensor(...)
out = paddle.sparse.masked_matmul(x, y, mask)For 3D point‑cloud detection, the CenterPoint model can now use the new sparse Conv3D, BatchNorm, and ReLU APIs, achieving up to 4% speedup and 0.2% higher accuracy.
Graph learning APIs (paddle.geometric) provide efficient message passing (send_u_recv, send_ue_recv, send_uv) and high‑performance sampling, with examples:
import paddle
x = paddle.to_tensor([[0,2,3],[1,4,5],[2,6,7]], dtype="float32")
y = paddle.to_tensor([1,1,1,1], dtype="float32")
indexes = paddle.to_tensor([[0,1],[1,2],[2,1],[0,0]], dtype="int32")
src_index, dst_index = indexes[:,0], indexes[:,1]
out = paddle.geometric.send_ue_recv(x, y, src_index, dst_index,
message_op="add", reduce_op="sum")Audio processing APIs (paddle.audio) add feature extractors such as MFCC, Spectrogram, LogMelSpectrogram, window functions, DCT, and I/O utilities. Example:
import paddle
from paddle.audio.features import LogMelSpectrogram
sample_rate = 16000
wav_data = paddle.linspace(-1.0, 1.0, int(sample_rate*0.5)) * 0.1
waveform = wav_data.tile([1, 1])
feature_extractor = LogMelSpectrogram(sr=sample_rate, n_fft=512, window='hann')
feats = feature_extractor(waveform)Additional updates include new loss functions (cosine_embedding_loss, soft_margin_loss, etc.), tensor utilities (paddle.sgn, paddle.count_nonzero, paddle.bucketize, etc.), distributed communication APIs, and expanded vision transforms.
For a complete list of changes, refer to the official release notes: https://github.com/PaddlePaddle/Paddle/releases
Baidu Geek Talk
Follow us to discover more Baidu tech insights.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.