Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
fd28881
[Metax_change_ut]
duqimeng Jul 23, 2025
a9d2aa7
Merge branch 'PaddlePaddle:develop' into develop
duqimeng Jul 24, 2025
1695f36
Merge branch 'PaddlePaddle:develop' into develop
duqimeng Jul 31, 2025
b931d38
Merge branch 'PaddlePaddle:develop' into develop
duqimeng Aug 1, 2025
bef21bf
Merge branch 'PaddlePaddle:develop' into develop
duqimeng Aug 8, 2025
f4e5004
Merge branch 'PaddlePaddle:develop' into develop
duqimeng Aug 13, 2025
55422eb
Merge branch 'PaddlePaddle:develop' into develop
duqimeng Aug 18, 2025
815a63a
Merge branch 'PaddlePaddle:develop' into develop
duqimeng Aug 19, 2025
1739a15
fix sum&collect_fpn_proposals op register
StareAtYou Aug 19, 2025
af0bae5
fix sum&collect_fpn_proposals op register
metax666 Aug 19, 2025
be61f06
modify profile
jxwangmetax Aug 20, 2025
0fc2dd1
modify profile
metax666 Aug 20, 2025
1ad95c5
Merge branch 'PaddlePaddle:develop' into develop
metax666 Aug 20, 2025
f12b3e4
Merge branch 'PaddlePaddle:develop' into develop
metax666 Aug 21, 2025
789c9fc
[Metax] fix paddle bug replace 'MoeGradDispatchKernel' to 'MoeGateDis…
StareAtYou Aug 21, 2025
a0116fb
[Metax] fix paddle bug
metax666 Aug 21, 2025
a2da5e0
Merge branch 'PaddlePaddle:develop' into develop
metax666 Aug 22, 2025
f9e6d2c
[Metax] register bce_loss_grad & bce_loss & index_add_grad kernels
StareAtYou Aug 22, 2025
4b4f562
Merge branch 'develop' of https://github.com/duqimeng/PaddleCustomDev…
duqimeng Aug 22, 2025
662e22e
[Metax] con2d_grad use gpudnn
duqimeng Aug 22, 2025
3e8d6ce
Merge branch 'metax666:develop' into develop
StareAtYou Aug 25, 2025
9dae9b7
[Metax] register bce_loss_grad & bce_loss & index_add_grad kernels
metax666 Aug 25, 2025
47fef62
blas handle support
jxwangmetax Aug 25, 2025
266c0df
blas handle support
metax666 Aug 25, 2025
a0b340b
[Metax] register some kernels & update CMakeLists
StareAtYou Aug 25, 2025
aa9bd35
Merge branch 'metax666:develop' into develop
StareAtYou Aug 26, 2025
8c6ac05
[Metax] register some kernels & update CMakeLists
metax666 Aug 26, 2025
9510f7d
Merge branch 'metax666:develop' into develop
duqimeng Aug 26, 2025
fa7cc1a
[Metax] fix metax unittest fail
StareAtYou Aug 26, 2025
a907545
[Metax] fix metax unittest fail
metax666 Aug 26, 2025
7a6312e
[Metax] add group_norm & label_smooth kernel and update matmul kernel
StareAtYou Aug 26, 2025
90bb94e
[Metax] add group_norm & label_smooth kernel and update matmul kernel
metax666 Aug 27, 2025
9f130fe
[Metax] fix rmsprop kernel register and add meshgrid & meshgrid_grad …
StareAtYou Aug 27, 2025
ca38fb5
Merge branch 'metax666:develop' into develop
StareAtYou Aug 27, 2025
f0cc1e0
add test
zhang-chenyi Aug 27, 2025
8e8b732
add test
zhang-chenyi Aug 27, 2025
8d7efbd
Merge branch 'metax666:develop' into develop
zhang-chenyi Aug 27, 2025
28c992b
Merge branch 'develop' of https://github.com/zhang-chenyi/PaddleCusto…
zhang-chenyi Aug 27, 2025
d3470bb
[test] chang the logic of workspace_host in cholesky_kernel_register
zhang-chenyi Aug 27, 2025
db17ebf
Merge branch 'develop' of https://github.com/zhang-chenyi/PaddleCusto…
zhang-chenyi Aug 27, 2025
83bc87f
[Metax] fix compile fail
StareAtYou Aug 27, 2025
f1e8d0c
Revert "[Metax] fix compile fail"
StareAtYou Aug 27, 2025
a13daa8
[Metax] fix compile fail by 'conv_transpose_grad_kernel_impl.h'
StareAtYou Aug 27, 2025
95a179b
[Metax] fix bug & add some kernel register
metax666 Aug 28, 2025
4576ef4
[Metax]fix bug and add qr lstsq logsoftmax
duqimeng Aug 28, 2025
ca51a1e
Merge branch 'metax666:develop' into develop
duqimeng Aug 28, 2025
7789e9b
[Metax] con2d_grad use gpudnn
duqimeng Aug 22, 2025
afd0863
[Metax]fix bug and add qr lstsq logsoftmax
duqimeng Aug 28, 2025
6da0f0d
Merge branch 'metax666:develop' into develop
duqimeng Aug 28, 2025
e1e07ba
[Metax] change_patch
duqimeng Aug 28, 2025
046637c
[Metax] change_patch
metax666 Aug 28, 2025
c27b492
Merge branch 'PaddlePaddle:develop' into develop
metax666 Aug 28, 2025
05ecd9d
[Metax] update unit test CMakeLists.txt
StareAtYou Aug 28, 2025
b1bf7e8
[Metax] update unit test CMakeLists.txt
StareAtYou Aug 28, 2025
f90d585
Merge branch 'metax666:develop' into develop
StareAtYou Aug 28, 2025
874d9b6
Merge branch 'metax666:develop' into develop
zhang-chenyi Aug 28, 2025
0ca02b9
[feature] add unique_consecutive kernel
zhang-chenyi Aug 28, 2025
40d8f21
[metax-feature] add kernel for test_math_op_patch_var_base
metax666 Aug 28, 2025
3e9b526
[metax] add some kernel
duqimeng Aug 28, 2025
8911576
[metax] add some kernel
duqimeng Aug 28, 2025
8471597
Merge branch 'metax666:develop' into develop
duqimeng Aug 28, 2025
0758887
Merge branch 'metax666:develop' into develop
StareAtYou Aug 29, 2025
61be33d
[Metax] register baddbmm kernel & update blas api
StareAtYou Aug 29, 2025
2fe962e
[Metax] register baddbmm kernel & update blas api
StareAtYou Aug 29, 2025
531fedb
Merge branch 'metax666:develop' into develop
StareAtYou Aug 29, 2025
c0dcfff
[Metax] register deformable_conv kernel & fix 'ModulatedDeformableCol…
StareAtYou Aug 29, 2025
bd65451
[feature] add add unique_consecutive kernel.cu
zhang-chenyi Aug 29, 2025
0def63d
[fix] fix some test case due to missing op register
zhang-chenyi Aug 29, 2025
e503c9e
[fix] fix some fail text
zhang-chenyi Aug 29, 2025
9844878
[metax]fix lu eigvalshsqueeze rnn kernel
duqimeng Aug 29, 2025
70b86e7
[metax]fix lu eigvalshsqueeze rnn kernel
duqimeng Aug 29, 2025
1e90757
add and fix some kernels
1184319564 Aug 30, 2025
f93307d
[Metax] register deformable_conv kernel & fix 'ModulatedDeformableCol…
StareAtYou Aug 29, 2025
c4b0eb9
[Metax] fix conflict
StareAtYou Sep 1, 2025
06dda18
[Metax] fix conflict
StareAtYou Sep 1, 2025
dae6ce8
[Metax] adapt to paddle-cpu-20250901 & resolve the issue of 'test_ele…
StareAtYou Sep 1, 2025
b4a5c62
[Metax] update repeat_interleave kernel & ignore max op test
StareAtYou Sep 2, 2025
7cf4405
Merge branch 'metax666:develop' into develop
StareAtYou Sep 2, 2025
0015f2e
[Metax] register deformable_conv kernel & fix 'ModulatedDeformableCol…
metax666 Sep 2, 2025
fc2c0f5
Merge branch 'metax666:develop' into develop
duqimeng Sep 2, 2025
829c3b6
Merge dev
duqimeng Sep 2, 2025
3104a9c
【metax】add and fix some kernels
metax666 Sep 2, 2025
175cca6
[metax]fix lu eigvalshsqueeze rnn kernel
metax666 Sep 2, 2025
c7db810
[metax]fix lu eigvalshsqueeze rnn kernel
duqimeng Aug 29, 2025
f5813ed
[metax] chang patch fix copy
duqimeng Sep 2, 2025
6f0b705
[metax] chang patch fix copy
duqimeng Sep 2, 2025
8f47f0e
[metax] chang patch fix copy
metax666 Sep 2, 2025
b420f97
[Metax] update metax_gpu unit test
StareAtYou Sep 2, 2025
c08533e
[Metax] update metax_gpu unit test
metax666 Sep 2, 2025
414715f
[Metax] fix test CMakeList.txt
StareAtYou Sep 2, 2025
aa6b5bf
[Metax] fix test CMakeList.txt
metax666 Sep 2, 2025
f6932e0
Merge branch 'metax666:develop' into sth-to-do
1184319564 Sep 4, 2025
532694a
Merge branch 'metax666:develop' into sth-to-do
1184319564 Sep 10, 2025
29ebf44
Merge branch 'metax666:develop' into sth-to-do
1184319564 Sep 12, 2025
489ceb0
Merge branch 'metax666:develop' into sth-to-do
1184319564 Sep 15, 2025
ef88e86
Merge branch 'metax666:develop' into sth-to-do
1184319564 Sep 16, 2025
e9ed0b4
Merge branch 'metax666:develop' into sth-to-do
1184319564 Sep 17, 2025
b8d5d18
Merge branch 'metax666:develop' into sth-to-do
1184319564 Sep 19, 2025
96fafac
Merge branch 'metax666:develop' into sth-to-do
1184319564 Sep 22, 2025
53e4758
Merge branch 'metax666:develop' into sth-to-do
1184319564 Sep 23, 2025
c5afd21
Merge branch 'metax666:develop' into sth-to-do
1184319564 Sep 24, 2025
9acaf05
Merge branch 'metax666:develop' into sth-to-do
1184319564 Sep 25, 2025
4b8cb7f
Merge branch 'metax666:develop' into sth-to-do
1184319564 Sep 26, 2025
3f3c71d
Merge branch 'metax666:develop' into sth-to-do
1184319564 Sep 26, 2025
0a82407
Merge branch 'metax666:develop' into sth-to-do
1184319564 Sep 29, 2025
b9b2421
Merge branch 'metax666:develop' into sth-to-do
1184319564 Sep 29, 2025
9c513b8
Merge branch 'metax666:develop' into sth-to-do
1184319564 Sep 30, 2025
d7c538b
Merge branch 'metax666:develop' into sth-to-do
1184319564 Sep 30, 2025
d0f90fc
Merge branch 'metax666:develop' into sth-to-do
1184319564 Oct 11, 2025
df38349
Merge branch 'metax666:develop' into sth-to-do
1184319564 Oct 13, 2025
eeefd2e
Merge branch 'metax666:develop' into sth-to-do
1184319564 Oct 14, 2025
e8cb9a3
Merge branch 'metax666:develop' into sth-to-do
1184319564 Oct 14, 2025
1a9775c
Merge branch 'metax666:develop' into sth-to-do
1184319564 Oct 14, 2025
ae07924
Merge branch 'metax666:develop' into sth-to-do
1184319564 Oct 15, 2025
b081368
fix some tests
1184319564 Oct 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion backends/metax_gpu/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@ foreach(test_name ${TEST_PROGRAMS})
continue()
endif()

set(CURRENT_TEST_PROGRAM ${PADDLE_LEGACY_TEST_PATH}/${test_name}.py)
string(FIND "${test_name}" "metax" METAX_SUFFIX_POS)
if(NOT METAX_SUFFIX_POS EQUAL -1)
set(CURRENT_TEST_PROGRAM ${METAX_UNIT_TEST_PATH}/${test_name}.py)
else()
set(CURRENT_TEST_PROGRAM ${PADDLE_LEGACY_TEST_PATH}/${test_name}.py)
endif()

if(NOT EXISTS ${CURRENT_TEST_PROGRAM})
message(WARNING "${CURRENT_TEST_PROGRAM} is not exist, skip it.")
else()
Expand Down
381 changes: 381 additions & 0 deletions backends/metax_gpu/tests/unit_test/test_conv3d_layer_metax.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,381 @@
# Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import unittest

import numpy as np
from op_test import get_device_place, is_custom_device
from test_conv3d_op import conv3d_forward_naive

import paddle
import paddle.base.dygraph as dg
import paddle.nn.functional as F
from paddle import base, nn
from paddle.base import core

core.set_cudnn_switch(False)


class Conv3DTestCase(unittest.TestCase):
def __init__(
self,
methodName="runTest",
batch_size=4,
spatial_shape=(8, 8, 8),
num_channels=6,
num_filters=8,
filter_size=3,
padding=0,
stride=1,
dilation=1,
groups=1,
no_bias=False,
data_format="NCDHW",
dtype="float32",
):
super().__init__(methodName)
self.batch_size = batch_size
self.num_channels = num_channels
self.num_filters = num_filters
self.spatial_shape = spatial_shape
self.filter_size = filter_size

self.padding = padding
self.stride = stride
self.dilation = dilation
self.groups = groups
self.no_bias = no_bias
self.data_format = data_format
self.dtype = dtype

def setUp(self):
self.channel_last = self.data_format == "NDHWC"
if self.channel_last:
input_shape = (
self.batch_size,
*self.spatial_shape,
self.num_channels,
)
else:
input_shape = (
self.batch_size,
self.num_channels,
*self.spatial_shape,
)
self.input = np.random.randn(*input_shape).astype(self.dtype)

if isinstance(self.filter_size, int):
filter_size = [self.filter_size] * 3
else:
filter_size = self.filter_size
self.weight_shape = weight_shape = (
self.num_filters,
self.num_channels // self.groups,
*filter_size,
)
self.weight = np.random.uniform(-1, 1, size=weight_shape).astype(self.dtype)
if not self.no_bias:
self.bias = np.random.uniform(-1, 1, size=(self.num_filters,)).astype(
self.dtype
)
else:
self.bias = None

def base_layer(self, place):
main = base.Program()
start = base.Program()
with (
base.unique_name.guard(),
base.program_guard(main, start),
):
input_shape = (
(-1, -1, -1, -1, self.num_channels)
if self.channel_last
else (-1, self.num_channels, -1, -1, -1)
)
x_var = paddle.static.data("input", input_shape, dtype=self.dtype)
weight_attr = paddle.nn.initializer.Assign(self.weight)
if self.bias is None:
bias_attr = False
else:
bias_attr = paddle.nn.initializer.Assign(self.bias)
y_var = paddle.nn.Conv3D(
in_channels=self.num_channels,
out_channels=self.num_filters,
kernel_size=self.filter_size,
stride=self.stride,
padding=self.padding,
dilation=self.dilation,
groups=self.groups,
padding_mode="zeros",
weight_attr=weight_attr,
bias_attr=bias_attr,
data_format=self.data_format,
)(x_var)
feed_dict = {"input": self.input}
exe = base.Executor(place)
exe.run(start)
(y_np,) = exe.run(main, feed=feed_dict, fetch_list=[y_var])
return y_np

def functional(self, place):
main = base.Program()
start = base.Program()
with (
base.unique_name.guard(),
base.program_guard(main, start),
):
input_shape = (
(-1, -1, -1, -1, self.num_channels)
if self.channel_last
else (-1, self.num_channels, -1, -1, -1)
)
x_var = paddle.static.data("input", input_shape, dtype=self.dtype)
w_var = paddle.static.data("weight", self.weight_shape, dtype=self.dtype)
if not self.no_bias:
b_var = paddle.static.data(
"bias", (self.num_filters,), dtype=self.dtype
)
else:
b_var = None
y_var = F.conv3d(
x_var,
w_var,
b_var,
padding=self.padding,
stride=self.stride,
dilation=self.dilation,
groups=self.groups,
data_format=self.data_format,
)
feed_dict = {"input": self.input, "weight": self.weight}
if self.bias is not None:
feed_dict["bias"] = self.bias
exe = base.Executor(place)
exe.run(start)
(y_np,) = exe.run(main, feed=feed_dict, fetch_list=[y_var])
return y_np

def paddle_nn_layer(self):
x_var = paddle.to_tensor(self.input)
x_var.stop_gradient = False
conv = nn.Conv3D(
self.num_channels,
self.num_filters,
self.filter_size,
padding=self.padding,
stride=self.stride,
dilation=self.dilation,
groups=self.groups,
data_format=self.data_format,
)
conv.weight.set_value(self.weight)
if not self.no_bias:
conv.bias.set_value(self.bias)
y_var = conv(x_var)
y_var.backward()
y_np = y_var.numpy()
t1 = x_var.gradient()
return y_np, t1

def _test_pir_equivalence(self, place):
with paddle.pir_utils.IrGuard():
result1 = self.base_layer(place)
result2 = self.functional(place)
with dg.guard(place):
result3, g1 = self.paddle_nn_layer()
np.testing.assert_array_almost_equal(result1, result2)
np.testing.assert_array_almost_equal(result2, result3)

def runTest(self):
place = base.CPUPlace()
self._test_pir_equivalence(place)

if base.core.is_compiled_with_cuda() or is_custom_device():
place = get_device_place()
self._test_pir_equivalence(place)


class Conv3DErrorTestCase(Conv3DTestCase):
def runTest(self):
place = base.CPUPlace()
with (
dg.guard(place),
self.assertRaises(ValueError),
):
self.paddle_nn_layer()


def add_cases(suite):
suite.addTest(Conv3DTestCase(methodName="runTest"))
suite.addTest(Conv3DTestCase(methodName="runTest", stride=[1, 2, 1], dilation=2))
suite.addTest(Conv3DTestCase(methodName="runTest", stride=2, dilation=(2, 1, 2)))
suite.addTest(Conv3DTestCase(methodName="runTest", padding="same", no_bias=True))
suite.addTest(
Conv3DTestCase(methodName="runTest", filter_size=(3, 2, 3), padding="valid")
)
suite.addTest(Conv3DTestCase(methodName="runTest", padding=(2, 3, 1)))
suite.addTest(Conv3DTestCase(methodName="runTest", padding=[1, 2, 2, 1, 2, 3]))
suite.addTest(
Conv3DTestCase(
methodName="runTest",
padding=[[0, 0], [0, 0], [1, 2], [2, 1], [2, 2]],
)
)
suite.addTest(Conv3DTestCase(methodName="runTest", data_format="NDHWC"))
suite.addTest(
Conv3DTestCase(
methodName="runTest",
data_format="NDHWC",
padding=[[0, 0], [1, 1], [3, 3], [2, 2], [0, 0]],
)
)
suite.addTest(Conv3DTestCase(methodName="runTest", groups=2, padding="valid"))
suite.addTest(
Conv3DTestCase(
methodName="runTest",
num_filters=6,
num_channels=3,
groups=3,
padding="valid",
)
)


def add_error_cases(suite):
suite.addTest(Conv3DErrorTestCase(methodName="runTest", num_channels=5, groups=2))
suite.addTest(
Conv3DErrorTestCase(
methodName="runTest", num_channels=5, groups=2, padding=[-1, 1, 3]
)
)


def load_tests(loader, standard_tests, pattern):
suite = unittest.TestSuite()
add_cases(suite)
add_error_cases(suite)
return suite


def get_places():
places = []
if core.is_compiled_with_xpu():
places.append(paddle.device.XPUPlace(0))
elif core.is_compiled_with_cuda():
places.append(paddle.CUDAPlace(0))
places.append(paddle.CPUPlace())
return places


class TestConv3dAPI_Compatibility(unittest.TestCase):
def setUp(self):
np.random.seed(2025)
self.places = get_places()
self.shape_x = [2, 3, 8, 8, 8] # NCDHW
self.shape_w = [6, 3, 3, 3, 3] # Co, Cin, kD, kH, kW
self.dtype = "float32"
self.init_data()

def init_data(self):
self.np_x = np.random.rand(*self.shape_x).astype(self.dtype)
self.np_w = np.random.rand(*self.shape_w).astype(self.dtype)
conv_param = {
"stride": [1, 1, 1],
"pad": [0, 0, 0],
"dilation": [1, 1, 1],
}
self.np_ref_out = conv3d_forward_naive(self.np_x, self.np_w, 1, conv_param)

def test_dygraph_Compatibility(self):
for place in self.places:
paddle.device.set_device(place)
paddle.disable_static()
x = paddle.to_tensor(self.np_x)
w = paddle.to_tensor(self.np_w)

paddle_dygraph_out = []
# Position args (args)
out1 = paddle.nn.functional.conv3d(x, w)
paddle_dygraph_out.append(out1)
# Key words args (kwargs) for paddle
out2 = paddle.nn.functional.conv3d(x=x, weight=w)
paddle_dygraph_out.append(out2)
# Key words args for alias compatibility
out3 = paddle.nn.functional.conv3d(input=x, weight=w)
paddle_dygraph_out.append(out3)
# Combined args and kwargs
out4 = paddle.nn.functional.conv3d(x, weight=w)
paddle_dygraph_out.append(out4)

# refer to test/xpu/test_conv3d_op_xpu.py
if isinstance(place, core.XPUPlace):
rtol = 5e-3
atol = 5e-3
else:
rtol = 1e-5
atol = 0

# Check all dygraph results against reference
for out in paddle_dygraph_out:
np.testing.assert_allclose(
self.np_ref_out, out.numpy(), rtol=rtol, atol=atol
)
paddle.enable_static()

def test_static_Compatibility(self):
paddle.enable_static()

fetch_list = []
main = paddle.static.Program()
startup = paddle.static.Program()
with base.program_guard(main, startup):
x = paddle.static.data(name="x", shape=self.shape_x, dtype=self.dtype)
w = paddle.static.data(name="w", shape=self.shape_w, dtype=self.dtype)

# Position args (args)
out1 = paddle.nn.functional.conv3d(x, w)
fetch_list.append(out1)
# Key words args (kwargs) for paddle
out2 = paddle.nn.functional.conv3d(x=x, weight=w)
fetch_list.append(out2)
# Key words args for alias compatibility
out3 = paddle.nn.functional.conv3d(input=x, weight=w)
fetch_list.append(out3)
# Combined args and kwargs
out4 = paddle.nn.functional.conv3d(x, weight=w)
fetch_list.append(out4)

for place in self.places:
# refer to test/xpu/test_conv2d_op_xpu.py
if isinstance(place, core.XPUPlace):
rtol = 5e-3
atol = 5e-3
else:
rtol = 1e-5
atol = 0

exe = base.Executor(place)
fetches = exe.run(
main,
feed={"x": self.np_x, "w": self.np_w},
fetch_list=fetch_list,
)
for out in fetches:
np.testing.assert_allclose(
out, self.np_ref_out, rtol=rtol, atol=atol
)


if __name__ == "__main__":
unittest.main()
Loading