0
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
(defun arange-user-shape-int (&key from to step (dtype :int64) shape rank)
(nnl2.ffi:%int-arange from to step t shape rank dtype))
(defun arange-user-shape-float (&key from to step (dtype nnl2.system:*default-tensor-type*) shape rank)
(nnl2.ffi:%float-arange from to step t shape rank dtype))
(defun arange-auto-shape-int (&key from to step (dtype :int64))
(nnl2.ffi:%int-arange from to step nil nnl2.ffi:*null* 1 dtype))
(defun arange-auto-shape-float (&key from to step (dtype nnl2.system:*default-tensor-type*))
(nnl2.ffi:%float-arange from to step nil nnl2.ffi:*null* 1 dtype))
(defun arange-user-shape (from to step dtype indices)
(multiple-value-bind (shape rank) (nnl2.hli:make-shape-pntr indices)
(if (or (floatp from) (floatp to) (floatp step))
(if dtype
(arange-user-shape-float :from from :to to :step step :dtype dtype :shape shape :rank rank)
(arange-user-shape-float :from from :to to :step step :shape shape :rank rank))
(if dtype
(arange-user-shape-int :from from :to to :step step :dtype dtype :shape shape :rank rank)
(arange-user-shape-int :from from :to to :step step :shape shape :rank rank)))))
(defun arange-auto-shape (from to step dtype)
(if (or (floatp from) (floatp to) (floatp step))
(if dtype
(arange-auto-shape-float :from from :to to :step step :dtype dtype)
(arange-auto-shape-float :from from :to to :step step))
(if dtype
(arange-auto-shape-int :from from :to to :step step :dtype dtype)
(arange-auto-shape-int :from from :to to :step step))))
(defun arange (&key from to step dtype shape)
(if shape
(arange-user-shape from to step dtype shape)
(arange-auto-shape from to step dtype)))
реальный код в отличии от моих шуточных
Запостил:
lisp-worst-code ,
24.12.2025 (Updated 24.12.2025 )
Комментарии (0) RSS