Skip to content

Commit

Permalink
Fix issues in TRT model ID generator (#13837)
Browse files Browse the repository at this point in the history
There are some issues in
#13015,
1. Model name should be used rather than graph name in the model ID
generator.
2. Hash collision is observed in ID cache, which means different model
may have the same key and thus load same hash id from the cache.
3. For the class and function that generate model id, MetaDef in the
name is not appropriate.
4. Should reuse murmurhash3 rather than copy it over to TRT EP
This PR fixes those issues.
  • Loading branch information
stevenlix authored Dec 15, 2022
1 parent b52e8bf commit c4ecbb9
Show file tree
Hide file tree
Showing 9 changed files with 98 additions and 436 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "core/providers/shared/common.h"

#include "core/common/inlined_containers.h"
#include "core/framework/murmurhash3.h"
#include "core/framework/random_generator.h"
#include "core/providers/cpu/controlflow/if.h"
#include "core/providers/cpu/controlflow/loop.h"
Expand Down Expand Up @@ -319,6 +320,10 @@ std::unique_ptr<IAllocator> CreateCUDAPinnedAllocator(int16_t device_id, const c
std::unique_ptr<IDataTransfer> CreateGPUDataTransfer() {
return g_host->CreateGPUDataTransfer();
}

void MurmurHash3::x86_128(const void* key, int len, uint32_t seed, void* out) {
return g_host->MurmurHash3__x86_128(key, len, seed, out);
}
#endif

#ifdef USE_MIGRAPHX
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ struct ProviderHost {
virtual const Node* Graph__ParentNode(const Graph* p) const = 0;
virtual const Graph* Graph__ParentGraph(const Graph* p) const = 0;
virtual const std::string& Graph__Name(const Graph* p) const noexcept = 0;
virtual const Path& Graph__ModelPath(const Graph* p) const = 0;
virtual const std::vector<const NodeArg*>& Graph__GetInputsIncludingInitializers(const Graph* p) const noexcept = 0;
virtual bool Graph__IsSubgraph(const Graph* p) = 0;

Expand Down Expand Up @@ -703,6 +704,8 @@ struct ProviderHost {

// Path
virtual PathString Path__ToPathString(const Path* p) noexcept = 0;
virtual const std::vector<PathString>& Path__GetComponents(const Path* p) noexcept = 0;
virtual bool Path__IsEmpty(const Path* p) noexcept = 0;

// OpKernel
virtual const Node& OpKernel__Node(const OpKernel* p) = 0;
Expand Down Expand Up @@ -879,8 +882,13 @@ struct ProviderHost {
virtual RandomGenerator& RandomGenerator__Default() = 0;
#endif

#if defined(USE_TENSORRT)
virtual void MurmurHash3__x86_128(const void* key, int len, uint32_t seed, void* out) = 0;
#endif

virtual ProviderHostCPU& GetProviderHostCPU() = 0;
};

#if defined(_MSC_VER) && !defined(__clang__)
#pragma warning(pop)
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,7 @@ struct Graph final {
const Node* ParentNode() const { return g_host->Graph__ParentNode(this); }
const Graph* ParentGraph() const { return g_host->Graph__ParentGraph(this); }
const std::string& Name() const noexcept { return g_host->Graph__Name(this); }
const Path& ModelPath() const { return g_host->Graph__ModelPath(this); }
const std::vector<const NodeArg*>& GetInputsIncludingInitializers() const noexcept { return g_host->Graph__GetInputsIncludingInitializers(this); }
bool IsSubgraph() const { return g_host->Graph__IsSubgraph(this); }

Expand Down Expand Up @@ -745,6 +746,8 @@ struct GraphViewer final {

struct Path final {
PathString ToPathString() const noexcept { return g_host->Path__ToPathString(this); }
const std::vector<PathString>& GetComponents() const noexcept { return g_host->Path__GetComponents(this); }
bool IsEmpty() const noexcept { return g_host->Path__IsEmpty(this); }

PROVIDER_DISALLOW_ALL(Path)
};
Expand Down
Loading

0 comments on commit c4ecbb9

Please sign in to comment.