Unknown operation used in model that is not explicitly declared
Hi @TimiOkusi ,

The 1.x versions are not supported now. Please provide the context and error log for Tf2.x versions. 

As I understand the reported error is with TF1.8 version, and if so we can't support it. Please test with Tf2.x versions and preferably with latest versions and report the problems faced with all the required details for debug. Thanks! This issue is stale because it has been open for 7 days with no activity. It will be closed if no further activity occurs. Thank you. This issue was closed because it has been inactive for 7 days since being marked as stale. Please reopen if you'd like to work on this further. Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/64920">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/64920">No</a>

### Issue type

Bug

### Have you reproduced the bug with TensorFlow Nightly?

No

### Source

source

### TensorFlow version

tf 2.15 and 1.8

### Custom code

Yes

### OS platform and distribution

_No response_

### Mobile device

_No response_

### Python version

_No response_

### Bazel version

_No response_

### GCC/compiler version

_No response_

### CUDA/cuDNN version

_No response_

### GPU model and memory

_No response_

### Current behavior?

I am working on a uni project, a fall detection app built using Android studio and machine learning model.

The model uses time series data gotten from mobile sensors.
I have trained the model using model architecture LSTM -> TimeDistributedLayer -> Dense layer -> Dense layer (Output)

I did this initially on colab which uses tensorflow version 2.15, but when I tried to export it as a tensorflow lite model I was getting some errors during the conversion suggesting me to use SelectOps or flex ops which are because an operation is not supported by tensorflow lite’s standard operations.

Doing that and importing into Android studio, I couldn’t initialize the model without getting error saying “Unsupported data type 14 in tensor” which was probably as a result of Android not having the package to run the added operation.
I have tried importing flex ops into Android studio but didn’t work. Might have done it wrongly though.

Then I backdated the tensorflow version to v1.8 to use freeze graph which exported without any errors.
When i tried doing inferencing, I was getting the error “No OpKernel was registered to support Op ‘ClipByValue’ with these attrs. Register device: CPU, Register Kernel: <No registered kernel >”

I inspected the freeze graph model using Netron and found the clipbyvalue op was being used in the LSTM layer and I’ve tried to declare in the optimizer not to use it though by default no clipping is used but nothing works.

I have also gone through my code to find any non-standard or custom operation used but can’t find any.

So I’m just stuck rn
Below is an image for inferencing

![Screenshot 2024-04-02 160928](https://github.com/tensorflow/tensorflow/assets/148882249/614749e7-d6ad-403d-b8b1-42cc190bf292)

below is the image from netron of the freeze graph model
![Screenshot 2024-04-02 161141](https://github.com/tensorflow/tensorflow/assets/148882249/f935de0b-102d-4c7e-95b6-dcfa2ddc5ede)



### Standalone code to reproduce the issue

```shell
df = pd.read_csv("SisFall_All.csv")
df.drop(columns=['acc2_x', 'acc2_y', 'acc2_z'], inplace=True)
df.set_index(df.index, inplace=True)

# Resample the DataFrame index to downsample from 200Hz to 50Hz
df = df.iloc[::4]

# Reset the index to retain the original row indices
df.reset_index(drop=True, inplace=True)

acc1_resolution = 13
acc1_range = 16

gyro_resolution = 16
gyro_range = 2000

# Convert accelerometer data to gravity units
df['acc1_x'] = (2 * acc1_range / 2**acc1_resolution) * df['acc1_x']
df['acc1_y'] = (2 * acc1_range / 2**acc1_resolution) * df['acc1_y']
df['acc1_z'] = (2 * acc1_range / 2**acc1_resolution) * df['acc1_z']

# Convert gyroscope data to degrees per second
df['gyro_x'] = (2 * gyro_range / 2**gyro_resolution) * df['gyro_x']
df['gyro_y'] = (2 * gyro_range / 2**gyro_resolution) * df['gyro_y']
df['gyro_z'] = (2 * gyro_range / 2**gyro_resolution) * df['gyro_z']

# Convert activity labels to "ADL" or "Fall" based on their first letter
df['label'] = df['label'].apply(lambda x: 'ADL' if x.startswith('D') else 'Fall' if x.startswith('F') else x)
df.drop(columns=['Subject ID_Trial'], inplace=True)

time_steps = 200
features = 6
step = 20
segments = []
labels = []
for i in range(0, len(df) - time_steps, step):
  axs = df['acc1_x'].values[i: i + time_steps]
  ays = df['acc1_y'].values[i: i + time_steps]
  azs = df['acc1_z'].values[i: i + time_steps]
  gxs = df['gyro_x'].values[i: i + time_steps]
  gys = df['gyro_y'].values[i: i + time_steps]
  gzs = df['gyro_z'].values[i: i + time_steps]
#  amags = df['acc_magnitude'].values[i: i + time_steps]

  # label_counts = np.unique(df['label'][i: i + time_steps], return_counts=True)
  # label = label_counts[0][np.argmax(label_counts[1])]
  # segments.append([axs, ays, azs, gxs, gys, gzs])
  # labels.append(label)

  label = stats.mode(df['label'][i: i + time_steps])
  label = label[0][0]
  segments.append([axs, ays, azs, gxs, gys, gzs])
  labels.append(label)

np.array(segments).shape

reshaped_segment = np.asarray(segments, dtype = np.float32).reshape(-1, time_steps, features)
reshaped_segment.shape

from sklearn.preprocessing import LabelEncoder

label_encoder = LabelEncoder()
labels = label_encoder.fit_transform(labels)

print(labels)
print(labels.shape)

from sklearn.model_selection import train_test_split
X_train, X_test, y_train, y_test = train_test_split(reshaped_segment, labels, test_size = 0.2, random_state = 42)

model = Sequential()
# RNN layer
model.add(LSTM(128, input_shape = (200, 6), return_sequences = True, name = 'lstm_1'))
# Apply Dense operations individually to each time sequence
model.add(TimeDistributed(Dense(64, activation='relu'), name='time_distributed'))
# Flatten layer
model.add(Flatten(name='flatten'))
# Dense layer with ReLu
model.add(Dense(64, activation='relu', name='dense_1'))
# Softmax layer
model.add(Dense(2, activation = 'softmax', name='output'))

# Compile model
model.compile(loss='sparse_categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
model.summary()

from keras.callbacks import ModelCheckpoint

callbacks = [ModelCheckpoint('model.h5', save_weights_only=False, save_best_only=True, verbose=1)]
history = model.fit(X_train, y_train, epochs = 10, validation_split = 0.20, batch_size = 256, 
                    verbose = 1, callbacks = callbacks)

from keras.models import load_model
model = load_model('model.h5')
model.summary()

loss, accuracy = model.evaluate(X_test, y_test, batch_size = 128, verbose = 1)
print("Test Accuracy :", accuracy)
print("Test Loss :", loss)

from keras import backend as k
from tensorflow.python.tools import freeze_graph, optimize_for_inference_lib

input_node_name = ['lstm_1_input']
output_node_name = 'output/Softmax'
model_name = 'fall_model'

tf.train.write_graph(k.get_session().graph_def, 'models', model_name + '_graph.pbtxt')
saver = tf.train.Saver()
saver.save(k.get_session(), 'models/' + model_name + '.chkp')

freeze_graph.freeze_graph('models/' +model_name + '_graph.pbtxt', None, False, 'models/' +model_name+'.chkp',output_node_name, 'save/restore_all', 'save/Const:0', 'models/frozen_'+model_name+'.pb', True, "")
```


### Relevant log output

```shell
FATAL EXCEPTION: main
Process: com.example.qdetect, PID: 7760
java.lang.IllegalArgumentException: No OpKernel was registered to support Op 'ClipByValue' with these attrs.  Registered devices: [CPU], Registered kernels:
  <no registered kernels>

	 [[Node: lstm_1/while/clip_by_value = ClipByValue[T=DT_FLOAT](lstm_1/while/add_2, lstm_1/while/Const, lstm_1/while/Const_1)]]
	at org.tensorflow.Session.run(Native Method)
	at org.tensorflow.Session.access$100(Session.java:48)
	at org.tensorflow.Session$Runner.runHelper(Session.java:298)
	at org.tensorflow.Session$Runner.run(Session.java:248)
	at org.tensorflow.contrib.android.TensorFlowInferenceInterface.run(TensorFlowInferenceInterface.java:228)
	at org.tensorflow.contrib.android.TensorFlowInferenceInterface.run(TensorFlowInferenceInterface.java:197)
	at org.tensorflow.contrib.android.TensorFlowInferenceInterface.run(TensorFlowInferenceInterface.java:187)
	at com.example.qdetect.pbClassifier.predict(pbClassifier.java:32)
	at com.example.qdetect.MainActivity.predictActivity(MainActivity.java:172)
	at com.example.qdetect.MainActivity.onSensorChanged(MainActivity.java:118)
	at android.hardware.SystemSensorManager$SensorEventQueue.dispatchSensorEvent(SystemSensorManager.java:1108)
	at android.os.MessageQueue.nativePollOnce(Native Method)
	at android.os.MessageQueue.next(MessageQueue.java:335)
	at android.os.Looper.loopOnce(Looper.java:187)
	at android.os.Looper.loop(Looper.java:319)
	at android.app.ActivityThread.main(ActivityThread.java:8913)
	at java.lang.reflect.Method.invoke(Native Method)
	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608)
	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
```
