Skip to content

feat(atenlib): logarithmic ops; test aten::full #281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Jan 10, 2023
Merged
Show file tree
Hide file tree
Changes from 3 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
43 changes: 29 additions & 14 deletions onnxscript/function_libs/torch_aten/ops/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2505,46 +2505,61 @@ def aten_linspace(start: float, end: float, steps: int) -> TensorType:
raise NotImplementedError()


def aten_log(self: TensorType) -> TensorType:
@torch_op("log")
def aten_log(self: TFloatOrBFloat16) -> TFloatOrBFloat16:
# log(Tensor self) -> Tensor

raise NotImplementedError()
return op.Log(self)


def aten_log10(self: TensorType) -> TensorType:
@torch_op("aten::log10")
def aten_log10(self: TFloatOrBFloat16) -> TFloatOrBFloat16:
# log10(Tensor self) -> Tensor

raise NotImplementedError()
return op.Div(op.Log(self), op.Log(10.0))


def aten_log1p(self: TensorType) -> TensorType:
@torch_op("aten::log1p")
def aten_log1p(self: TFloatOrBFloat16) -> TFloatOrBFloat16:
# log1p(Tensor self) -> Tensor

raise NotImplementedError()
return op.Log(op.Add(self, 1.0))


def aten_log2(self: TensorType) -> TensorType:
@torch_op("aten::log2")
def aten_log2(self: TFloatOrBFloat16) -> TFloatOrBFloat16:
# log2(Tensor self) -> Tensor

raise NotImplementedError()
return op.Div(op.Log(self), op.Log(2.0))


def aten_logaddexp(self: TensorType, other: TensorType) -> TensorType:
@torch_op("aten::logaddexp")
def aten_logaddexp(self: TFloatOrBFloat16, other: TFloatOrBFloat16) -> TFloatOrBFloat16:
# logaddexp(Tensor self, Tensor other) -> Tensor

raise NotImplementedError()
return op.Log(op.Add(op.Exp(self), op.Exp(other)))


def aten_logaddexp2(self: TensorType, other: TensorType) -> TensorType:
@torch_op("aten::logaddexp2")
def aten_logaddexp2(self: TFloatOrBFloat16, other: TFloatOrBFloat16) -> TFloatOrBFloat16:
# logaddexp2(Tensor self, Tensor other) -> Tensor
summation = op.Add(op.Pow(2.0, self), op.Pow(2.0, other))

raise NotImplementedError()
return op.Log(summation) / op.Log(2.0)


def aten_logcumsumexp(self: TensorType, dim: int) -> TensorType:
@torch_op("aten::logcumsumexp")
def aten_logcumsumexp(self: TFloatOrBFloat16, dim: INT64) -> TFloatOrBFloat16:
# logcumsumexp(Tensor self, int dim) -> Tensor

raise NotImplementedError()
if op.Size(op.Shape(self)) == 0:
# A scalar
result = self
else:
# TODO(justinchuby): Ensure numerical stability
result = op.Log(op.CumSum(op.Exp(self), dim))

return result


def aten_logdet(self: TensorType) -> TensorType:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,13 @@ def wrapped(fn):
"fmod": core_ops.aten_fmod,
"gt": core_ops.aten_gt,
"isinf": core_ops.aten_isinf,
"log": core_ops.aten_log,
"log10": core_ops.aten_log10,
"log1p": core_ops.aten_log1p,
"log2": core_ops.aten_log2,
"logaddexp": core_ops.aten_logaddexp,
"logaddexp2": core_ops.aten_logaddexp2,
"logcumsumexp": core_ops.aten_logcumsumexp,
"lt": core_ops.aten_lt,
"matmul": core_ops.aten_matmul,
"mm": core_ops.aten_mm,
Expand Down