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

piztneat  于 4个月前  发布在  其他
关注(0)|答案(1)|浏览(43)

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

2izufjch

2izufjch1#

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

相关问题