fastmachinelearning/hls4ml

AttributeError: module 'tensorflow.keras.layers' has no attribute 'LocallyConnected1D'

Closed this issue · 1 comments

tensorflow/core/util/port.cc:153] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable TF_ENABLE_ONEDNN_OPTS=0.
2024-09-22 15:13:05.487338: E external/local_xla/xla/stream_executor/cuda/cuda_fft.cc:485] Unable to register cuFFT factory: Attempting to register factory for plugin cuFFT when one has already been registered
2024-09-22 15:13:05.504004: E external/local_xla/xla/stream_executor/cuda/cuda_dnn.cc:8454] Unable to register cuDNN factory: Attempting to register factory for plugin cuDNN when one has already been registered
2024-09-22 15:13:05.509065: E external/local_xla/xla/stream_executor/cuda/cuda_blas.cc:1452] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2024-09-22 15:13:05.522025: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-09-22 15:13:06.233888: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
Traceback (most recent call last):
File "/disk/zj/LLM/onnxinfo.py", line 27, in
from hls4ml.converters import convert_from_pytorch_model
File "/disk/zj/.conda/envs/llm/lib/python3.10/site-packages/hls4ml/init.py", line 1, in
from hls4ml import converters, report, utils # noqa: F401
File "/disk/zj/.conda/envs/llm/lib/python3.10/site-packages/hls4ml/converters/init.py", line 7, in
from hls4ml.converters.keras_to_hls import KerasFileReader # noqa: F401
File "/disk/zj/.conda/envs/llm/lib/python3.10/site-packages/hls4ml/converters/keras_to_hls.py", line 5, in
from hls4ml.model import ModelGraph
File "/disk/zj/.conda/envs/llm/lib/python3.10/site-packages/hls4ml/model/init.py", line 1, in
from hls4ml.model.graph import HLSConfig, ModelGraph # noqa: F401
File "/disk/zj/.conda/envs/llm/lib/python3.10/site-packages/hls4ml/model/graph.py", line 9, in
from hls4ml.backends import get_backend
File "/disk/zj/.conda/envs/llm/lib/python3.10/site-packages/hls4ml/backends/init.py", line 1, in
from hls4ml.backends.backend import Backend, get_available_backends, get_backend, register_backend # noqa: F401
File "/disk/zj/.conda/envs/llm/lib/python3.10/site-packages/hls4ml/backends/backend.py", line 5, in
from hls4ml.backends.template import Template
File "/disk/zj/.conda/envs/llm/lib/python3.10/site-packages/hls4ml/backends/template.py", line 1, in
from hls4ml.model.optimizer.optimizer import OptimizerPass
File "/disk/zj/.conda/envs/llm/lib/python3.10/site-packages/hls4ml/model/optimizer/init.py", line 4, in
from hls4ml.model.optimizer.optimizer import ( # noqa: F401
File "/disk/zj/.conda/envs/llm/lib/python3.10/site-packages/hls4ml/model/optimizer/optimizer.py", line 5, in
from hls4ml.utils.string_utils import convert_to_snake_case
File "/disk/zj/.conda/envs/llm/lib/python3.10/site-packages/hls4ml/utils/init.py", line 1, in
from hls4ml.utils.config import config_from_keras_model, config_from_onnx_model, config_from_pytorch_model # noqa: F401
File "/disk/zj/.conda/envs/llm/lib/python3.10/site-packages/hls4ml/utils/config.py", line 3, in
import qkeras
File "/disk/zj/.conda/envs/llm/lib/python3.10/site-packages/qkeras/init.py", line 23, in
from .estimate import * # pylint: disable=wildcard-import
File "/disk/zj/.conda/envs/llm/lib/python3.10/site-packages/qkeras/estimate.py", line 41, in
from .qlayers import QActivation
File "/disk/zj/.conda/envs/llm/lib/python3.10/site-packages/qkeras/qlayers.py", line 58, in
from tensorflow_model_optimization.python.core.sparsity.keras.prunable_layer import PrunableLayer
File "/disk/zj/.conda/envs/llm/lib/python3.10/site-packages/tensorflow_model_optimization/init.py", line 86, in
from tensorflow_model_optimization.python.core.api import clustering
File "/disk/zj/.conda/envs/llm/lib/python3.10/site-packages/tensorflow_model_optimization/python/core/api/init.py", line 16, in
from tensorflow_model_optimization.python.core.api import clustering
File "/disk/zj/.conda/envs/llm/lib/python3.10/site-packages/tensorflow_model_optimization/python/core/api/clustering/init.py", line 16, in
from tensorflow_model_optimization.python.core.api.clustering import keras
File "/disk/zj/.conda/envs/llm/lib/python3.10/site-packages/tensorflow_model_optimization/python/core/api/clustering/keras/init.py", line 19, in
from tensorflow_model_optimization.python.core.clustering.keras.cluster import cluster_scope
File "/disk/zj/.conda/envs/llm/lib/python3.10/site-packages/tensorflow_model_optimization/python/core/clustering/keras/cluster.py", line 22, in
from tensorflow_model_optimization.python.core.clustering.keras import cluster_wrapper
File "/disk/zj/.conda/envs/llm/lib/python3.10/site-packages/tensorflow_model_optimization/python/core/clustering/keras/cluster_wrapper.py", line 24, in
from tensorflow_model_optimization.python.core.clustering.keras import clustering_registry
File "/disk/zj/.conda/envs/llm/lib/python3.10/site-packages/tensorflow_model_optimization/python/core/clustering/keras/clustering_registry.py", line 57, in
class ClusteringRegistry(object):
File "/disk/zj/.conda/envs/llm/lib/python3.10/site-packages/tensorflow_model_optimization/python/core/clustering/keras/clustering_registry.py", line 76, in ClusteringRegistry
layers.LocallyConnected1D: ['kernel'],
AttributeError: module 'tensorflow.keras.layers' has no attribute 'LocallyConnected1D'

Hi, I met the same issue when I installed the lastest hls4ml from source code.(commit 1654c1c)

Strangely, I found that tensorflow-model-optimization package was downgraded while updating to the latest hls4ml.

before after
hls4ml 0.8.1 hls4ml 0.1.0.dev2159+g3c08fea.d20241002
tensorflow-model-optimization 0.8.0 tensorflow-model-optimization 0.7.5

So I upgraded the package. In my case, the problem was solved.

pip install tensorflow-model-optimization==0.8.0