[GPU] Gracefully handle zero batch size#34515
Open
mostafafaheem wants to merge 1 commit intoopenvinotoolkit:masterfrom
Open
[GPU] Gracefully handle zero batch size#34515mostafafaheem wants to merge 1 commit intoopenvinotoolkit:masterfrom
mostafafaheem wants to merge 1 commit intoopenvinotoolkit:masterfrom
Conversation
Author
|
Hello @p-durandin, @p-wysocki, @praasz! Is this the right approach, or should it just return an exception? When I tested the following snippet using CPU, it caused a segmentation fault that was fixed when I set batch size to 1, so if the exception approach was to be taken, should it be at the model validation level, or the plugin level? Since CPU plugin also seems to have a problem with 0 batch size. #include <chrono>
#include <thread>
#include <string>
#include <iostream>
#include <openvino/openvino.hpp>
int main(int argc, char *argv[]){
ov::Core ieCore;
auto model = ieCore.read_model(argv[1]);
// Reshape model
model->reshape({0, 3, 300, 300});
ov::CompiledModel compiledModel = ieCore.compile_model(model, argv[2]);
// Create an inference request
ov::InferRequest infer_request = compiledModel.create_infer_request();
// Get input port for model with one input
auto input_port = compiledModel.input();
// Create tensor from external memory
ov::Tensor input_tensor(input_port.get_element_type(), {0, 3, 300, 300});
// Set input tensor for model with one input
infer_request.set_input_tensor(input_tensor);
infer_request.start_async();
infer_request.wait();
std::this_thread::sleep_for(std::chrono::seconds(1));
compiledModel = {};
std::cout << "Hello\n" << std::flush;
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Details:
Tickets:
AI Assistance: