未验证 提交 bb271b6d 编写于 作者: Q qingqing01 提交者: GitHub

Remove unit testing for large shape in test_affine_channel_op (#19993)

上级 f50e701b
...@@ -11,6 +11,9 @@ ...@@ -11,6 +11,9 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
"""
Unit testing for affine_channel_op
"""
from __future__ import print_function from __future__ import print_function
...@@ -36,9 +39,9 @@ class TestAffineChannelOp(OpTest): ...@@ -36,9 +39,9 @@ class TestAffineChannelOp(OpTest):
self.op_type = "affine_channel" self.op_type = "affine_channel"
self.init_test_case() self.init_test_case()
x = np.random.random(self.shape).astype("float32") x = np.random.random(self.shape).astype("float64")
scale = np.random.random(self.C).astype("float32") scale = np.random.random(self.C).astype("float64")
bias = np.random.random(self.C).astype("float32") bias = np.random.random(self.C).astype("float64")
y = affine_channel(x, scale, bias, self.layout) y = affine_channel(x, scale, bias, self.layout)
...@@ -59,15 +62,15 @@ class TestAffineChannelOp(OpTest): ...@@ -59,15 +62,15 @@ class TestAffineChannelOp(OpTest):
self.check_grad(['X'], 'Out', no_grad_set=set(['Scale', 'Bias'])) self.check_grad(['X'], 'Out', no_grad_set=set(['Scale', 'Bias']))
def init_test_case(self): def init_test_case(self):
self.shape = [2, 32, 14, 14] self.shape = [2, 8, 12, 12]
self.C = 32 self.C = 8
self.layout = 'NCHW' self.layout = 'NCHW'
class TestAffineChannelNHWC(TestAffineChannelOp): class TestAffineChannelNHWC(TestAffineChannelOp):
def init_test_case(self): def init_test_case(self):
self.shape = [2, 14, 14, 32] self.shape = [2, 12, 12, 16]
self.C = 32 self.C = 16
self.layout = 'NHWC' self.layout = 'NHWC'
def test_check_grad_stopgrad_dx(self): def test_check_grad_stopgrad_dx(self):
...@@ -79,8 +82,8 @@ class TestAffineChannelNHWC(TestAffineChannelOp): ...@@ -79,8 +82,8 @@ class TestAffineChannelNHWC(TestAffineChannelOp):
class TestAffineChannel2D(TestAffineChannelOp): class TestAffineChannel2D(TestAffineChannelOp):
def init_test_case(self): def init_test_case(self):
self.shape = [16, 64] self.shape = [8, 32]
self.C = 64 self.C = 32
self.layout = 'NCHW' self.layout = 'NCHW'
def test_check_grad_stopgrad_dx(self): def test_check_grad_stopgrad_dx(self):
...@@ -90,29 +93,28 @@ class TestAffineChannel2D(TestAffineChannelOp): ...@@ -90,29 +93,28 @@ class TestAffineChannel2D(TestAffineChannelOp):
return return
class TestAffineChannelNCHWLargeShape(TestAffineChannelOp): # TODO(qingqing): disable unit testing for large shape
def init_test_case(self): #class TestAffineChannelNCHWLargeShape(TestAffineChannelOp):
self.shape = [4, 128, 112, 112] # def init_test_case(self):
self.C = 128 # self.shape = [4, 128, 112, 112]
self.layout = 'NCHW' # self.C = 128
# self.layout = 'NCHW'
# since the gradient check is very slow in large shape, so skip check_grad #
def test_check_grad(self): # # since the gradient check is very slow in large shape, so skip check_grad
pass # def test_check_grad(self):
# pass
def test_check_grad_stopgrad_dx(self): #
pass # def test_check_grad_stopgrad_dx(self):
# pass
def test_check_grad_stopgrad_dscale_dbias(self): #
pass # def test_check_grad_stopgrad_dscale_dbias(self):
# pass
class TestAffineChannelNHWCLargeShape(TestAffineChannelNCHWLargeShape): #class TestAffineChannelNHWCLargeShape(TestAffineChannelNCHWLargeShape):
def init_test_case(self): # def init_test_case(self):
self.shape = [64, 32, 32, 128] # self.shape = [64, 32, 32, 128]
self.C = 128 # self.C = 128
self.layout = 'NHWC' # self.layout = 'NHWC'
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册