Content-Length: 312574 | pFad | http://github.com/tensorly/torch/commit/8b1022e944ef6268ebfa788aad6ca84971daa673

26 Adds docstrings for utils · tensorly/torch@8b1022e · GitHub
Skip to content

Commit 8b1022e

Browse files
committed
Adds docstrings for utils
1 parent 8a35905 commit 8b1022e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tltorch/utils/tensorize_shape.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,22 @@
55
# Author : Jean Kossaifi
66

77
def factorize(value, min_value=2, remaining=-1):
8+
"""Factorize an integer input value into it's smallest divisors
9+
10+
Parameters
11+
----------
12+
value : int
13+
integer to factorize
14+
min_value : int, default is 2
15+
smallest divisors to use
16+
remaining : int, default is -1
17+
DO NOT SPECIFY THIS VALUE, IT IS USED FOR TAIL RECURSION
18+
19+
Returns
20+
-------
21+
factorization : int tuple
22+
ints such that prod(factorization) == value
23+
"""
824
if value <= min_value or remaining == 0:
925
return (value, )
1026
lim = math.isqrt(value)
@@ -16,6 +32,20 @@ def factorize(value, min_value=2, remaining=-1):
1632
return (value, )
1733

1834
def merge_ints(values, size):
35+
"""Utility function to merge the smallest values in a given tuple until it's length is the given size
36+
37+
Parameters
38+
----------
39+
values : int list
40+
list of values to merge
41+
size : int
42+
target len of the list
43+
stop merging when len(values) <= size
44+
45+
Returns
46+
-------
47+
merge_values : list of size ``size``
48+
"""
1949
if len(values) <= 1:
2050
return values
2151

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/tensorly/torch/commit/8b1022e944ef6268ebfa788aad6ca84971daa673

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy