Skip to content

Commit 8218e6c

Browse files
authored
Fix patch error (#1930)
1 parent 58dd9c8 commit 8218e6c

5 files changed

Lines changed: 98 additions & 125 deletions

File tree

Paddle

Submodule Paddle updated 770 files

backends/iluvatar_gpu/patches/paddle-corex.patch

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -700,16 +700,16 @@ diff --git a/paddle/phi/kernels/reduce_sum_kernel.cc b/paddle/phi/kernels/reduce
700700
index 654eae9199..3b6e5580e6 100644
701701
--- a/paddle/phi/kernels/reduce_sum_kernel.cc
702702
+++ b/paddle/phi/kernels/reduce_sum_kernel.cc
703-
@@ -37,6 +37,7 @@ void SumKernel(const Context& dev_ctx,
704-
using complex64 = ::phi::dtype::complex<float>;
705-
using complex128 = ::phi::dtype::complex<double>;
703+
@@ -34,6 +34,7 @@ void SumKernel(const Context& dev_ctx,
704+
705+
} // namespace phi
706706

707707
+#ifndef PADDLE_WITH_COREX
708708
PD_REGISTER_KERNEL(sum,
709709
CPU,
710710
ALL_LAYOUT,
711-
@@ -55,6 +56,7 @@ PD_REGISTER_KERNEL(sum,
712-
complex128) {
711+
@@ -52,6 +53,7 @@ PD_REGISTER_KERNEL(sum,
712+
phi::complex128) {
713713
kernel->OutputAt(0).SetDataType(phi::DataType::UNDEFINED);
714714
}
715715
+#endif

backends/metax_gpu/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,8 @@ add_library(
735735
target_include_directories(
736736
${TARGET_NAME}
737737
PRIVATE ${PADDLE_SOURCE_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/kernels
738-
${CUDA_INCLUDE_DIRS} ${PADDLE_SOURCE_DIR}/third_party/pybind/include)
738+
${CUDA_INCLUDE_DIRS} ${PADDLE_SOURCE_DIR}/third_party/pybind/include
739+
${PADDLE_SOURCE_DIR}/paddle/phi/api/include/compat/)
739740

740741
target_link_libraries(
741742
${TARGET_NAME}

backends/metax_gpu/patch/paddle.patch

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -35,35 +35,7 @@ diff --git a/paddle/phi/backends/dynload/cudnn.h b/paddle/phi/backends/dynload/c
3535
index 7a5450c349..95de89ced2 100644
3636
--- a/paddle/phi/backends/dynload/cudnn.h
3737
+++ b/paddle/phi/backends/dynload/cudnn.h
38-
@@ -1,3 +1,4 @@
39-
+// 2024 - Modified by MetaX Integrated Circuits (Shanghai) Co., Ltd. All Rights Reserved.
40-
/* Copyright (c) 2016 PaddlePaddle Authors. All Rights Reserved.
41-
42-
Licensed under the Apache License, Version 2.0 (the "License");
43-
@@ -15,7 +16,6 @@ limitations under the License. */
44-
#pragma once
45-
#ifdef PADDLE_WITH_CUDA
46-
#include <cudnn.h>
47-
-
48-
#include <mutex> // NOLINT
49-
50-
#include "paddle/phi/backends/dynload/dynamic_loader.h"
51-
@@ -24,11 +24,11 @@ limitations under the License. */
52-
namespace phi {
53-
namespace dynload {
54-
55-
-TEST_API extern std::once_flag cudnn_dso_flag;
56-
-TEST_API extern void* cudnn_dso_handle;
57-
+extern std::once_flag cudnn_dso_flag;
58-
+extern void* cudnn_dso_handle;
59-
extern bool HasCUDNN();
60-
61-
-TEST_API extern void EnforceCUDNNLoaded(const char* fn_name);
62-
+extern void EnforceCUDNNLoaded(const char* fn_name);
63-
#define DECLARE_DYNAMIC_LOAD_CUDNN_WRAP(__name) \
64-
struct DynLoad__##__name { \
65-
template <typename... Args> \
66-
@@ -38,7 +38,9 @@ TEST_API extern void EnforceCUDNNLoaded(const char* fn_name);
38+
@@ -38,7 +38,9 @@ extern void EnforceCUDNNLoaded(const char* fn_name);
6739
cudnn_dso_handle = phi::dynload::GetCUDNNDsoHandle(); \
6840
}); \
6941
EnforceCUDNNLoaded(#__name); \

backends/sdaa/tests/unittests/test_custom_pass_sdaa.py

Lines changed: 89 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -99,95 +99,95 @@ def fc_pass_subgraph(input, w, bias):
9999
MODLE_FILE = "./saved_model"
100100
MODLE_FILE2 = "./silu_fuse_model"
101101

102-
103-
class TestCustomPassSilu(unittest.TestCase):
104-
def setUp(self):
105-
paddle.jit.save(func_silu, MODLE_FILE2)
106-
107-
def test_silu_fuse(self):
108-
with paddle.pir_utils.OldIrGuard():
109-
paddle.disable_static()
110-
config = paddle.inference.Config()
111-
config.set_prog_file(MODLE_FILE2 + ".pdmodel")
112-
config.enable_memory_optim()
113-
config.enable_custom_device("sdaa")
114-
config.switch_ir_optim(True)
115-
pass_builder = config.pass_builder()
116-
pass_builder.append_pass("custom_silu_fuse_pass")
117-
print(pass_builder.all_passes())
118-
print("IR Optim is: {}".format(config.ir_optim()))
119-
predictor = paddle.inference.create_predictor(config)
120-
121-
np_inputs = [np.random.randn(2, 32).astype("float32")]
122-
input_names = predictor.get_input_names()
123-
for i, name in enumerate(input_names):
124-
input_tensor = predictor.get_input_handle(name)
125-
input_tensor.copy_from_cpu(np_inputs[i])
126-
127-
predictor.run()
128-
results = []
129-
output_names = predictor.get_output_names()
130-
for i, name in enumerate(output_names):
131-
output_tensor = predictor.get_output_handle(name)
132-
output_data = output_tensor.copy_to_cpu()
133-
results.append(output_data)
134-
np.testing.assert_allclose(
135-
results,
136-
paddle.nn.functional.silu(paddle.to_tensor(np_inputs)).numpy(),
137-
rtol=1e-5,
138-
)
139-
paddle.enable_static()
140-
141-
142-
class TestCustomFcPass(unittest.TestCase):
143-
def setUp(self):
144-
self.model_name = "fc"
145-
paddle.jit.save(fc_pass_subgraph, self.model_name)
146-
147-
self.batch_size = 64
148-
149-
def test_custom_fc_n(self):
150-
with paddle.pir_utils.OldIrGuard():
151-
config = paddle.inference.Config()
152-
config.set_prog_file(self.model_name + ".pdmodel")
153-
config.enable_memory_optim()
154-
config.enable_custom_device("sdaa")
155-
pass_builder = config.pass_builder()
156-
pass_builder.append_pass("custom_fc")
157-
predictor = paddle.inference.create_predictor(config)
158-
159-
np_inputs = [
160-
np.random.randn(self.batch_size, 200).astype("float32"),
161-
np.random.randn(200, 2).astype("float32"),
162-
np.random.randn(2).astype("float32"),
163-
]
164-
input_names = predictor.get_input_names()
165-
for i, name in enumerate(input_names):
166-
input_tensor = predictor.get_input_handle(name)
167-
input_tensor.copy_from_cpu(np_inputs[i])
168-
169-
predictor.run()
170-
results = []
171-
output_names = predictor.get_output_names()
172-
for i, name in enumerate(output_names):
173-
output_tensor = predictor.get_output_handle(name)
174-
output_data = output_tensor.copy_to_cpu()
175-
results.append(output_data)
176-
177-
with paddle.base.dygraph.guard(paddle.CPUPlace()):
178-
cpu_output = paddle._legacy_C_ops.fc(
179-
paddle.to_tensor(np_inputs[0]),
180-
paddle.to_tensor(np_inputs[1]),
181-
paddle.to_tensor(np_inputs[2]),
182-
"activation_type",
183-
"",
184-
"in_num_col_dims",
185-
1,
186-
)
187-
188-
np.testing.assert_allclose(
189-
results[0], cpu_output.numpy(), rtol=1e-4, atol=1e-2
190-
)
102+
# This case is deleted because paddle no longer support old IR in recent update.
103+
# class TestCustomPassSilu(unittest.TestCase):
104+
# def setUp(self):
105+
# paddle.jit.save(func_silu, MODLE_FILE2)
106+
107+
# def test_silu_fuse(self):
108+
# with paddle.pir_utils.OldIrGuard():
109+
# paddle.disable_static()
110+
# config = paddle.inference.Config()
111+
# config.set_prog_file(MODLE_FILE2 + ".pdmodel")
112+
# config.enable_memory_optim()
113+
# config.enable_custom_device("sdaa")
114+
# config.switch_ir_optim(True)
115+
# pass_builder = config.pass_builder()
116+
# pass_builder.append_pass("custom_silu_fuse_pass")
117+
# print(pass_builder.all_passes())
118+
# print("IR Optim is: {}".format(config.ir_optim()))
119+
# predictor = paddle.inference.create_predictor(config)
120+
121+
# np_inputs = [np.random.randn(2, 32).astype("float32")]
122+
# input_names = predictor.get_input_names()
123+
# for i, name in enumerate(input_names):
124+
# input_tensor = predictor.get_input_handle(name)
125+
# input_tensor.copy_from_cpu(np_inputs[i])
126+
127+
# predictor.run()
128+
# results = []
129+
# output_names = predictor.get_output_names()
130+
# for i, name in enumerate(output_names):
131+
# output_tensor = predictor.get_output_handle(name)
132+
# output_data = output_tensor.copy_to_cpu()
133+
# results.append(output_data)
134+
# np.testing.assert_allclose(
135+
# results,
136+
# paddle.nn.functional.silu(paddle.to_tensor(np_inputs)).numpy(),
137+
# rtol=1e-5,
138+
# )
139+
# paddle.enable_static()
140+
141+
# This case is deleted because paddle no longer support old IR in recent update.
142+
# class TestCustomFcPass(unittest.TestCase):
143+
# def setUp(self):
144+
# self.model_name = "fc"
145+
# paddle.jit.save(fc_pass_subgraph, self.model_name)
146+
147+
# self.batch_size = 64
148+
149+
# def test_custom_fc_n(self):
150+
# with paddle.pir_utils.OldIrGuard():
151+
# config = paddle.inference.Config()
152+
# config.set_prog_file(self.model_name + ".pdmodel")
153+
# config.enable_memory_optim()
154+
# config.enable_custom_device("sdaa")
155+
# pass_builder = config.pass_builder()
156+
# pass_builder.append_pass("custom_fc")
157+
# predictor = paddle.inference.create_predictor(config)
158+
159+
# np_inputs = [
160+
# np.random.randn(self.batch_size, 200).astype("float32"),
161+
# np.random.randn(200, 2).astype("float32"),
162+
# np.random.randn(2).astype("float32"),
163+
# ]
164+
# input_names = predictor.get_input_names()
165+
# for i, name in enumerate(input_names):
166+
# input_tensor = predictor.get_input_handle(name)
167+
# input_tensor.copy_from_cpu(np_inputs[i])
168+
169+
# predictor.run()
170+
# results = []
171+
# output_names = predictor.get_output_names()
172+
# for i, name in enumerate(output_names):
173+
# output_tensor = predictor.get_output_handle(name)
174+
# output_data = output_tensor.copy_to_cpu()
175+
# results.append(output_data)
176+
177+
# with paddle.base.dygraph.guard(paddle.CPUPlace()):
178+
# cpu_output = paddle._legacy_C_ops.fc(
179+
# paddle.to_tensor(np_inputs[0]),
180+
# paddle.to_tensor(np_inputs[1]),
181+
# paddle.to_tensor(np_inputs[2]),
182+
# "activation_type",
183+
# "",
184+
# "in_num_col_dims",
185+
# 1,
186+
# )
187+
188+
# np.testing.assert_allclose(
189+
# results[0], cpu_output.numpy(), rtol=1e-4, atol=1e-2
190+
# )
191191

192192

193193
class TestCustomConvBnFusedPass(unittest.TestCase):

0 commit comments

Comments
 (0)