From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id QA8YNHpS/2V/aAEAqHPOHw:P1 (envelope-from ) for ; Sat, 23 Mar 2024 23:06:51 +0100 Received: from aspmx1.migadu.com ([2001:41d0:303:e16b::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0.migadu.com with LMTPS id QA8YNHpS/2V/aAEAqHPOHw (envelope-from ) for ; Sat, 23 Mar 2024 23:06:51 +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=NORvJSUk; 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"; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1711231610; 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=iZkCN0vV8tmVI7qzc36Hq+ooHyoUZ8qOGw89SesfUEk=; b=GB9ajgobv98p5u1ypQaoCqAh31F6U/YejZkzE0+WsiEy38ZSnl23Nu30IE7jjvoXJk1+BT pTO5fb0JLjOjLd2Y5HV45rGwS195EW9xWLuYcCm8wHMl/XLg5ioS1sG7UL0RGpNjCZyAwB c/Qv2KicxVV6tkejNidCjaGQx7MqWhiEAXH8VkE9aGJCsFwYQ5j+2as6F64QZmiYigWTDw oaxF2XTXZa5jPxzA+ASbsH8rPYyM0YepMo1qwf11zRLSZz6NH/9cUbWV0duEv2HXLR3dsi ppdCj8UAyj3GH07fbEXKgJt46irjgOj62O/gCOAzQdAHVoT9lXv0ZjZzeZosuw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b=NORvJSUk; 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"; dmarc=fail reason="SPF not aligned (strict)" header.from=posteo.net (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1711231610; a=rsa-sha256; cv=none; b=S9mo7SV3Brk4MfQ0VVRjLwKB8mgZ3rWGkgr47iaqaA0pLsNomSIToHWB2CbTm+4HGtPYeO E7+40u3oYdkoClclrZxytSimXIVafoILtP83Xr5qyPWAL1OZX/Gckzof5wjcdbl0V9LwyX n2JER0v57rx0hI/YNXc8MeDfoF63rrOV3niI1vLK0rh7tFxIuZw2Czd4XNysh43NoOAx+i OAbFNGoPRkBEYDVsGVBMRDEAfN/jXzDnq3fsI1nbjLEUDBA7IDqeIMo9seYfQa7wuMku2/ 2n5jQ0J6PmitGKDLnQkO5WnpU/teBZ05uWdh12ihnDyjuCozsrh2XxBiCMmNgQ== 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 97534645A4 for ; Sat, 23 Mar 2024 23:06:50 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ro9VQ-00050y-Mq; Sat, 23 Mar 2024 18:06:24 -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 1ro9VO-0004zy-VL for guix-patches@gnu.org; Sat, 23 Mar 2024 18:06:23 -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 1ro9VO-00080f-NW for guix-patches@gnu.org; Sat, 23 Mar 2024 18:06:22 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ro9W4-0006Sw-01 for guix-patches@gnu.org; Sat, 23 Mar 2024 18:07:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#69591] [PATCH v4 25/32] gnu: Add qnnpack-pytorch. Resent-From: David Elsing Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 23 Mar 2024 22:07:03 +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.171123161024746 (code B ref 69591); Sat, 23 Mar 2024 22:07:03 +0000 Received: (at 69591) by debbugs.gnu.org; 23 Mar 2024 22:06:50 +0000 Received: from localhost ([127.0.0.1]:56607 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ro9Vp-0006Qw-Or for submit@debbugs.gnu.org; Sat, 23 Mar 2024 18:06:50 -0400 Received: from mout01.posteo.de ([185.67.36.65]:59383) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ro9VL-0006OG-Du for 69591@debbugs.gnu.org; Sat, 23 Mar 2024 18:06:20 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 25A8D240028 for <69591@debbugs.gnu.org>; Sat, 23 Mar 2024 23:05:34 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1711231534; bh=z6on9LZqeuui0vPouHqG6FnU+0rMjhSO8ois/NJsy+M=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:From; b=NORvJSUkpB6dERK0ViyykW68p5DEiE7wo6UTFK8yOWll04rcZt1Mz8eHi5zpA4CXr 4ODEWRPCe/R2Xv6/VBo2NiIRmEBhrN3WgVc6mBZqc21Qz9MrY1dZpC0uzmMpPVr3Ai /GEWCp21oWY34BdTKvn+a/Id7phYT1jg79BmQTkF/PwJjt1C81evvn3L8kzvNnP5q2 hyAhm07SBLZdWHZ4QkpUL4hfKmlYpaxyy3dP6HWNGjWlQxs7FotLY8xRYb5Wd+xXpI xBAKe8XUP/IVENnea9KAcmPFp1h0SKNHM9L+BNsxAm7k6CKHu5VzyhdIgjthQw5D0P IrrainZ2WcMHg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4V2Ctj5m9pz6tm4; Sat, 23 Mar 2024 23:05:33 +0100 (CET) From: David Elsing Date: Sat, 23 Mar 2024 22:05:04 +0000 Message-ID: <20240323220518.25063-25-david.elsing@posteo.net> In-Reply-To: <20240323214040.20221-1-david.elsing@posteo.net> References: <20240323214040.20221-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-Spam-Score: 3.97 X-Migadu-Queue-Id: 97534645A4 X-Migadu-Scanner: mx13.migadu.com X-Migadu-Spam-Score: 3.97 X-TUID: yTztVxoN7st9 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 375fd77a28..1be598e1e7 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