PaddlePaddle / Paddle

PArallel Distributed Deep LEarning: Machine Learning Framework from Industrial Practice (『飞桨』核心框架,深度学习&机器学习高性能单机、分布式训练和跨平台部署)
http://www.paddlepaddle.org/
Apache License 2.0
22.13k stars 5.55k forks source link

AttributeError: module 'paddle' has no attribute 'cinn'. #64945

Open Zoeeeeey opened 4 months ago

Zoeeeeey commented 4 months ago

bug描述 Describe the Bug

您好,在paddle 2.6.1下是否还支持使用cinn?

当调用paddle.cinn.enable_cinn_compiler()时,出现报错AttributeError: module 'paddle' has no attribute 'cinn'

以下这段代码可以复现这个问题。

import paddle
from paddle.static import InputSpec

paddle.enable_static()
paddle.cinn.enable_cinn_compiler()
def create_model():
    x = paddle.static.data(name='x', shape=[None, 32, 32, 3], dtype='float32')
    conv2d = paddle.static.nn.conv2d(input=x, num_filters=6, filter_size=3, stride=2, padding=1)
    pool2d = paddle.static.nn.max_pool2d(input=conv2d, kernel_size=2, stride=2)
    return pool2d

paddle_model = paddle.static.Program()
startup_program = paddle.static.Program()
with paddle.static.program_guard(paddle_model, startup_program):
    model = create_model()

exe = paddle.static.Executor(paddle.CPUPlace())

exe.run(startup_program)

x = paddle.randn([1, 32, 32, 3], dtype='float32')

result = exe.run(paddle_model,
                 feed={'x': x.numpy()},
                 fetch_list=[model])

print(result)

得到的输出:

Traceback (most recent call last):
  File "xxx.py", line 6, in <module>
    paddle.cinn.enable_cinn_compiler()
AttributeError: module 'paddle' has no attribute 'cinn'

其他补充信息 Additional Supplementary Information

No response

will-jl944 commented 4 months ago

可通过paddle.jit.to_static接口的backend参数指定,参考文档(https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/jit/to_static_cn.html#to-static)。