Skip to content

Commit

Permalink
removed Evision.Backend.random_{uniform,normal}
Browse files Browse the repository at this point in the history
  • Loading branch information
cocoa-xu committed Jun 1, 2024
1 parent 0bf92d1 commit 031be95
Showing 1 changed file with 0 additions and 45 deletions.
45 changes: 0 additions & 45 deletions lib/evision/backend.ex
Original file line number Diff line number Diff line change
Expand Up @@ -107,51 +107,6 @@ defmodule Evision.Backend do
|> to_nx(out)
end

@impl true
@spec random_uniform(Nx.Tensor.t(), number(), number(), any()) :: Nx.Tensor.t()
def random_uniform(%T{type: {s, _} = type, shape: shape} = out, min, max, _backend_options)
when s in [:u, :s, :f] do
min = to_number(min)
max = to_number(max)

Evision.randu(
reject_error(Evision.Mat.zeros(shape, type)),
reject_error(Evision.Mat.number(min, type)),
reject_error(Evision.Mat.number(max, type))
)
|> reject_error()
|> Evision.Mat.as_type(type)
|> reject_error()
|> to_nx(out)
end

def random_uniform(%T{type: {:c, _}, shape: _shape} = _out, _min, _max, _backend_options) do
raise ArgumentError, "Complex number is not support yet"
end

@impl true
@spec random_normal(Nx.Tensor.t(), number | Nx.Tensor.t(), number | Nx.Tensor.t(), any) ::
Nx.Tensor.t()
def random_normal(%T{type: {s, _} = type, shape: shape} = out, mu, sigma, _backend_options)
when s in [:u, :s, :f] do
mu = to_number(mu)
sigma = to_number(sigma)

Evision.randn(
reject_error(Evision.Mat.zeros(shape, type)),
reject_error(Evision.Mat.number(mu, type)),
reject_error(Evision.Mat.number(sigma, type))
)
|> reject_error()
|> Evision.Mat.as_type(type)
|> reject_error()
|> to_nx(out)
end

def random_normal(%T{type: {:c, _}, shape: _shape} = _out, _min, _max, _backend_options) do
raise ArgumentError, "Complex number is not support yet"
end

@impl true
@spec backend_copy(Nx.Tensor.t(), atom, any) :: Nx.Tensor.t()
def backend_copy(tensor, Nx.Tensor, opts) do
Expand Down

0 comments on commit 031be95

Please sign in to comment.