Fix a path problem in onnxruntime_perf_test (#21341)

### Description
Resolve #21267 . onnxruntime_perf_test does not work properly if the
input model path url is just a single filename without any path
separator. For example,

```
./onnxruntime_perf_test -t 10 model.onnx
```

The problem was introduced in #19196 by me.
This commit is contained in:
Changming Sun 2024-07-15 10:47:02 -07:00 committed by GitHub
parent 281ed8c12d
commit dfaf18928a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -53,7 +53,8 @@ class TestModelInfo {
public:
virtual const std::filesystem::path& GetModelUrl() const = 0;
virtual std::filesystem::path GetDir() const {
return GetModelUrl().parent_path();
const auto& p = GetModelUrl();
return p.has_parent_path() ? p.parent_path() : std::filesystem::current_path();
}
virtual const std::string& GetNodeName() const = 0;
virtual const ONNX_NAMESPACE::ValueInfoProto* GetInputInfoFromModel(size_t i) const = 0;