WHY I can count FLOPs of a model without declare which model to be counted?

Hi everybody. (Apologize in advance if there is any statement sounds impolite due to my unfluently English skill)

I searched for how to count FLOPs for a model. And the below codes is what I found (with a little modified)
This function (get_flops_params()) can get FLOPs of “newmodel” without declaration of which model is going to be counted. It still worked. But WHY?
Since I’m trying to count FLOPs of model from DTLN (GitHub - breizhn/DTLN: Tensorflow 2.x implementation of the DTLN real time speech denoising model. With TF-lite, ONNX and real-time audio processing support.), I used the same function as below, but FLOPs returned 0.

So my question is why it worked though the original code didn’t declare the model name, but it can’t work out for DTLN?

# In TF 2.x you have to use tf.compat.v1.RunMetadata instead of tf.RunMetadata
# To work your code in TF 2.1.0, i have made all necessary changes that are compliant to TF 2.x

print(tf.__version__)
import tensorflow as tf
tf.compat.v1.disable_eager_execution()
print(tf.__version__)

def get_flops_params():
    sess_aha = tf.compat.v1.Session()
    graph = sess_aha.graph
    flops = tf.compat.v1.profiler.profile(graph, options=tf.compat.v1.profiler.ProfileOptionBuilder.float_operation())
    params = tf.compat.v1.profiler.profile(graph, options=tf.compat.v1.profiler.ProfileOptionBuilder.trainable_variables_parameter())
    print('FLOPs: {};    Trainable params: {}'.format(flops.total_float_ops, params.total_parameters))

from tensorflow.keras.layers import Conv2D, MaxPooling2D, Flatten, Dense
from tensorflow.keras.models import Sequential

newmodel = Sequential()
newmodel.add(Conv2D(filters=64, kernel_size=(3, 3), input_shape=(28, 28, 1), activation='relu'))
newmodel.add(MaxPooling2D(pool_size=(2, 2)))
newmodel.add(Flatten())
newmodel.add(Dense(units=100, activation='relu'))
newmodel.add(Dense(units=10, activation='softmax'))

newmodel.summary()
get_flops_params()

# clear out garbage
tf.keras.backend.clear_session()

The following code is my unsuccessful code:

# create instance of the DTLN model class
modeltry = DTLN_model()
# build the model
modeltry.build_DTLN_model()

def get_flops_params(model_name, model_path):
    sess = tf.compat.v1.Session()
    graph = sess.graph

    model_name.load_weights(model_path)
    model_name.summary()

    flops = tf.compat.v1.profiler.profile(graph, options=tf.compat.v1.profiler.ProfileOptionBuilder.float_operation())
    params = tf.compat.v1.profiler.profile(graph, options=tf.compat.v1.profiler.ProfileOptionBuilder.trainable_variables_parameter())
    print('FLOPs: {};    Trainable params: {}'.format(flops.total_float_ops, params.total_parameters))

# from keras.models import load_model
model_path = os.path.join(cwd, "pretrained_model\\model.h5")
print(model_path)

model_DTLN = modeltry.model
get_flops_params(model_DTLN, model_path)

And output of the code above is: (FLOPs: 0; Trainable params: 0)

Layer (type)                    Output Shape         Param #     Connected to                     
==================================================================================================
input_1 (InputLayer)            [(None, None)]       0                                            
__________________________________________________________________________________________________
lambda (Lambda)                 [(None, None, 257),  0           input_1[0][0]                    
__________________________________________________________________________________________________
lstm (LSTM)                     (None, None, 128)    197632      lambda[0][0]                     
__________________________________________________________________________________________________
dropout (Dropout)               (None, None, 128)    0           lstm[0][0]                       
__________________________________________________________________________________________________
lstm_1 (LSTM)                   (None, None, 128)    131584      dropout[0][0]                    
__________________________________________________________________________________________________
dense (Dense)                   (None, None, 257)    33153       lstm_1[0][0]                     
__________________________________________________________________________________________________
activation (Activation)         (None, None, 257)    0           dense[0][0]                      
__________________________________________________________________________________________________
multiply (Multiply)             (None, None, 257)    0           lambda[0][0]                     
                                                                 activation[0][0]                 
__________________________________________________________________________________________________
lambda_1 (Lambda)               (None, None, 512)    0           multiply[0][0]                   
                                                                 lambda[0][1]                     
__________________________________________________________________________________________________
conv1d (Conv1D)                 (None, None, 256)    131072      lambda_1[0][0]                   
__________________________________________________________________________________________________
instant_layer_normalization (In (None, None, 256)    512         conv1d[0][0]                     
__________________________________________________________________________________________________
lstm_2 (LSTM)                   (None, None, 128)    197120      instant_layer_normalization[0][0]
__________________________________________________________________________________________________
dropout_1 (Dropout)             (None, None, 128)    0           lstm_2[0][0]                     
__________________________________________________________________________________________________
lstm_3 (LSTM)                   (None, None, 128)    131584      dropout_1[0][0]                  
__________________________________________________________________________________________________
dense_1 (Dense)                 (None, None, 256)    33024       lstm_3[0][0]                     
__________________________________________________________________________________________________
activation_1 (Activation)       (None, None, 256)    0           dense_1[0][0]                    
__________________________________________________________________________________________________
multiply_1 (Multiply)           (None, None, 256)    0           conv1d[0][0]                     
                                                                 activation_1[0][0]               
__________________________________________________________________________________________________
conv1d_1 (Conv1D)               (None, None, 512)    131072      multiply_1[0][0]                 
__________________________________________________________________________________________________
lambda_2 (Lambda)               (None, None)         0           conv1d_1[0][0]                   
==================================================================================================
Total params: 986,753
Trainable params: 986,753
Non-trainable params: 0
__________________________________________________________________________________________________
FLOPs: 0;    Trainable params: 0