Inefficient Tensor Creation
Description
Using `torch.Tensor()` to directly create a tensor can lead to parsing issues and inefficiency. It is recommended to use the proper methods for tensor creation as outlined in the PyTorch documentation.
Examples
Insecure Code
python
x = torch.Tensor([1, 2, 3])Secure Code
python
x = torch.tensor([1, 2, 3])Remediation
Use the recommended methods for tensor creation, such as `torch.tensor()` or `torch.from_numpy()`
Rule Details
| Field | Value |
|---|---|
| ID | CODE-0103 |
| Category | Performance |
| Severity | LOW |
| CWE | |
| Confidence | HIGH |
| Impact | LOW |
| Likelihood | MEDIUM |
| Exploitability | COMPLEX |
| Tags | performance, parsing |
| OWASP | N/A |