mirror of
https://github.com/ml-explore/mlx.git
synced 2025-09-18 18:28:12 +08:00
Don't use make_unique to create shared_ptr (#902)
The code compiled because shared_ptr's constructor actually accepts unique_ptr.
This commit is contained in:
@@ -95,7 +95,7 @@ array fft_impl(
|
||||
return array(
|
||||
out_shape,
|
||||
out_type,
|
||||
std::make_unique<FFT>(to_stream(s), valid_axes, inverse, real),
|
||||
std::make_shared<FFT>(to_stream(s), valid_axes, inverse, real),
|
||||
{astype(in, in_type, s)});
|
||||
}
|
||||
|
||||
|
@@ -217,7 +217,7 @@ array load(std::shared_ptr<io::Reader> in_stream, StreamOrDevice s) {
|
||||
auto loaded_array = array(
|
||||
shape,
|
||||
dtype,
|
||||
std::make_unique<Load>(to_stream(s), in_stream, offset, swap_endianness),
|
||||
std::make_shared<Load>(to_stream(s), in_stream, offset, swap_endianness),
|
||||
std::vector<array>{});
|
||||
if (col_contiguous) {
|
||||
loaded_array = transpose(loaded_array, s);
|
||||
|
@@ -136,7 +136,7 @@ SafetensorsLoad load_safetensors(
|
||||
auto loaded_array = array(
|
||||
shape,
|
||||
type,
|
||||
std::make_unique<Load>(
|
||||
std::make_shared<Load>(
|
||||
to_stream(s), in_stream, offset + data_offsets.at(0), false),
|
||||
std::vector<array>{});
|
||||
res.insert({item.key(), loaded_array});
|
||||
|
@@ -1267,7 +1267,7 @@ std::pair<std::vector<array>, std::vector<int>> FFT::vmap(
|
||||
{array(
|
||||
out_shape,
|
||||
real_ && inverse_ ? float32 : complex64,
|
||||
std::make_unique<FFT>(stream(), fft_axes, inverse_, real_),
|
||||
std::make_shared<FFT>(stream(), fft_axes, inverse_, real_),
|
||||
{in})},
|
||||
{ax}};
|
||||
}
|
||||
@@ -1377,7 +1377,7 @@ std::pair<std::vector<array>, std::vector<int>> Full::vmap(
|
||||
assert(axes.size() == 1);
|
||||
auto& in = inputs[0];
|
||||
auto out =
|
||||
array(in.shape(), in.dtype(), std::make_unique<Full>(stream()), {in});
|
||||
array(in.shape(), in.dtype(), std::make_shared<Full>(stream()), {in});
|
||||
return {{out}, axes};
|
||||
}
|
||||
|
||||
@@ -1604,7 +1604,7 @@ std::pair<std::vector<array>, std::vector<int>> Log::vmap(
|
||||
{array(
|
||||
in.shape(),
|
||||
in.dtype(),
|
||||
std::make_unique<Log>(stream(), base_),
|
||||
std::make_shared<Log>(stream(), base_),
|
||||
{in})},
|
||||
axes};
|
||||
}
|
||||
@@ -2259,7 +2259,7 @@ std::pair<std::vector<array>, std::vector<int>> RandomBits::vmap(
|
||||
auto out = array(
|
||||
shape,
|
||||
get_dtype(),
|
||||
std::make_unique<RandomBits>(stream(), shape, width_),
|
||||
std::make_shared<RandomBits>(stream(), shape, width_),
|
||||
{key});
|
||||
return {{out}, {kax}};
|
||||
}
|
||||
@@ -2493,7 +2493,7 @@ std::pair<std::vector<array>, std::vector<int>> Scan::vmap(
|
||||
{array(
|
||||
in.shape(),
|
||||
out_dtype,
|
||||
std::make_unique<Scan>(
|
||||
std::make_shared<Scan>(
|
||||
stream(), reduce_type_, axis_ + axis_left, reverse_, inclusive_),
|
||||
{in})},
|
||||
axes};
|
||||
@@ -3303,7 +3303,7 @@ std::pair<std::vector<array>, std::vector<int>> NumberOfElements::vmap(
|
||||
array out = array(
|
||||
std::vector<int>{},
|
||||
dtype_,
|
||||
std::make_unique<NumberOfElements>(stream(), new_axes, inverted_, dtype_),
|
||||
std::make_shared<NumberOfElements>(stream(), new_axes, inverted_, dtype_),
|
||||
inputs);
|
||||
|
||||
return {{out}, {-1}};
|
||||
|
@@ -53,7 +53,7 @@ void eval(std::vector<array> outputs) {
|
||||
}
|
||||
|
||||
auto synchronizer = array(
|
||||
{}, bool_, std::make_unique<Synchronizer>(stream), std::move(outputs));
|
||||
{}, bool_, std::make_shared<Synchronizer>(stream), std::move(outputs));
|
||||
|
||||
size_t depth_counter = 0;
|
||||
recurse = [&](const array& a) {
|
||||
@@ -118,7 +118,7 @@ void eval(std::vector<array> outputs) {
|
||||
}
|
||||
std::shared_ptr<std::promise<void>> p;
|
||||
if (auto it = deps.find(arr.output(0).id()); it != deps.end()) {
|
||||
p = std::make_unique<std::promise<void>>();
|
||||
p = std::make_shared<std::promise<void>>();
|
||||
ps.push_back(p);
|
||||
it->second = p->get_future().share();
|
||||
}
|
||||
|
Reference in New Issue
Block a user