From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id qIERH2Zz+2VDEQEAe85BDQ:P1 (envelope-from ) for ; Thu, 21 Mar 2024 00:38:14 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:58f0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id qIERH2Zz+2VDEQEAe85BDQ (envelope-from ) for ; Thu, 21 Mar 2024 00:38:14 +0100 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=q3U8RjLY; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1710977894; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=RLrEe0Evdb6mvGiqpPrQdd647CPlbOURSwido72GOec=; b=sh/YC/9mFRSaLyXT3+hQT2+OxzZnvdFpnrtKv53yS5uKWELZ04stEcFzggZw5wxyPshWjM VvKUHwEriYgHc+d4DFsK98QhPMhk4szVe1vNV6hzfsvzCcdq8DH31MhAvOWkx6pt0JG6Pp 8mCyfYOy4eZcbjQX5mqKfuYPqNfrC1pu1aq83trzApkW3MmyVm5xbb7NUgTzzf7NfY6hdr JA6JZJvSMtJX6+HkJ94ZmRCYFBHufRfOdNLXiRPyTSRjRB4apdaR55yRn9wHSNReGjuU+F uZeWWrIe0CmHD28M33jod0jCgNkIksBhLXZz328a/RogbOCVPjCO3CAPnCtgAQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=q3U8RjLY; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1710977894; a=rsa-sha256; cv=none; b=tmROqdElk1UKgFH6Umck8dBZhAoOLuz+6NlPWKEMpGeymxw585P5CACosS/LEgBZbszgDQ aWTY/znFU9Av6YK98CQ4b2IcsJSaMc/iyfJNCIhPGbBZ0iP+oRE0x8ulnuZQ+6UqL/lNcK VOYijAXu4GMPxIem6ewpd4AnzgZdL6qnm1y/AcuNG+ICE6rmb2KLuTAnMM+tv/h5S/B4Bb 2k4WNKd1zwZ3ssNP0OhSrsYZ7k/TFO7osXpVoeQE5d8yYA6aL2Ru5qWRr9xFrX2DRW8HgQ r5O5iA12IdFfYx3ijIiWejAH+PmAUjQKd+uGjZwZuJlhlWPKakod8T2UP7Flbg== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 411246FBF5 for ; Thu, 21 Mar 2024 00:38:14 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rn4c8-00066n-Uy; Wed, 20 Mar 2024 18:40:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rn4br-000605-F2 for guix-patches@gnu.org; Wed, 20 Mar 2024 18:40:36 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rn4br-0007e4-4N for guix-patches@gnu.org; Wed, 20 Mar 2024 18:40:35 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rn4cU-0006FS-LS for guix-patches@gnu.org; Wed, 20 Mar 2024 18:41:14 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#69591] [PATCH v3 25/32] gnu: Add qnnpack-pytorch. Resent-From: David Elsing Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 20 Mar 2024 22:41:14 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69591 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 69591@debbugs.gnu.org Cc: David Elsing Received: via spool by 69591-submit@debbugs.gnu.org id=B69591.171097445823782 (code B ref 69591); Wed, 20 Mar 2024 22:41:14 +0000 Received: (at 69591) by debbugs.gnu.org; 20 Mar 2024 22:40:58 +0000 Received: from localhost ([127.0.0.1]:36840 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rn4cD-0006BP-Nx for submit@debbugs.gnu.org; Wed, 20 Mar 2024 18:40:58 -0400 Received: from mout02.posteo.de ([185.67.36.66]:42103) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rn4bR-00064a-Qa for 69591@debbugs.gnu.org; Wed, 20 Mar 2024 18:40:12 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 99FCF240101 for <69591@debbugs.gnu.org>; Wed, 20 Mar 2024 23:39:24 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1710974364; bh=dWr8XBVvFnqerSAo8OpUP0rE1yqt/L8xDG6HXuH53zk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:From; b=q3U8RjLYa3K60BaTqFpuh7r9xNDy9MKWNFxBdlguhITRGXokm1RycASYRu1KmS3H3 cLZKGPxQjg1h0sf8q4GZZHnqdNhlk2AaHonnKAM66SlYm8u24BiXYT0CvInsu3dx8g LsgMYH8dr7AFfZYnsGlU+2GR3m15lTG3SN/6P8+mkNj59qt2vZ6WczMUa/ANszQYQm L7xDR32kSrBHBQHR+9eVoQ9rQZ0fPWY4HR8CdTgs3fkT1BLnK1J6HPsGs5+XRf+9aK mj7uxyRFh9N6BXxvLHi4KaxSbAXPj+eM/kkBepMn7Cq4oQfZTECIC4lyP/Y7H0whgK XkDfDQnPux66A== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4V0Nn82Bxvz6twQ; Wed, 20 Mar 2024 23:39:24 +0100 (CET) From: David Elsing Date: Wed, 20 Mar 2024 22:38:50 +0000 Message-ID: <20240320223906.13214-25-david.elsing@posteo.net> In-Reply-To: <20240320223737.12883-1-david.elsing@posteo.net> References: <20240320223737.12883-1-david.elsing@posteo.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -3.92 X-Spam-Score: -3.92 X-Migadu-Queue-Id: 411246FBF5 X-Migadu-Scanner: mx11.migadu.com X-TUID: 4Qh2jy/B2aos This is an internal fork of QNNPACK in the PyTorch source tree. * gnu/packages/machine-learning.scm (%python-pytorch-version): New variable. (%python-pytorch-src): New variable. (qnnpack-pytorch): New variable. --- gnu/packages/machine-learning.scm | 127 ++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm index 6c5b723559..c4785ac2f1 100644 --- a/gnu/packages/machine-learning.scm +++ b/gnu/packages/machine-learning.scm @@ -4313,6 +4313,133 @@ (define-public ideep-pytorch PyTorch.") (license license:expat))) +(define %python-pytorch-version "2.2.1") + +(define %python-pytorch-src + (origin + (method git-fetch) + (uri (git-reference + (url "https://github.com/pytorch/pytorch") + (commit (string-append "v" %python-pytorch-version)))) + (file-name (git-file-name "python-pytorch" %python-pytorch-version)) + (sha256 + (base32 + "03mm0pwwb5lxdsmmiw3cch9fijgjw81kmmc4ln9rlyazkm7l1r48")) + (modules '((guix build utils))) + (snippet + '(begin + ;; Bundled or unused code + (for-each + (lambda (dir) + (when (file-exists? dir) + (delete-file-recursively dir))) + '("android" + "aten/src/ATen/native/cuda/cutlass_extensions" + "aten/src/ATen/native/quantized/cpu/qnnpack" + "caffe2/mobile/contrib/libopencl-stub" + "caffe2/mobile/contrib/libvulkan-stub" + "third_party")) + + ;; Autogenerated files + (for-each + delete-file + '("aten/src/ATen/nnapi/nnapi_wrapper.cpp" + "aten/src/ATen/nnapi/nnapi_wrapper.h" + "caffe2/mobile/contrib/ios/mpscnn/mpscnn_kernels.h" + "caffe2/proto/caffe2_legacy_pb2.pyi" + "caffe2/proto/caffe2_pb2.pyi" + "caffe2/proto/hsm_pb2.pyi" + "caffe2/proto/metanet_pb2.pyi" + "caffe2/proto/predictor_consts_pb2.pyi" + "caffe2/proto/prof_dag_pb2.pyi" + "caffe2/proto/torch_pb2.pyi" + ;; These files contain just lists of floating point values and + ;; might be as well hand-written. + ;; "test/cpp/api/init_baseline.h" + ;; "test/cpp/api/optim_baseline.h" + "test/mobile/test_upgrader_bytecode_table_example.cpp" + "torch/csrc/jit/mobile/upgrader_mobile.cpp" + "torch/csrc/jit/runtime/decomposition_registry_util.cpp" + "torch/csrc/jit/runtime/serialized_shape_function_registry.cpp" + "torch/csrc/jit/tensorexpr/external_functions_codegen.cpp" + "torch/csrc/jit/serialization/mobile_bytecode_generated.h")) + (delete-file-recursively ".github") + (for-each + (lambda (dir) + (for-each + delete-file + (find-files dir "\\.cu$"))) + '("aten/src/ATen/native/transformers/cuda/flash_attn/kernels" + "aten/src/ATen/native/transformers/cuda/mem_eff_attention/kernels")))))) + +(define-public qnnpack-pytorch + (package + (inherit qnnpack) + (name "qnnpack-pytorch") + (version (string-append "pytorch-" %python-pytorch-version)) + (source + (origin + (inherit %python-pytorch-src) + (patches '()) + (modules '((guix build utils) + (srfi srfi-26) + (ice-9 ftw))) + (snippet + '(begin + (rename-file "aten/src/ATen/native/quantized/cpu/qnnpack" + "../qnnpack") + (let ((outdir (getcwd))) + (chdir "..") + (rename-file outdir "dummy") + (rename-file "qnnpack" outdir) + (chdir outdir) + (delete-file-recursively "deps")))))) + (arguments + (substitute-keyword-arguments (package-arguments qnnpack) + ((#:phases phases #~%standard-phases) + #~(modify-phases %standard-phases + (add-after 'unpack 'patch-cmake + (lambda _ + (substitute* "CMakeLists.txt" + (("project\\(.*" orig) + (apply + string-append + orig "\n" + (map (lambda (name) + (string-append + "option(" name " \"\" ON)\n")) + '("USE_SYSTEM_CPUINFO" "USE_SYSTEM_FP16" "USE_SYSTEM_FXDIV" + "USE_SYSTEM_PSIMD" "USE_SYSTEM_PTHREADPOOL")))) + (("if.*SOURCE_DIR.*") + "if(FALSE)\n") + (("if\\(NOT TARGET (clog|gtest|benchmark).*") + "if(FALSE)\n") + (("target_link_libraries.*(fxdiv|psimd|fp16)\\).*") + "") + (("(target_link_libraries.*) fp16 (.*)" _ before after) + (string-append before " " after))))) + (add-after 'unpack 'fix-cstring-include + (lambda _ + (substitute* "include/pack_block_sparse.h" + (("#include.*.*" orig) + (string-append orig "\n#include \n"))))) + (add-after 'install 'install-missing-headers + (lambda _ + (for-each + (lambda (name) + (install-file (string-append "../source/include/" name) + (string-append #$output "/include"))) + '("pack_block_sparse.h" + "pytorch_qnnpack.h" + "qnnpack_func.h")) + (copy-recursively + "../source/src/qnnpack" + (string-append #$output "/include/qnnpack")))))) + ;; Some tests occasionally fail on i686 due to floating point rounding. + ((#:tests? _ #t) + (not (string-prefix? "i686" (or (%current-target-system) + (%current-system))))))))) + ;; Please also update python-torchvision when updating this package. (define-public python-pytorch (package -- 2.41.0