MCPcopy Create free account
hub / github.com/RightNow-AI/autokernel / generate_sample_input

Function generate_sample_input

verify.py:202–216  ·  view source on GitHub ↗

Generate a sample input tensor from a shape string like '1,2048'.

(
    input_shape: str,
    dtype: torch.dtype,
    device: str = "cuda",
    seed: int = 42,
)

Source from the content-addressed store, hash-verified

200# ---------------------------------------------------------------------------
201
202def generate_sample_input(
203 input_shape: str,
204 dtype: torch.dtype,
205 device: str = "cuda",
206 seed: int = 42,
207) -> torch.Tensor:
208 """Generate a sample input tensor from a shape string like '1,2048'."""
209 dims = [int(d.strip()) for d in input_shape.split(",")]
210 torch.manual_seed(seed)
211
212 if dtype in (torch.int32, torch.int64, torch.long):
213 # For language models, generate token IDs (assume vocab size ~32000)
214 return torch.randint(0, 32000, dims, device=device, dtype=dtype)
215 else:
216 return torch.randn(dims, device=device, dtype=dtype)
217
218
219def infer_input_type(model: nn.Module) -> str:

Callers 1

make_model_inputFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected