MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / _shape_equal

Function _shape_equal

imperative/python/megengine/xla/rules/utils.py:45–65  ·  view source on GitHub ↗
(lhs_shape, rhs_shape)

Source from the content-addressed store, hash-verified

43
44
45def _shape_equal(lhs_shape, rhs_shape):
46 lhs_shape = lhs_shape.tolist() if isinstance(lhs_shape, np.ndarray) else lhs_shape
47 rhs_shape = rhs_shape.tolist() if isinstance(rhs_shape, np.ndarray) else rhs_shape
48 assert isinstance(lhs_shape, (tuple, list)) and isinstance(
49 rhs_shape, (tuple, list)
50 ), f"lhs_shape: {lhs_shape}{type(lhs_shape)}, rhs_shape: {rhs_shape}{type(rhs_shape)}"
51 if len(lhs_shape) == 0 and len(rhs_shape) == 0:
52 return True
53 if len(lhs_shape) != 0:
54 assert isinstance(lhs_shape[0], (int, np.int32)), f"{lhs_shape}, {rhs_shape}"
55 if len(rhs_shape) != 0:
56 assert isinstance(rhs_shape[0], (int, np.int32)), f"{lhs_shape}, {rhs_shape}"
57
58 if len(lhs_shape) != len(rhs_shape):
59 return False
60
61 for l, r in zip(lhs_shape, rhs_shape):
62 if l != r:
63 return False
64
65 return True
66
67
68def _check_shape(actual, ref):

Callers 14

lowering_opsFunction · 0.85
_reduceFunction · 0.85
reduce_lowerFunction · 0.85
_check_shapeFunction · 0.85
batched_matmul_lowerFunction · 0.85
_sort_according_to_keyFunction · 0.85
argsort_backward_lowerFunction · 0.85
rng_uint_generatorFunction · 0.85
broadcast_toFunction · 0.85
reshapeFunction · 0.85
linspaceFunction · 0.85
fill_like_lowerFunction · 0.85

Calls 1

tolistMethod · 0.80

Tested by

no test coverage detected