-
Notifications
You must be signed in to change notification settings - Fork 415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SetInput error #7583
Comments
What is the shape of your |
1, 3, 224, 224 |
Okay, just remember that since you haven't declared any dynamic shapes on export, your inputs to forward() need to have that exact shape. Other than that, try building from main to get some useful logging that @GregoryComer added recently - https://github.com/pytorch/executorch/blob/main/runtime/core/portable_type/tensor_impl.cpp#L115 |
Hi @jpeng2012, Could you provide some more information on how you created the tensors? I'm able to run your exported file with the executor_runner, you could also try that along with @dvorjackz 's suggestions. |
The tensor is created like this.
I added some logs in Module::execute
The log output is as below.
Somehow data shape changed after
|
I add load_method right after the module is created, then the issue is gone. Is it expected or some bug in the code? executorch_model_ = std::make_unique(configs.model_path_.c_str()); |
Glad to hear you were able to resolve the issue. Using the Module API, you should be able to do something like this example: #7598, without explicitly calling |
🐛 Describe the bug
I am testing mobilenet_v3_small. My model generation code is below.
import torch
import torchvision
from torch.export import export
from executorch.exir import to_edge
import executorch.exir as exir
from torch.export import export, ExportedProgram
from torchvision.models import mobilenet_v3_small, MobileNet_V3_Small_Weights
from torch.utils.mobile_optimizer import optimize_for_mobile
m = mobilenet_v3_small(weights=MobileNet_V3_Small_Weights.IMAGENET1K_V1).eval()
m.eval()
example_args = (torch.randn(1, 3, 224, 224),)
aten_dialect: ExportedProgram = export(m, example_args)
edge_program: exir.EdgeProgramManager = exir.to_edge(aten_dialect)
executorch_program: exir.ExecutorchProgramManager = edge_program.to_executorch(
exir.ExecutorchBackendConfig(
passes=[], # User-defined passes
)
)
with open("mobilenet_v3_small.pte", "wb") as file:
file.write(executorch_program.buffer)
In my c++ code,
in the setup function, I use
executorch_model_ = std::make_unique(configs.model_path_.c_str(), Module::LoadMode::File);
In setInput function,:
for(int i=0;i<1;i++) {
auto input_tensor0 = executorch::extension::from_blob(input[i]->data, atenShape, data_type));
auto input_tensor = clone_tensor_ptr(input_tensor0);
std::cout<< "tensor data type0 " << static_cast(input_tensor->scalar_type()) << std::endl;
std::cout<< ensor data dim0 " << input_tensor->dim() << std::endl;
this->inputs_.emplace_back(input_tensor);
}
In execute function,
const auto result = executorch_model_->forward(this->inputs_);
I got the following error,
E 00:00:00.271241 executorch:tensor_impl.cpp:98] Attempted to resize a static tensor
E 00:00:00.271286 executorch:method.cpp:808] Error setting input 0: 0x10
F 00:00:00.271312 executorch:result.h:165] In function CheckOk(), assert failed: hasValue_
It looks like its trying to resize the input size of the forward method which TensorShapeDynamism::STATIC. Couldn't figure where it is configured as TensorShapeDynamism::STATIC.
Versions
I am using tag 0.4 on android NTK
The text was updated successfully, but these errors were encountered: