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

使用paddleslim的模型自动化压缩工具ACT优化TPSMM模型报错 #1879

Open
kiyojimini opened this issue Jun 16, 2024 · 1 comment
Open
Assignees

Comments

@kiyojimini
Copy link

kiyojimini commented Jun 16, 2024

Traceback (most recent call last):
File "run.py", line 212, in
main()
File "run.py", line 205, in main
ac.compress()
File "/data/huangyan/anaconda/anaconda3/envs/yolov5sperson/lib/python3.8/site-packages/paddleslim-0.0.0.dev0-py3.8.egg/paddleslim/auto_compression/compressor.py", line 586, in compress
self.single_strategy_compress(strategy, config, strategy_idx,
File "/data/huangyan/anaconda/anaconda3/envs/yolov5sperson/lib/python3.8/site-packages/paddleslim-0.0.0.dev0-py3.8.egg/paddleslim/auto_compression/compressor.py", line 753, in single_strategy_compress
metric = self.eval_function(self._exe, inference_program,
File "run.py", line 104, in eval_function
pred = exe.run(
File "/data/huangyan/anaconda/anaconda3/envs/yolov5sperson/lib/python3.8/site-packages/paddle/base/executor.py", line 1746, in run
res = self._run_impl(
File "/data/huangyan/anaconda/anaconda3/envs/yolov5sperson/lib/python3.8/site-packages/paddle/base/executor.py", line 1952, in _run_impl
ret = new_exe.run(
File "/data/huangyan/anaconda/anaconda3/envs/yolov5sperson/lib/python3.8/site-packages/paddle/base/executor.py", line 831, in run
tensors = self._new_exe.run(
ValueError: In user code:

File "/data/huangyan/anaconda/anaconda3/envs/paddle/bin/x2paddle", line 8, in <module>
  sys.exit(main())
File "/data/huangyan/anaconda/anaconda3/envs/paddle/lib/python3.7/site-packages/x2paddle/convert.py", line 497, in main
  enable_onnx_checker=args.enable_onnx_checker)
File "/data/huangyan/anaconda/anaconda3/envs/paddle/lib/python3.7/site-packages/x2paddle/convert.py", line 311, in onnx2paddle
  mapper.paddle_graph.gen_model(save_dir)
File "/data/huangyan/anaconda/anaconda3/envs/paddle/lib/python3.7/site-packages/x2paddle/core/program.py", line 297, in gen_model
  self.dygraph2static(save_dir, input_shapes, input_types)
File "/data/huangyan/anaconda/anaconda3/envs/paddle/lib/python3.7/site-packages/x2paddle/core/program.py", line 583, in dygraph2static
  osp.join(save_dir, "inference_model/model"))
File "/data/huangyan/anaconda/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/dygraph/jit.py", line 631, in wrapper
  func(layer, path, input_spec, **configs)
File "/data/huangyan/anaconda/anaconda3/envs/paddle/lib/python3.7/site-packages/decorator.py", line 232, in fun
  return caller(func, *(extras + args), **kw)
File "/data/huangyan/anaconda/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/wrapped_decorator.py", line 25, in __impl__
  return wrapped_func(*args, **kwargs)
File "/data/huangyan/anaconda/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/dygraph/base.py", line 51, in __impl__
  return func(*args, **kwargs)
File "/data/huangyan/anaconda/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/dygraph/jit.py", line 861, in save
  inner_input_spec, with_hook=with_hook)
File "/data/huangyan/anaconda/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 528, in concrete_program_specify_input_spec
  *desired_input_spec, with_hook=with_hook)
File "/data/huangyan/anaconda/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 436, in get_concrete_program
  concrete_program, partial_program_layer = self._program_cache[cache_key]
File "/data/huangyan/anaconda/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 801, in __getitem__
  self._caches[item_id] = self._build_once(item)
File "/data/huangyan/anaconda/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 790, in _build_once
  **cache_key.kwargs)
File "/data/huangyan/anaconda/anaconda3/envs/paddle/lib/python3.7/site-packages/decorator.py", line 232, in fun
  return caller(func, *(extras + args), **kw)
File "/data/huangyan/anaconda/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/wrapped_decorator.py", line 25, in __impl__
  return wrapped_func(*args, **kwargs)
File "/data/huangyan/anaconda/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/dygraph/base.py", line 51, in __impl__
  return func(*args, **kwargs)
File "/data/huangyan/anaconda/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/dygraph/dygraph_to_static/program_translator.py", line 733, in from_func_spec
  outputs = static_func(*inputs)
File "./x2paddle_code.py", line 103, in forward
  x2paddle_onnx__Gemm_190 = paddle.reshape(x=x2paddle_onnx__Flatten_189, shape=[1, 512])
File "/data/huangyan/anaconda/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/tensor/manipulation.py", line 2139, in reshape
  return paddle.fluid.layers.reshape(x=x, shape=shape, name=name)
File "/data/huangyan/anaconda/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/layers/nn.py", line 6450, in reshape
  "XShape": x_shape})
File "/data/huangyan/anaconda/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/layer_helper.py", line 44, in append_op
  return self.main_program.current_block().append_op(*args, **kwargs)
File "/data/huangyan/anaconda/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/framework.py", line 3621, in append_op
  attrs=kwargs.get("attrs", None))
File "/data/huangyan/anaconda/anaconda3/envs/paddle/lib/python3.7/site-packages/paddle/fluid/framework.py", line 2635, in __init__
  for frame in traceback.extract_stack():

InvalidArgumentError: The 'shape' in ReshapeOp is invalid. The input tensor X'size must be equal to the capacity of 'shape'. But received X's shape = [2, 512, 1, 1], X's size = 1024, 'shape' is [1, 512], the capacity of 'shape' is 512.
  [Hint: Expected capacity == in_size, but received capacity:512 != in_size:1024.] (at ../paddle/fluid/operators/reshape_op.cc:234)
  [operator < reshape2 > error]

请问该如何修改呢,期待解答!!

@kiyojimini kiyojimini changed the title 使用paddleslim的模型自动化压缩工具ACT运行示例程序mobileNetV1报错 使用paddleslim的模型自动化压缩工具ACT优化TPSMM模型报错 Jun 16, 2024
@YZW-explorer
Copy link

您好,错误是发生在这里:
... File "./x2paddle_code.py", line 103, in forward x2paddle_onnx__Gemm_190 = paddle.reshape(x=x2paddle_onnx__Flatten_189, shape=[1, 512]) ... InvalidArgumentError: The 'shape' in ReshapeOp is invalid. The input tensor X'size must be equal to the capacity of 'shape'. But received X's shape = [2, 512, 1, 1], X's size = 1024, 'shape' is [1, 512], the capacity of 'shape' is 512. [Hint: Expected capacity == in_size, but received capacity:512 != in_size:1024.] (at ../paddle/fluid/operators/reshape_op.cc:234) [operator < reshape2 > error]
是纬度不匹配的问题,请修改该代码为后再次尝试:
x2paddle_onnx__Gemm_190 = paddle.reshape(x=x2paddle_onnx__Flatten_189, shape=[2, 512])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants