Skip to content
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

Add is_floating_point and div_ PyTorch ops #7128

Merged
merged 5 commits into from
Dec 18, 2020
Merged
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
13 changes: 13 additions & 0 deletions python/tvm/relay/frontend/pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2059,9 +2059,21 @@ def scatter_add(self, inputs, input_types):
src = inputs[3]
return _op.scatter_add(data, index, src, axis=axis)

def is_floating_point(self, inputs, input_types):
assert len(inputs) == 1

if isinstance(inputs[0], _expr.Expr):
input_type = self.infer_type(inputs[0]).dtype
else:
input_type = input_types[0]

is_float = input_type in ["float32", "float64", "float16"]
return _expr.const(is_float)

# Operator mappings
def create_convert_map(self):
self.convert_map = {
"aten::is_floating_point": self.is_floating_point,
"aten::pixel_shuffle": self.pixel_shuffle,
"aten::device": self.none,
"prim::device": self.none,
Expand All @@ -2077,6 +2089,7 @@ def create_convert_map(self):
"aten::div": self.make_elemwise("divide"),
"aten::div_": self.make_elemwise("divide"),
"aten::floor_divide": self.make_elemwise("floor_divide"),
"aten::floor_divide_": self.make_elemwise("floor_divide"),
"aten::true_divide": self.make_elemwise("divide"),
"aten::addcdiv": self.addcdiv,
"aten::addcmul": self.addcmul,
Expand Down