Skip to content

SwinTransformer模型转换失败 #1090

Open
@UnlimitedWand

Description

@UnlimitedWand

问题描述

SwinTransformer模型转换失败,使用本仓库转换代码以及模型

运行环境,aarch64, torch是cpu版本,2.5.1和1.10.2都失败,同样的报错
PaddlePaddle = 2.6.1:
X2Paddle = 1.5.0

  • 错误信息
  • warnings.warn(
    Fail to generate inference model! Problem happened while export inference model from python code '/work/code/X2Paddle/test_benchmark/PyTorch/SwinTransformer/pd_model_trace/x2paddle_code.py';

===================Error Information===============
Traceback (most recent call last):
File "/work/code/X2Paddle/test_benchmark/PyTorch/SwinTransformer/convert_trace.py", line 27, in
pytorch2paddle(torch_module,
File "/opt/py310/lib/python3.10/site-packages/x2paddle/convert.py", line 398, in pytorch2paddle
mapper.paddle_graph.gen_model(save_dir,
File "/opt/py310/lib/python3.10/site-packages/x2paddle/core/program.py", line 308, in gen_model
raise e
File "/opt/py310/lib/python3.10/site-packages/x2paddle/core/program.py", line 302, in gen_model
self.dygraph2static(save_dir, input_shapes, input_types)
File "/opt/py310/lib/python3.10/site-packages/x2paddle/core/program.py", line 584, in dygraph2static
paddle.jit.save(static_model,
File "/opt/py310/lib/python3.10/site-packages/decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
File "/opt/py310/lib/python3.10/site-packages/paddle/base/wrapped_decorator.py", line 26, in impl
return wrapped_func(*args, **kwargs)
File "/opt/py310/lib/python3.10/site-packages/paddle/jit/api.py", line 809, in wrapper
func(layer, path, input_spec, **configs)
File "/opt/py310/lib/python3.10/site-packages/decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
File "/opt/py310/lib/python3.10/site-packages/paddle/base/wrapped_decorator.py", line 26, in impl
return wrapped_func(*args, **kwargs)
File "/opt/py310/lib/python3.10/site-packages/paddle/base/dygraph/base.py", line 68, in impl
return func(*args, **kwargs)
File "/opt/py310/lib/python3.10/site-packages/paddle/jit/api.py", line 1104, in save
static_func.concrete_program_specify_input_spec(
File "/opt/py310/lib/python3.10/site-packages/paddle/jit/dy2static/program_translator.py", line 986, in concrete_program_specify_input_spec
concrete_program, _ = self.get_concrete_program(
File "/opt/py310/lib/python3.10/site-packages/paddle/jit/dy2static/program_translator.py", line 875, in get_concrete_program
concrete_program, partial_program_layer = self._program_cache[
File "/opt/py310/lib/python3.10/site-packages/paddle/jit/dy2static/program_translator.py", line 1648, in getitem
self._caches[item_id] = self._build_once(item)
File "/opt/py310/lib/python3.10/site-packages/paddle/jit/dy2static/program_translator.py", line 1575, in _build_once
concrete_program = ConcreteProgram.from_func_spec(
File "/opt/py310/lib/python3.10/site-packages/decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
File "/opt/py310/lib/python3.10/site-packages/paddle/base/wrapped_decorator.py", line 26, in impl
return wrapped_func(*args, **kwargs)
File "/opt/py310/lib/python3.10/site-packages/paddle/base/dygraph/base.py", line 68, in impl
return func(*args, **kwargs)
File "/opt/py310/lib/python3.10/site-packages/paddle/jit/dy2static/program_translator.py", line 1346, in from_func_spec
error_data.raise_new_exception()
File "/opt/py310/lib/python3.10/site-packages/paddle/jit/dy2static/error.py", line 452, in raise_new_exception
raise new_exception from None
AssertionError: In transformed code:

File "/work/code/X2Paddle/test_benchmark/PyTorch/SwinTransformer/pd_model_trace/x2paddle_code.py", line 545, in forward
    layers_0_downsample_reduction_weight = self.layers_0_downsample_reduction_weight
    x274 = paddle.matmul(x=x272, y=layers_0_downsample_reduction_weight, transpose_y=True)
    x274 = paddle.add(x=x274, y=x47)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
    x276 = 0
    x277 = 2

File "/opt/py310/lib/python3.10/site-packages/paddle/tensor/math.py", line 699, in add
    return _elementwise_op(LayerHelper('elementwise_add', **locals()))
File "/opt/py310/lib/python3.10/site-packages/paddle/tensor/math.py", line 580, in _elementwise_op
    assert y is not None, f'y cannot be None in {original_op_type}'

AssertionError: y cannot be None in elementwise_add
  • 模型来源
    本仓库提供的链接

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions