Skip to content

Commit

Permalink
added utils.digits
Browse files Browse the repository at this point in the history
  • Loading branch information
gfursin committed Nov 22, 2024
1 parent 1021edd commit b2cc8da
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 12 deletions.
21 changes: 11 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ CK consists of several sub-projects:
* [CM4ABTF](https://github.com/mlcommons/cm4abtf) - a unified CM interface and automation recipes
to run automotive benchmark across different models, data sets, software and hardware from different vendors.

* [CMX (the next generation of CM)](cm/docs/cmx) - we are developing the next generation of CM
* [CMX (the next generation of CM and CM4MLOps)](cm/docs/cmx) - we are developing the next generation of CM
to make it simpler and more flexible based on user feedback. Please follow
this project [here]( https://github.com/orgs/mlcommons/projects/46 ).

Expand All @@ -59,8 +59,9 @@ CK consists of several sub-projects:

### Maintainers

* CM/CMX/CM4Research: [Grigori Fursin](https://cKnowledge.org/gfursin)
* CM/CM4Research: [Grigori Fursin](https://cKnowledge.org/gfursin)
* CM4MLOps: [Arjun Suresh](https://github.com/arjunsuresh) and [Anandhu Sooraj](https://github.com/anandhu-eng)
* CMX (the next generation of CM) [Grigori Fursin](https://cKnowledge.org/gfursin)

### Citing our project

Expand Down Expand Up @@ -89,11 +90,11 @@ To learn more about the motivation behind CK and CM technology, please explore t

### Acknowledgments

The open-source Collective Knowledge project (CK)
was founded by [Grigori Fursin](https://cKnowledge.org/gfursin),
sponsored by cTuning.org, HiPEAC and OctoML, and donated to MLCommons
to serve the wider community. This open-source initiative includes
CM, CM4MLOps/CM4MLPerf, CM4ABTF, and CMX automation technologies.
Its development is a collaborative community effort,
made possible by our dedicated [volunteers, collaborators,
and contributors](https://github.com/mlcommons/ck/blob/master/CONTRIBUTING.md)!
The open-source Collective Knowledge project (CK, CM, CM4MLOps/CM4MLPerf,
CM4Research and CMX) was created by [Grigori Fursin](https://cKnowledge.org/gfursin)
and sponsored by cTuning.org, OctoAI and HiPEAC.
Grigori donated CK to MLCommons to benefit the community
and to advance its development as a collaborative, community-driven effort.
We thank MLCommons and FlexAI for supporting this project,
as well as our dedicated [volunteers and collaborators](https://github.com/mlcommons/ck/blob/master/CONTRIBUTING.md)
for their feedback and contributions!
3 changes: 2 additions & 1 deletion cm/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
## V3.4.1.1
## V3.4.2
- added utils.flatten_dict
- added utils.safe_int
- added utils.safe_float
- added utils.get_set
- added utils.digits

## V3.4.1
- reduced Python min version in pyproject.toml to 3.7 for backwards compatibility
Expand Down
2 changes: 1 addition & 1 deletion cm/cmind/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Written by Grigori Fursin

__version__ = "3.4.1.1"
__version__ = "3.4.2"

from cmind.core import access
from cmind.core import x
Expand Down
30 changes: 30 additions & 0 deletions cm/cmind/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2122,3 +2122,33 @@ def get_set(meta, key, state, keys):
cur = cur[k]

return v

##############################################################################
def digits(s, first = True):
"""
Get first digits and convert to int
Args:
s (str): string ("1.3+xyz")
first (bool): if True, choose only first digits, otherwise all
Returns:
(int): returns int from first digits or 0
"""

v = 0

digits = ''
for char in s:
if char.isdigit():
digits+=char
elif first:
break

try:
v = int(digits)
except Exception as e:
pass

return v

0 comments on commit b2cc8da

Please sign in to comment.