diff --git a/README.md b/README.md index 18fa42c85..9959803e0 100755 --- a/README.md +++ b/README.md @@ -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 ). @@ -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 @@ -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! diff --git a/cm/CHANGES.md b/cm/CHANGES.md index e526859e5..492d9a92f 100644 --- a/cm/CHANGES.md +++ b/cm/CHANGES.md @@ -1,5 +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 diff --git a/cm/cmind/__init__.py b/cm/cmind/__init__.py index 6fa7e4068..d63eb4ef4 100644 --- a/cm/cmind/__init__.py +++ b/cm/cmind/__init__.py @@ -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 diff --git a/cm/cmind/utils.py b/cm/cmind/utils.py index e352fbc90..23296c6e4 100644 --- a/cm/cmind/utils.py +++ b/cm/cmind/utils.py @@ -2047,3 +2047,108 @@ def flatten_dict(d, fd = {}, prefix = ''): fd[prefix + k] = str(v) return + +############################################################################## +def safe_int(i, d): + """ + Get safe int (useful for sorting function) + + Args: + i (any): variable with any type + d (int): default value + + Returns: + (int): returns i if it can be converted to int, or d otherwise + """ + + r = d + try: + r = int(i) + except Exception as e: + pass + + return r + +############################################################################## +def safe_float(i, d): + """ + Get safe float (useful for sorting function) + + Args: + i (any): variable with any type + d (float): default value + + Returns: + (float): returns i if it can be converted to float or d otherwise + + """ + + r = d + try: + r = float(i) + except Exception as e: + pass + + return r + +############################################################################## +def get_set(meta, key, state, keys): + """ + Get value from dict and update in another dict + + Args: + meta (dict): original dict + key (str): key to get value from original dict + state (dict): target dict + keys (list): list of keys to set value in target dict + + Returns: + (Python object): value from original dict or None + + """ + + v = meta.get(key, None) + if v != None: + cur = state + vv = None + for k in keys: + if k == keys[-1]: + vv = cur.get(k, None) + if vv == None: + cur[k] = v + else: + if k not in cur: + cur[k] = {} + 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