From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <guix-patches-bounces+larch=yhetil.org@gnu.org>
Received: from mp1.migadu.com ([2001:41d0:303:e224::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by ms8.migadu.com with LMTPS
	id SNkYB51S/2WPTgAA62LTzQ:P1
	(envelope-from <guix-patches-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Sat, 23 Mar 2024 23:07:25 +0100
Received: from aspmx1.migadu.com ([2001:41d0:303:e224::])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	by mp1.migadu.com with LMTPS
	id SNkYB51S/2WPTgAA62LTzQ
	(envelope-from <guix-patches-bounces+larch=yhetil.org@gnu.org>)
	for <larch@yhetil.org>; Sat, 23 Mar 2024 23:07:25 +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="CXz/VL38";
	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=1711231645; a=rsa-sha256; cv=none;
	b=YdyU11NSf/d52su1bFcdsV83eM1P88F981uDygwBVgVBo1FZVPZEObuVID+45uALRL6ryC
	/t8ZAahMI2tZQX7KJM/ddIjkaToyCWYDqK8MEW9pxlXcGc5GEMYA0w8fR046HfXTs2WqDM
	BRkCxIxo8uL3GFPSsi+E08dHjXXMQsXounTZXbWHpvoxjt35dyHtE26TIKm/wYWHpvjo/j
	d65QieVNICCarYGXZ7gm6JdsdH86WSeclIdsrX153FiEAmcU/GPlLMkNtE4Oxb9C7ZgNJZ
	o+CkdSji7MCFmK6sKBVHzerEl1gmXvug0AJ2nXpW6lw2qSd0Kg4dxDra+ZjKtQ==
ARC-Authentication-Results: i=1;
	aspmx1.migadu.com;
	dkim=fail ("headers rsa verify failed") header.d=posteo.net header.s=2017 header.b="CXz/VL38";
	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=1711231645;
	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=rCpvbeRHqFeG6VciuZryrfnoHvr0Yf9P3UOqljKAGSg=;
	b=Eqr2sEtoD08yPKuhbGcCWaTZC3UUXu0u9f8caqvs4zmn6odTLpK63M5/+PO5yClggaASvf
	/OvtJXRq75wdKmWUQafnjHnN4odLB1Of5RuvzCWKV/XPm2+S/rotfXAh/hxdqOl347Vbgm
	1cpl0sElpP8GSjkmhH7FXRnbFn/fGjKza2i+hq4TatcnpkLm0XhsDHUHrgYcnkzc5YOO65
	53KBr8yHpaN3E89QbyEktlZWedC8TBOsETDt7oq6yKCT//SmyW7LGdTTlq8xbIo0bQyq9U
	Fp0kR7YpDTsQKVPa4S9sAaG7DCHPgOKd+oraT6unvqhPVBcEzncEMQD7ulM2Tg==
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 D532E35461
	for <larch@yhetil.org>; Sat, 23 Mar 2024 23:07:24 +0100 (CET)
Received: from localhost ([::1] helo=lists1p.gnu.org)
	by lists.gnu.org with esmtp (Exim 4.90_1)
	(envelope-from <guix-patches-bounces@gnu.org>)
	id 1ro9VQ-00050N-1m; 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 <Debian-debbugs@debbugs.gnu.org>)
 id 1ro9VO-0004zV-6O
 for guix-patches@gnu.org; Sat, 23 Mar 2024 18:06:22 -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 <Debian-debbugs@debbugs.gnu.org>)
 id 1ro9VN-00080V-UJ
 for guix-patches@gnu.org; Sat, 23 Mar 2024 18:06:21 -0400
Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2)
 (envelope-from <Debian-debbugs@debbugs.gnu.org>) id 1ro9W3-0006Si-0A
 for guix-patches@gnu.org; Sat, 23 Mar 2024 18:07:03 -0400
X-Loop: help-debbugs@gnu.org
Subject: [bug#69591] [PATCH v4 21/32] gnu: Add foxi.
Resent-From: David Elsing <david.elsing@posteo.net>
Original-Sender: "Debbugs-submit" <debbugs-submit-bounces@debbugs.gnu.org>
Resent-CC: guix-patches@gnu.org
Resent-Date: Sat, 23 Mar 2024 22:07:02 +0000
Resent-Message-ID: <handler.69591.B69591.171123160924726@debbugs.gnu.org>
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 <david.elsing@posteo.net>
Received: via spool by 69591-submit@debbugs.gnu.org id=B69591.171123160924726
 (code B ref 69591); Sat, 23 Mar 2024 22:07:02 +0000
Received: (at 69591) by debbugs.gnu.org; 23 Mar 2024 22:06:49 +0000
Received: from localhost ([127.0.0.1]:56601 helo=debbugs.gnu.org)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <debbugs-submit-bounces@debbugs.gnu.org>)
 id 1ro9Vo-0006Qd-CZ
 for submit@debbugs.gnu.org; Sat, 23 Mar 2024 18:06:48 -0400
Received: from mout01.posteo.de ([185.67.36.65]:56923)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <david.elsing@posteo.net>) id 1ro9VK-0006OH-JV
 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 A5A26240027
 for <69591@debbugs.gnu.org>; Sat, 23 Mar 2024 23:05:31 +0100 (CET)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017;
 t=1711231531; bh=vufDdfGXcfVcnvGMrX95eFPGzFrg67nXJSA+L63r0So=;
 h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:
 Content-Transfer-Encoding:From;
 b=CXz/VL38eXtOmbjFyb9pNJP4siPlbPWNgy2OhkYgwXoWjfjZSC8yNv0kTqiJJ8JJo
 xsK+w3+ICphFPOJEgEDZP4iUPdBMd9bQtUKyNdAlaZRRHWnDoUkTUaxkDW1LFGlSz9
 nSr4e/fCxM6l1giTUHJl9LvGBFWIWO/GlDJNn4EVO2WyCKsvw+bOT6mn8l8vxXQwV2
 lkZJvKjhxiQsZqqkez9KjATN4RV4Il4qdDRBA37ur7Ztv1kUbNtTTBjjjKfoDnpsGA
 6m1ky2jl+nzU3U2XoHXvpiHXNtDPwVtUrpSzH9V2pX86jTFAffFWmv04iYqqbFv/5a
 /Gv0VpS+S0KaA==
Received: from customer (localhost [127.0.0.1])
 by submission (posteo.de) with ESMTPSA id 4V2Ctg2W1hz6tm4;
 Sat, 23 Mar 2024 23:05:31 +0100 (CET)
From: David Elsing <david.elsing@posteo.net>
Date: Sat, 23 Mar 2024 22:05:00 +0000
Message-ID: <20240323220518.25063-21-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: <guix-patches.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/guix-patches>,
 <mailto:guix-patches-request@gnu.org?subject=unsubscribe>
List-Archive: <https://lists.gnu.org/archive/html/guix-patches>
List-Post: <mailto:guix-patches@gnu.org>
List-Help: <mailto:guix-patches-request@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/guix-patches>,
 <mailto:guix-patches-request@gnu.org?subject=subscribe>
Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org
Sender: guix-patches-bounces+larch=yhetil.org@gnu.org
X-Migadu-Flow: FLOW_IN
X-Migadu-Country: US
X-Spam-Score: 3.97
X-Migadu-Queue-Id: D532E35461
X-Migadu-Scanner: mx12.migadu.com
X-Migadu-Spam-Score: 3.97
X-TUID: N/K6QbOZdvYO

* gnu/packages/machine-learning.scm (foxi): New variable.
* gnu/packages/patches/foxi-fix-build.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.
---
 gnu/local.mk                              |  1 +
 gnu/packages/machine-learning.scm         | 29 ++++++++++++
 gnu/packages/patches/foxi-fix-build.patch | 55 +++++++++++++++++++++++
 3 files changed, 85 insertions(+)
 create mode 100644 gnu/packages/patches/foxi-fix-build.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index e0fa9e1f78..15d9d50de7 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1207,6 +1207,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/foobillard++-pkg-config.patch		\
   %D%/packages/patches/foomatic-filters-CVE-2015-8327.patch	\
   %D%/packages/patches/foomatic-filters-CVE-2015-8560.patch	\
+  %D%/packages/patches/foxi-fix-build.patch			\
   %D%/packages/patches/fp16-implicit-double.patch		\
   %D%/packages/patches/fp16-system-libraries.patch		\
   %D%/packages/patches/fpc-reproducibility.patch		\
diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index 1872ca9d30..5dc0a48b12 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -4214,6 +4214,35 @@ (define-public tensorpipe
 the tensors contained therein.")
       (license license:bsd-3))))
 
+(define-public foxi
+  (let
+      ((commit "c278588e34e535f0bb8f00df3880d26928038cad")
+       (revision "0"))
+    (package
+      (name "foxi")
+      (version (git-version "1.4.1" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/houseroad/foxi")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "0q3ssm5hmmvwfwx87mnnajbavzgpahybw6rpn8ysr9r095dwgq5a"))
+                (patches (search-patches "foxi-fix-build.patch"))))
+      (build-system cmake-build-system)
+      (arguments
+       (list
+        ;; No tests
+        #:tests? #f))
+      (home-page "https://github.com/houseroad/foxi")
+      (synopsis "ONNXIFI with Facebook Extension")
+      (description "ONNX Interface for Framework Integration is a cross-platform
+API for loading and executing ONNX graphs on optimized backends.  This package
+contains facebook extensions and is used by PyTorch.")
+      (license license:expat))))
+
 ;; Please also update python-torchvision when updating this package.
 (define-public python-pytorch
   (package
diff --git a/gnu/packages/patches/foxi-fix-build.patch b/gnu/packages/patches/foxi-fix-build.patch
new file mode 100644
index 0000000000..d82090ad38
--- /dev/null
+++ b/gnu/packages/patches/foxi-fix-build.patch
@@ -0,0 +1,55 @@
+Taken from https://github.com/houseroad/foxi/pull/25.
+
+diff --git a/foxi/onnxifi_dummy.c b/foxi/onnxifi_dummy.c
+index 2115af9..73e25fc 100644
+--- a/foxi/onnxifi_dummy.c
++++ b/foxi/onnxifi_dummy.c
+@@ -103,7 +103,10 @@ ONNXIFI_PUBLIC ONNXIFI_CHECK_RESULT onnxStatus ONNXIFI_ABI onnxInitGraph(
+     const void* onnxModel,
+     uint32_t weightCount,
+     const onnxTensorDescriptorV1* weightDescriptors,
+-    onnxGraph* graph) {
++    onnxGraph* graph,
++    uint32_t maxSeqLength,
++    void* deferredWeightReader) {
++
+   if (graph == NULL) {
+     return ONNXIFI_STATUS_INVALID_POINTER;
+   }
+@@ -215,6 +218,8 @@ ONNXIFI_PUBLIC ONNXIFI_CHECK_RESULT onnxStatus ONNXIFI_ABI
+ onnxWaitEventFor(onnxEvent event,
+                  uint32_t timeoutMs,
+                  onnxEventState* eventState,
+-                 onnxStatus* eventStatus) {
++		  onnxStatus* eventStatus,
++		  char* message,
++		  size_t* messageLength) {
+   return ONNXIFI_STATUS_SUCCESS;
+ }
+\ No newline at end of file
+diff --git a/foxi/onnxifi_wrapper.c b/foxi/onnxifi_wrapper.c
+index 98a9325..abe1440 100644
+--- a/foxi/onnxifi_wrapper.c
++++ b/foxi/onnxifi_wrapper.c
+@@ -761,7 +761,9 @@ ONNXIFI_PUBLIC onnxStatus ONNXIFI_ABI onnxInitGraph(
+     const void* onnxModel,
+     uint32_t weightsCount,
+     const onnxTensorDescriptorV1* weightDescriptors,
+-    onnxGraph* graph)
++    onnxGraph* graph,
++    uint32_t maxSeqLength,
++    void* deferredWeightReader)
+ {
+   if (graph == NULL) {
+     return ONNXIFI_STATUS_INVALID_POINTER;
+@@ -797,7 +799,9 @@ ONNXIFI_PUBLIC onnxStatus ONNXIFI_ABI onnxInitGraph(
+     onnxModel,
+     weightsCount,
+     weightDescriptors,
+-    &graph_wrapper->graph);
++    &graph_wrapper->graph,
++    maxSeqLength,
++    deferredWeightReader);
+   switch (status) {
+     case ONNXIFI_STATUS_SUCCESS:
+     case ONNXIFI_STATUS_FALLBACK:
-- 
2.41.0