From dev-return-3337-archive-asf-public=cust-asf.ponee.io@singa.incubator.apache.org Wed Aug 14 13:45:13 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 8EAEC1802C7 for ; Wed, 14 Aug 2019 15:45:13 +0200 (CEST) Received: (qmail 67864 invoked by uid 500); 14 Aug 2019 13:45:13 -0000 Mailing-List: contact dev-help@singa.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@singa.incubator.apache.org Delivered-To: mailing list dev@singa.incubator.apache.org Received: (qmail 67854 invoked by uid 99); 14 Aug 2019 13:45:13 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Aug 2019 13:45:13 +0000 From: GitBox To: dev@singa.apache.org Subject: [GitHub] [incubator-singa] pinpom commented on a change in pull request #499: SINGA -475 add Div operator Message-ID: <156579031286.10134.16661793551909627318.gitbox@gitbox.apache.org> Date: Wed, 14 Aug 2019 13:45:12 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit pinpom commented on a change in pull request #499: SINGA -475 add Div operator URL: https://github.com/apache/incubator-singa/pull/499#discussion_r313881460 ########## File path: test/python/test_operation.py ########## @@ -791,69 +791,23 @@ def test_Sub_cpu(self): x1.to_device(cpu_dev) dy.to_device(cpu_dev) - result = autograd.sub(x0, x1) + result = autograd.div(x0, x1) dx0, dx1 = result.creator.backward(dy.data) - DX0 = np.multiply(DY, 1.0) - DX1 = np.multiply(DY, -1.0) + G0 = 1.0 / X1 + DX0 = np.multiply(G0, DY) + G1 = np.divide(-X0, np.square(X1)) + DX1 = np.multiply(G1, DY) np.testing.assert_array_almost_equal(tensor.to_numpy(result), XT, decimal=5) np.testing.assert_array_almost_equal(tensor.to_numpy(tensor.from_raw_tensor(dx0)), DX0, decimal=5) np.testing.assert_array_almost_equal(tensor.to_numpy(tensor.from_raw_tensor(dx1)), DX1, decimal=5) - - def test_Sub_gpu(self): + + def test_Div_gpu(self): X0 = np.array([7, -5, 0.2, -0.1, 0.3, 4]).reshape(3, 2).astype(np.float32) X1 = np.array([0.6, -1.3, 0.1, -0.1, 0.4, 0.3]).reshape(3, 2).astype(np.float32) - XT = np.subtract(X0, X1) - - DY = np.ones((3, 2), dtype = np.float32) - x0 = tensor.from_numpy(X0) - x1 = tensor.from_numpy(X1) - dy = tensor.from_numpy(DY) - x0.to_device(gpu_dev) - x1.to_device(gpu_dev) - dy.to_device(gpu_dev) + XT = np.divide(X0, X1) - - result = autograd.sub(x0, x1) - dx0, dx1 = result.creator.backward(dy.data) - DX0 = np.multiply(DY, 1.0) - DX1 = np.multiply(DY, -1.0) - - np.testing.assert_array_almost_equal(tensor.to_numpy(result), XT, decimal=5) - np.testing.assert_array_almost_equal(tensor.to_numpy(tensor.from_raw_tensor(dx0)), DX0, decimal=5) - np.testing.assert_array_almost_equal(tensor.to_numpy(tensor.from_raw_tensor(dx1)), DX1, decimal=5) - - def test_Pow_cpu(self): Review comment: i guess i misused git command so some functions were accidently deleted. I'll create a new branch from latest master branch and create new PR for this operator ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org With regards, Apache Git Services