Skip to content

Commit 85ba044

Browse files
committed
New logging system
1 parent 84a8789 commit 85ba044

21 files changed

Lines changed: 348 additions & 133 deletions

File tree

Deeploy/AbstractDataTypes.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
_DeeployType = TypeVar("_DeeployType", _PointerType, _ImmediateType, _StructType)
4343
_PythonType = TypeVar("_PythonType", str, int, float, Dict[str, "_PythonType"], Iterable["_PythonType"])
4444

45+
from Deeploy.Logging import DEFAULT_LOGGER as log
46+
4547

4648
class _ClassPropertyDescriptor(object):
4749

@@ -275,8 +277,8 @@ def partialOrderUpcast(cls, otherCls: Type[Immediate]) -> bool:
275277
@classmethod
276278
def checkValue(cls, value: Union[float, Iterable[float], np.ndarray], ctxt: Optional[_NetworkContext] = None):
277279
"""
278-
This method tries to manually cast standard python's standard immediate float precision values
279-
(64 bits) to an arbitrary FP representation and check if the new representation is close enough
280+
This method tries to manually cast standard python's standard immediate float precision values
281+
(64 bits) to an arbitrary FP representation and check if the new representation is close enough
280282
to the original value.
281283
"""
282284
_val_list = []
@@ -337,7 +339,7 @@ def checkValue(cls, value: Optional[str], ctxt: Optional[_NetworkContext] = None
337339
return False
338340

339341
if value is None or value == "NULL":
340-
print("WARNING: Setting pointer value to NULL - Referenced data is invalid!")
342+
log.warning("Setting pointer value to NULL - Referenced data is invalid!")
341343
return True
342344

343345
reference = ctxt.lookup(value)

Deeploy/CommonExtensions/OptimizationPasses/PassClasses.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import onnx_graphsurgeon as gs
3131

3232
from Deeploy.DeeployTypes import NetworkContext
33+
from Deeploy.Logging import DEFAULT_LOGGER as log
3334

3435
from .Matchers import Match, NonBranchingMatcher, SubgraphMatcher
3536

@@ -152,7 +153,7 @@ def remove_subpass(self, name):
152153
try:
153154
del self._subpasses[name]
154155
except KeyError:
155-
print(f"No subpass with name {name}, cannot remove!")
156+
log.error(f"No subpass with name {name}, cannot remove!")
156157
except AttributeError:
157158
raise AttributeError("Cannot remove sub-pass before calling Pass.__init__!")
158159

Deeploy/CommonExtensions/TypeCheckers/SignPropTypeChecker.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
from Deeploy.AbstractDataTypes import IntegerImmediate
3131
from Deeploy.DeeployTypes import ConstantBuffer, NetworkContext, NodeTypeChecker, OperatorRepresentation, VariableBuffer
32+
from Deeploy.Logging import DEFAULT_LOGGER as log
3233

3334

3435
class SignPropTypeChecker(NodeTypeChecker):
@@ -73,8 +74,8 @@ def typeInferOutput(self, ctxt: NetworkContext, node: gs.Node,
7374

7475
if issubclass(obj._type.referencedType,
7576
IntegerImmediate) and not obj._type.checkNumLevels(nLevel, sign):
76-
print(
77-
f"[WARNING] {obj.name} has {nLevel} levels, but {obj._type.referencedType.typeName} only supports {obj._type.referencedType.nLevels} levels."
77+
log.warning(
78+
f"{obj.name} has {nLevel} levels, but {obj._type.referencedType.typeName} only supports {obj._type.referencedType.nLevels} levels."
7879
)
7980

8081
return ctxt

0 commit comments

Comments
 (0)