MCPcopy Create free account
hub / github.com/apache/tvm / generate_np_inputs

Function generate_np_inputs

tests/python/relax/test_frontend_stablehlo.py:41–63  ·  view source on GitHub ↗

Generate numpy data as the inputs of model Parameters ---------- input_shapes: Union[Tuple, List[Tuple]] shapes for inputs dtype: str the data type of inputs Results ------- out: List[np.ndarray] numpy input data

(
    input_shapes: tuple | list[tuple], dtype: str = "float32"
)

Source from the content-addressed store, hash-verified

39
40
41def generate_np_inputs(
42 input_shapes: tuple | list[tuple], dtype: str = "float32"
43) -> np.ndarray | list[np.ndarray]:
44 """Generate numpy data as the inputs of model
45
46 Parameters
47 ----------
48 input_shapes: Union[Tuple, List[Tuple]]
49 shapes for inputs
50 dtype: str
51 the data type of inputs
52
53 Results
54 -------
55 out: List[np.ndarray]
56 numpy input data
57 """
58 if not isinstance(input_shapes[0], list | tuple):
59 return [np.random.uniform(size=input_shapes).astype(dtype)]
60 out = []
61 for input_shape in input_shapes:
62 out.append(np.random.uniform(size=input_shape).astype(dtype))
63 return out
64
65
66def np2jnp(inputs_np: np.ndarray | list[np.ndarray]):

Callers 2

check_correctnessFunction · 0.85
test_convFunction · 0.85

Calls 3

uniformMethod · 0.80
astypeMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…