From 079e230719755790420c703126d3a5f97cf0fdb3 Mon Sep 17 00:00:00 2001 From: masahi <masahi129@gmail.com> Date: Sat, 20 Jan 2018 03:31:51 +0900 Subject: [PATCH] simplify expr in get_const_tuple (#795) * fix upsampling output shape * simplify expr in get_const_tuple --- topi/python/topi/nn/upsampling.py | 5 +++-- topi/python/topi/util.py | 5 ++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/topi/python/topi/nn/upsampling.py b/topi/python/topi/nn/upsampling.py index e1234741e..df77bbdb2 100644 --- a/topi/python/topi/nn/upsampling.py +++ b/topi/python/topi/nn/upsampling.py @@ -1,6 +1,7 @@ """TVM operator upsampling compute.""" from __future__ import absolute_import import tvm +from .. import util def upsampling(data, scale): @@ -21,8 +22,8 @@ def upsampling(data, scale): 4-D with shape [batch, channel, in_height*scale, in_width*scale] """ batch, channel, height, width = data.shape - out_height = height * scale - out_width = width * scale + out_height = util.simplify(height * scale) + out_width = util.simplify(width * scale) return tvm.compute((batch, channel, out_height, out_width), \ lambda n, c, h, w: data[n, c, h/scale, w/scale]) diff --git a/topi/python/topi/util.py b/topi/python/topi/util.py index 246d283cd..00c8b9d42 100644 --- a/topi/python/topi/util.py +++ b/topi/python/topi/util.py @@ -59,9 +59,8 @@ def get_const_tuple(in_tuple): """ out_tuple = () for elem in in_tuple: - if not isinstance(elem, (tvm.expr.IntImm, tvm.expr.UIntImm)): - raise ValueError("Element of input tuple should be const int") - out_tuple = out_tuple + (elem.value, ) + value = get_const_int(elem) + out_tuple = out_tuple + (value, ) return out_tuple -- GitLab