mirror of
https://github.com/ml-explore/mlx.git
synced 2025-12-16 01:49:05 +08:00
* redesign for faster cpu/gpu synch * load + more async CPU * use command encoder API and move more ops to use it * make fence back-end generic + CPU only fence * faster build * fix async eval * fixes + handle temporaries * fix / improve cpu conv * remove unused status, fix siblings * fix extensions * fix * fix no cpu build * format * comments * fix perf regression, remove unecessary abort * fix events, task limit cpu * fix waiting * fix donation / temporaries in normalization
29 lines
585 B
C++
29 lines
585 B
C++
// Copyright © 2023 Apple Inc.
|
|
|
|
#pragma once
|
|
|
|
#include "mlx/array.h"
|
|
#include "mlx/backend/cpu/encoder.h"
|
|
|
|
namespace mlx::core {
|
|
|
|
namespace {
|
|
|
|
template <typename T>
|
|
void arange(T start, T next, array& out, size_t size, Stream stream) {
|
|
auto ptr = out.data<T>();
|
|
auto step_size = next - start;
|
|
auto& encoder = cpu::get_command_encoder(stream);
|
|
encoder.set_output_array(out);
|
|
encoder.dispatch([ptr, start, step_size, size]() mutable {
|
|
for (int i = 0; i < size; ++i) {
|
|
ptr[i] = start;
|
|
start += step_size;
|
|
}
|
|
});
|
|
}
|
|
|
|
} // namespace
|
|
|
|
} // namespace mlx::core
|