keras/keras_core/api_export.py
Chen Qian eabdb87f9f Add some numpy ops (#1)
* Add numpy ops (initial batch) and some config

* Add unit test

* fix call

* Revert "fix call"

This reverts commit 6748ad183029ff4b97317b77ceed8661916bb9a0.

* full unit test coverage

* fix setup.py
2023-04-12 11:31:58 -07:00

35 lines
789 B
Python

import types
from keras_core.saving import register_keras_core_serializable
try:
import namex
except ImportError:
namex = None
def maybe_register_serializable(symbol):
if isinstance(symbol, types.FunctionType) or hasattr(symbol, "get_config"):
register_keras_core_serializable(symbol)
if namex:
class keras_core_export(namex.export):
def __init__(self, path):
super().__init__(package="keras_core", path=path)
def __call__(self, symbol):
maybe_register_serializable(symbol)
return super().__call__(symbol)
else:
class keras_core_export:
def __init__(self, path):
pass
def __call__(self, symbol):
maybe_register_serializable(symbol)
return symbol