Skip to content

Commit a8dee3b

Browse files
authored
fix convert ut framework problem (PaddlePaddle#35112)
1 parent a5060b5 commit a8dee3b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

python/paddle/fluid/tests/unittests/ir/inference/program_config.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,11 @@ def create_fake_model(program_config):
137137
op_desc._set_attr(name, values)
138138
for name, values in op_config.outputs.items():
139139
op_desc.set_output(name, values)
140-
var_desc = main_block_desc.var(cpt.to_bytes(name))
141-
var_desc.set_type(core.VarDesc.VarType.LOD_TENSOR)
140+
for v in values:
141+
var_desc = main_block_desc.var(cpt.to_bytes(v))
142+
var_desc.set_type(core.VarDesc.VarType.LOD_TENSOR)
143+
var_desc.set_dtype(
144+
convert_np_dtype_to_dtype_(tensor_config.dtype))
142145
op_desc.infer_var_type(main_block_desc)
143146
op_desc.infer_shape(main_block_desc)
144147

python/paddle/fluid/tests/unittests/ir/inference/trt_layer_auto_scan_test.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ def sample_program_configs(self):
100100
attrs=op_attr))
101101

102102
self.update_program_input_and_weight_with_attr(op_attr_list)
103+
# if no weight need to save, we create a place_holder to help seriazlie params.
104+
if not self.program_weights:
105+
self.program_weights = {
106+
"place_holder_weight": TensorConfig(
107+
shape=[1], data=np.array([1]).astype(np.float32))
108+
}
103109
program_config = ProgramConfig(
104110
ops=ops,
105111
weights=self.program_weights,

0 commit comments

Comments
 (0)