Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
bitsandbytes
Commits
f9cbe2fe
"examples/git@developer.sourcefind.cn:OpenDAS/fairseq.git" did not exist on "b870468689a6d903fb6c2464ca18e07ce73444fb"
Commit
f9cbe2fe
authored
Aug 08, 2022
by
Tim Dettmers
Browse files
Fixed prod Python < 3.7 compatibility in function.py.
parent
62441815
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
4 deletions
+11
-4
bitsandbytes/autograd/_functions.py
bitsandbytes/autograd/_functions.py
+1
-0
bitsandbytes/functional.py
bitsandbytes/functional.py
+9
-3
setup.py
setup.py
+1
-1
No files found.
bitsandbytes/autograd/_functions.py
View file @
f9cbe2fe
...
@@ -6,6 +6,7 @@ import bitsandbytes.functional as F
...
@@ -6,6 +6,7 @@ import bitsandbytes.functional as F
from
dataclasses
import
dataclass
from
dataclasses
import
dataclass
from
functools
import
reduce
# Required in Python 3
from
functools
import
reduce
# Required in Python 3
# math.prod not compatible with python < 3.8
def
prod
(
iterable
):
def
prod
(
iterable
):
return
reduce
(
operator
.
mul
,
iterable
,
1
)
return
reduce
(
operator
.
mul
,
iterable
,
1
)
...
...
bitsandbytes/functional.py
View file @
f9cbe2fe
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
# This source code is licensed under the MIT license found in the
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
# LICENSE file in the root directory of this source tree.
import
ctypes
as
ct
import
ctypes
as
ct
import
operator
import
random
import
random
import
math
import
math
import
torch
import
torch
...
@@ -11,6 +12,11 @@ from typing import Tuple
...
@@ -11,6 +12,11 @@ from typing import Tuple
from
torch
import
Tensor
from
torch
import
Tensor
from
.cextension
import
COMPILED_WITH_CUDA
,
lib
from
.cextension
import
COMPILED_WITH_CUDA
,
lib
from
functools
import
reduce
# Required in Python 3
# math.prod not compatible with python < 3.8
def
prod
(
iterable
):
return
reduce
(
operator
.
mul
,
iterable
,
1
)
name2qmap
=
{}
name2qmap
=
{}
...
@@ -326,8 +332,8 @@ def nvidia_transform(
...
@@ -326,8 +332,8 @@ def nvidia_transform(
dim1
=
ct
.
c_int32
(
shape
[
0
])
dim1
=
ct
.
c_int32
(
shape
[
0
])
dim2
=
ct
.
c_int32
(
shape
[
1
])
dim2
=
ct
.
c_int32
(
shape
[
1
])
elif
ld
is
not
None
:
elif
ld
is
not
None
:
n
=
math
.
prod
(
shape
)
n
=
prod
(
shape
)
dim1
=
math
.
prod
([
shape
[
i
]
for
i
in
ld
])
dim1
=
prod
([
shape
[
i
]
for
i
in
ld
])
dim2
=
ct
.
c_int32
(
n
//
dim1
)
dim2
=
ct
.
c_int32
(
n
//
dim1
)
dim1
=
ct
.
c_int32
(
dim1
)
dim1
=
ct
.
c_int32
(
dim1
)
else
:
else
:
...
@@ -1314,7 +1320,7 @@ def igemmlt(A, B, SA, SB, out=None, Sout=None, dtype=torch.int32):
...
@@ -1314,7 +1320,7 @@ def igemmlt(A, B, SA, SB, out=None, Sout=None, dtype=torch.int32):
m
=
shapeA
[
0
]
*
shapeA
[
1
]
m
=
shapeA
[
0
]
*
shapeA
[
1
]
rows
=
n
=
shapeB
[
0
]
rows
=
n
=
shapeB
[
0
]
assert
math
.
prod
(
list
(
shapeA
))
>
0
,
f
'Input tensor dimensions need to be > 0:
{
shapeA
}
'
assert
prod
(
list
(
shapeA
))
>
0
,
f
'Input tensor dimensions need to be > 0:
{
shapeA
}
'
# if the tensor is empty, return a transformed empty tensor with the right dimensions
# if the tensor is empty, return a transformed empty tensor with the right dimensions
if
shapeA
[
0
]
==
0
and
dimsA
==
2
:
if
shapeA
[
0
]
==
0
and
dimsA
==
2
:
...
...
setup.py
View file @
f9cbe2fe
...
@@ -18,7 +18,7 @@ def read(fname):
...
@@ -18,7 +18,7 @@ def read(fname):
setup
(
setup
(
name
=
f
"bitsandbytes"
,
name
=
f
"bitsandbytes"
,
version
=
f
"0.31.
5
"
,
version
=
f
"0.31.
7
"
,
author
=
"Tim Dettmers"
,
author
=
"Tim Dettmers"
,
author_email
=
"dettmers@cs.washington.edu"
,
author_email
=
"dettmers@cs.washington.edu"
,
description
=
"8-bit optimizers and matrix multiplication routines."
,
description
=
"8-bit optimizers and matrix multiplication routines."
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment