!44724 fix rewrite get attribute issue and data sink bug

Merge pull request !44724 from 于振华/fix_rewrite_get_attr_fail_1027
This commit is contained in:
i-robot 2022-10-29 00:53:30 +00:00 committed by Gitee
commit 12d8b5db7d
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
3 changed files with 11 additions and 11 deletions

View File

@ -84,8 +84,9 @@ class Node:
"""
self._node_type: NodeType = node_type
self._ast_node: Optional[ast.AST] = ast_node
self._attribute: {str, object} = \
Node._get_cell_or_prim_op_attribute(instance) if node_type == NodeType.CallModule else {}
self._attribute: {str, object} = {}
if node_type in (NodeType.CallModule, NodeType.CallCell, NodeType.CallPrimitive):
self._attribute = Node._get_cell_or_prim_op_attribute(instance)
self._instance = instance
self._name = name
self._func: Optional[ScopedValue] = func

View File

@ -131,7 +131,7 @@ def _generate_network_with_dataset(network, dataset_helper, queue_name):
else:
(min_shapes, max_shapes) = dataset_helper.dynamic_min_max_shapes()
if network.get_inputs() and None not in network.get_inputs():
_check_inputs(network, dataset_shapes, dataset_types)
_check_inputs(network.get_inputs(), dataset_shapes, dataset_types)
min_shapes, max_shapes = None, None
elif context.get_context("mode") == context.PYNATIVE_MODE:
dataset_shapes = tuple([(-2,)] * len(dataset_shapes))
@ -141,11 +141,10 @@ def _generate_network_with_dataset(network, dataset_helper, queue_name):
return network
def _check_inputs(network, dataset_shapes, dataset_types):
def _check_inputs(network_shapes, dataset_shapes, dataset_types):
"""
Check if set inputs are correct.
"""
network_shapes = network.get_inputs()
for tensor_index, ele_dataset_shape in enumerate(dataset_shapes):
set_inputs_shape = list(network_shapes[tensor_index].shape)
inputs_shape = list(ele_dataset_shape)

View File

@ -43,7 +43,7 @@ def test_replicationpad1d_2d(mode):
Description: Infer process of ReplicationPad1d with 2 types of parameters.
Expectation: success
"""
context.set_context(mode=mode, device_target="GPU")
context.set_context(mode=mode)
# Test functionality with 2D tensor as input
x = Tensor(np.array([[0, 1, 2, 3], [4, 5, 6, 7]]).astype(np.float16))
net = Net1d((3, 1))
@ -69,7 +69,7 @@ def test_replicationpad1d_3d(mode):
Description: Infer process of ReplicationPad1d with 2 types of parameters.
Expectation: success
"""
context.set_context(mode=mode, device_target="GPU")
context.set_context(mode=mode)
# Test functionality with 3D tensor input
x = Tensor(np.array([[[0, 1, 2, 3], [4, 5, 6, 7]]]).astype(np.float32))
net = Net1d((3, 1))
@ -96,7 +96,7 @@ def test_replicationpad2d_3d(mode):
Description: Infer process of ReplicationPad2d with three type parameters.
Expectation: success
"""
context.set_context(mode=mode, device_target="GPU")
context.set_context(mode=mode)
# Test functionality with 3D tensor as input
x = Tensor(np.array([[[0, 1, 2], [3, 4, 5], [6, 7, 8]]]).astype(np.float32))
net = Net2d((1, 1, 2, 0))
@ -124,7 +124,7 @@ def test_replicationpad2d_4d(mode):
Description: Infer process of ReplicationPad2d with three type parameters.
Expectation: success
"""
context.set_context(mode=mode, device_target="GPU")
context.set_context(mode=mode)
# Test functionality with 4D tensor as input
x = Tensor(np.array([[[[0, 1, 2], [3, 4, 5], [6, 7, 8]]]]).astype(np.int32))
net = Net2d((1, 1, 2, 0))
@ -152,7 +152,7 @@ def test_replicationpad3d_4d(mode):
Description: Infer process of ReplicationPad3d with three type parameters.
Expectation: success
"""
context.set_context(mode=mode, device_target="GPU")
context.set_context(mode=mode)
# Test functionality with 4D tensor as input
x = Tensor(np.array([[[[[0, 1, 2], [3, 4, 5], [6, 7, 8]]]]]).astype(np.int32))
net = Net3d((1, 1, 2, 0, 1, 1))
@ -186,7 +186,7 @@ def test_replicationpad3d_5d(mode):
Description: Infer process of ReplicationPad3d with three type parameters.
Expectation: success
"""
context.set_context(mode=mode, device_target="GPU")
context.set_context(mode=mode)
# Test functionality with 5D tensor as input
x = Tensor(np.array([[[[[0, 1, 2], [3, 4, 5], [6, 7, 8]]]]]).astype(np.float32))
net = Net3d((1, 1, 2, 0, 1, 1))