Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【PIR API adaptor No.14-15】Assign and Bilinear #58876

Closed
wants to merge 14 commits into from

Conversation

Liyulingyue
Copy link
Contributor

PR types

Others

PR changes

APIs

Description

#58067 14-15

@paddle-bot paddle-bot bot added the contributor External developers label Nov 9, 2023
@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label Nov 10, 2023
Copy link

paddle-ci-bot bot commented Nov 19, 2023

Sorry to inform you that b58508d's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually.

Copy link
Contributor

@MarioLulab MarioLulab left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work ~

@@ -541,6 +542,7 @@ def test_msra_initializer_bf16(self):


class TestBilinearInitializer(unittest.TestCase):
@test_with_pir_api
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

initializer 相关的 pir 单测无法适配旧 ir,所以需要单独新增 pir 下的单测,可以参考:#59419

@@ -628,6 +630,7 @@ def test_bilinear_initializer_fp16(self):


class TestNumpyArrayInitializer(unittest.TestCase):
@test_with_pir_api
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同上

python/paddle/nn/initializer/Bilinear.py Show resolved Hide resolved
python/paddle/nn/initializer/assign.py Outdated Show resolved Hide resolved
test/legacy_test/test_initializer.py Show resolved Hide resolved
test/legacy_test/test_initializer.py Show resolved Hide resolved
with paddle.static.program_guard(main, startup):
param = paddle.pir.core.create_parameter(
dtype=dtype,
shape=[5, 10],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shape 应与 TestBilinearInitializer.test_bilinear_initializer 单测对齐

Comment on lines 902 to 903
num_ops = 2 if dtype in ["float16", "uint16"] else 1
self.assertEqual(len(checked_ops), num_ops)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

同理,也不需要做 op 数量的判断

num_ops = 2 if dtype in ["float16", "uint16"] else 1
self.assertEqual(len(checked_ops), num_ops)
init_op = checked_ops[0]
self.assertEqual(init_op.type, 'assign_value')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不用再去检查 init_op.type,因为前面的 self.get_init_ops_by_op_name 就是根据 op_name 去获取 op 的。这里改成

self.assertEqual(len(checked_ops), 1)

即可

test/legacy_test/test_initializer.py Outdated Show resolved Hide resolved
def test_numpy_array_initializer_bf16(self):
"""Test the numpy array initializer with bfloat16"""
block = self.test_numpy_array_initializer("uint16")
self.assertTrue(block.ops[1])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这行不需要了

test/legacy_test/test_initializer.py Show resolved Hide resolved
test/legacy_test/test_initializer.py Outdated Show resolved Hide resolved
test/legacy_test/test_initializer.py Outdated Show resolved Hide resolved
test/legacy_test/test_initializer.py Outdated Show resolved Hide resolved
test/legacy_test/test_initializer.py Outdated Show resolved Hide resolved
test/legacy_test/test_initializer.py Outdated Show resolved Hide resolved
test/legacy_test/test_initializer.py Outdated Show resolved Hide resolved
test/legacy_test/test_initializer.py Outdated Show resolved Hide resolved
test/legacy_test/test_initializer.py Outdated Show resolved Hide resolved
@MarioLulab
Copy link
Contributor

MarioLulab commented Dec 18, 2023

张师傅好,这个联动了其他 python api 的迁移问题并且比较紧急,所以我新开了一个 pr 来完成这两个 python api 的迁移~ 可以关注下 #60114
另外还有其他的 pir python api 迁移任务,欢迎张师傅多多认领 😄

#60114 已合入,此 pr 关闭

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource 快乐开源活动issue与PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants