mirror of
https://github.com/ml-explore/mlx.git
synced 2025-09-18 18:28:12 +08:00
fix: handle linspace function when num is 1 (#602)
* fix: handle linspace function when num is 1 * add comment * fix test case * remove breakpoint
This commit is contained in:

committed by
GitHub

parent
4fd2fb84a6
commit
11a9fd40f0
@@ -148,6 +148,9 @@ array linspace(
|
||||
msg << "[linspace] number of samples, " << num << ", must be non-negative.";
|
||||
throw std::invalid_argument(msg.str());
|
||||
}
|
||||
if (num == 1) {
|
||||
return astype(array({start}), dtype, to_stream(s));
|
||||
}
|
||||
array sequence = arange(0, num, float32, to_stream(s));
|
||||
float step = (stop - start) / (num - 1);
|
||||
return astype(
|
||||
|
Reference in New Issue
Block a user