MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / parse_labels

Function parse_labels

python/paddle/tensor/einsum.py:82–104  ·  view source on GitHub ↗

Parse label strings for all input operands. Parameters ---------- labelstr: The equation's label string operands: The input operands Returns ------- list of full label strings for all input operands

(labelstr: str, operands: Sequence[Tensor])

Source from the content-addressed store, hash-verified

80
81
82def parse_labels(labelstr: str, operands: Sequence[Tensor]) -> list[str]:
83 '''
84 Parse label strings for all input operands.
85
86 Parameters
87 ----------
88 labelstr:
89 The equation's label string
90 operands:
91 The input operands
92
93 Returns
94 -------
95 list of full label strings for all input operands
96 '''
97
98 nop_labels = labelstr.split(',')
99 assert len(nop_labels) == len(operands), (
100 f"Invalid equation: the number of operands is {len(operands)}, "
101 f"but found {len(nop_labels)} segments in the label equation."
102 )
103
104 return list(map(parse_op_labels, nop_labels, operands))
105
106
107def validate_rhs(

Callers 2

preprocessFunction · 0.85
einsumFunction · 0.85

Calls 2

listFunction · 0.85
splitMethod · 0.45

Tested by

no test coverage detected