Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions aiter/jit/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,7 @@ def convert(d_ops: dict):
"_QuantType",
"init_custom_ar",
"greedy_sample",
"random_sample_outer_exponential",
"random_sample",
"mixed_sample",
"exponential",
Expand Down
20 changes: 20 additions & 0 deletions aiter/ops/sample.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ def greedy_sample(
) -> None: ...


@compile_ops("module_sample")
def random_sample_outer_exponential(
out: Tensor,
input: Tensor,
exponentials: Tensor,
temperatures: Tensor,
eps: float = 1e-10,
) -> None: ...


@compile_ops("module_sample")
def random_sample(
out: Tensor,
Expand All @@ -27,6 +37,16 @@ def random_sample(
) -> None: ...


@compile_ops("module_sample")
def mixed_sample_outer_exponential(
out: Tensor,
input: Tensor,
exponentials: Tensor,
temperatures: Tensor,
eps: float = 1e-10,
) -> None: ...


@compile_ops("module_sample")
def mixed_sample(
out: Tensor,
Expand Down
14 changes: 14 additions & 0 deletions csrc/include/rocm_ops.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,13 @@

#define SAMPLE_PYBIND \
m.def("greedy_sample", &aiter::greedy_sample, py::arg("out"), py::arg("input")); \
m.def("random_sample_outer_exponential", \
&aiter::random_sample_outer_exponential, \
py::arg("out"), \
py::arg("input"), \
py::arg("exponentials"), \
py::arg("temperature"), \
py::arg("eps") = 1e-10); \
m.def("random_sample", \
&aiter::random_sample, \
py::arg("out"), \
Expand All @@ -1147,6 +1154,13 @@
py::arg("lambd") = 1.0, \
py::arg("generator") = std::nullopt, \
py::arg("eps") = 1e-10); \
m.def("mixed_sample_outer_exponential", \
&aiter::mixed_sample_outer_exponential, \
py::arg("out"), \
py::arg("input"), \
py::arg("exponentials"), \
py::arg("temperature"), \
py::arg("eps") = 1e-10); \
m.def("mixed_sample", \
&aiter::mixed_sample, \
py::arg("out"), \
Expand Down
13 changes: 13 additions & 0 deletions csrc/include/sample.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,32 @@ namespace aiter {

void greedy_sample(torch::Tensor& out, torch::Tensor& input);

void random_sample_outer_exponential(torch::Tensor& out,
torch::Tensor& input,
torch::Tensor& exponentials,
torch::Tensor& temperatures,
float eps = 1e-10);

void random_sample(torch::Tensor& out,
torch::Tensor& input,
torch::Tensor& temperatures,
float lambd = 1.0,
std::optional<at::Generator> generator = std::nullopt,
float eps = 1e-10);

void mixed_sample_outer_exponential(torch::Tensor& out,
torch::Tensor& input,
torch::Tensor& exponentials,
torch::Tensor& temperatures,
float eps = 1e-10);

void mixed_sample(torch::Tensor& out,
torch::Tensor& input,
torch::Tensor& temperatures,
float lambd = 1.0,
std::optional<at::Generator> generator = std::nullopt,
float eps = 1e-10);

void exponential(torch::Tensor& out,
float lambd = 1.0,
std::optional<at::Generator> generator = std::nullopt,
Expand Down
Loading