tenstorrent / tt-buda

Tenstorrent TT-BUDA Repository
Other
150 stars 21 forks source link

NotImplementedError for TensorFlow operators during PyBUDA inference {'TensorListGetItem', 'TensorListReserve', 'TensorListSetItem', 'TensorListStack', 'TensorListFromTensor'} #33

Open trinhgiahuy opened 1 week ago

trinhgiahuy commented 1 week ago

I encountered a NotImplementedError when running inference with PyBUDA on a TensorFlow model. The error indicates that several TensorFlow operators are not implemented. NotImplementedError: The following operators are not implemented: {'TensorListGetItem', 'TensorListReserve', 'TensorListSetItem', 'TensorListStack', 'TensorListFromTensor'}

Environment

OS: Ubuntu 20.04 Card: Grayskull e150 Python: 3.8 BUDA: v0.12.3 follow this instruction

Error

image

Code to reproduce

import pybuda
import onnx
import numpy as np
import os
import torch
import tensorflow as tf
from pybuda._C.backend_api import BackendDevice

variant = "dla34"

dummy_input = torch.tensor(np.random.rand(2, 4, 5440).astype(np.float32))

compiler_cfg = pybuda.config._get_global_compiler_config()
compiler_cfg.balancer_policy = "Ribbon"
compiler_cfg.enable_t_streaming = True
os.environ["PYBUDA_RIBBON2"] = "1"

available_devices = pybuda.detect_available_devices()
if available_devices:
    arch = available_devices[0]
    print(f"arch : {arch}")
    if arch == BackendDevice.Grayskull:
        if variant == "dla102x2":
            os.environ["PYBUDA_FORCE_CONV_MULTI_OP_FRACTURE"] = "1"

base_dir = os.path.join(os.getcwd(), "src", "processing", "ML", "models", "LSTM_4class")
model_path = os.path.join(base_dir, "model_LSTM_4class.h5")
tf_model = tf.keras.models.load_model(model_path)

pybuda_module = pybuda.TFModule(
    "tf_lstm_4class",  
    tf_model
)

tt0 = pybuda.TTDevice(
    name="tt_device_0",
    arch=pybuda.BackendDevice.Grayskull
)

tt0.place_module(module=pybuda_module)
tt0.push_to_inputs((dummy_input,))

output_q = pybuda.run_inference()
print(f"output_q: {output_q}")
output = output_q.get()
print("Inference output:", output)

predicted_value = np.argmax(output[0].numpy(), axis=-1).item()

label_mapping = {0: 'Empty', 1: 'Moving', 2: 'Stationary', 3: 'In_bed', 4: 'on_floor'}
predicted_label = label_mapping[predicted_value]

print(f"Predicted label: {predicted_label}")
milank94 commented 3 days ago

@trinhgiahuy TensorFlow support is currently limited to a few models / ops. We're actively working on bringing up more functionality. In the meantime, is the PyTorch variant a viable alternative?

trinhgiahuy commented 3 days ago

@milank94 we would try to implement our model in PyTorch and test with PyTorchModule

staylorTT commented 12 hours ago

@trinhgiahuy let us know how the implementation goes.