From dev-return-3444-archive-asf-public=cust-asf.ponee.io@singa.incubator.apache.org Mon Aug 19 01:42:08 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 D1EF9180669 for ; Mon, 19 Aug 2019 03:42:07 +0200 (CEST) Received: (qmail 66420 invoked by uid 500); 19 Aug 2019 01:42:07 -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 66396 invoked by uid 99); 19 Aug 2019 01:42:07 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Aug 2019 01:42:07 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 805C11A33D9 for ; Mon, 19 Aug 2019 01:42:06 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -112.199 X-Spam-Level: X-Spam-Status: No, score=-112.199 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_HI=-5, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-he-de.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id l44hzTTWkJnV for ; Mon, 19 Aug 2019 01:42:03 +0000 (UTC) Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=207.244.88.153; helo=mail.apache.org; envelope-from=jira@apache.org; receiver= Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx1-he-de.apache.org (ASF Mail Server at mx1-he-de.apache.org) with SMTP id 3697E7DC05 for ; Mon, 19 Aug 2019 01:42:02 +0000 (UTC) Received: (qmail 66387 invoked by uid 99); 19 Aug 2019 01:42:01 -0000 Received: from mailrelay1-us-west.apache.org (HELO mailrelay1-us-west.apache.org) (209.188.14.139) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 19 Aug 2019 01:42:01 +0000 Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id B7693E300E for ; Mon, 19 Aug 2019 01:42:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 31B4C277AB for ; Mon, 19 Aug 2019 01:42:00 +0000 (UTC) Date: Mon, 19 Aug 2019 01:42:00 +0000 (UTC) From: "ASF subversion and git services (JIRA)" To: dev@singa.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (SINGA-478) Python 3 uses __itruediv__ instead of __idiv__ MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/SINGA-478?page=3Dcom.atlassian.= jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D16910= 118#comment-16910118 ]=20 ASF subversion and git services commented on SINGA-478: ------------------------------------------------------- Commit 15b6520e7c8f3d0af49b64864a1b3b44ffde25ce in incubator-singa's branch= refs/heads/master from Wei Wang [ https://gitbox.apache.org/repos/asf?p=3Dincubator-singa.git;h=3D15b6520 ] Merge pull request #523 from chrishkchris/SINGA-478 SINGA-478 Improve __itruediv__ in tensor.py > Python 3 uses __itruediv__ instead of __idiv__ > ---------------------------------------------- > > Key: SINGA-478 > URL: https://issues.apache.org/jira/browse/SINGA-478 > Project: Singa > Issue Type: Improvement > Components: Core > Reporter: YEUNG SAI HO > Priority: Major > Time Spent: 1h 40m > Remaining Estimate: 0h > > We need to add=C2=A0 __itruediv__ in tensor.py because the original __idi= v__ is not supported by python 3 anymore. > =C2=A0 > To understand the problem, let's study the following code first: > {code:java} > from singa import tensor > from singa import device > import numpy as np > Y =3D np.ones(shape=3D[10],dtype=3Dnp.float32) * 10.0 > y =3D tensor.from_numpy(Y) > y.to_device(device.get_default_device()) > def divide(y): > =C2=A0 y /=3D 10 > divide(y) > print(tensor.to_numpy(y)) > {code} > =C2=A0Without adding the=C2=A0{color:#333333}__itruediv__{color} function= , the result is as follows, which means that the /=3D operation is not in p= lace:=C2=A0 > {code:java} > [10. 10. 10. 10. 10. 10. 10. 10. 10. 10.] > {code} > After adding the=C2=A0__itruediv__ function, the result is as follows, wh= ich means that the /=3D operation is in place: > {code:java} > [1. 1. 1. 1. 1. 1. 1. 1. 1. 1.] > {code} > This is because the=C2=A0{color:#333333}__idiv__ operation is for python = 2, while=C2=A0__itruediv__ is for python 3. Therefore, if we do not add the= =C2=A0__itruediv__ operator in tensor.py, it just uses a default operation = which is not in place.{color} > =C2=A0 > =C2=A0 -- This message was sent by Atlassian JIRA (v7.6.14#76016)