Delete dead code

This commit is contained in:
Changming Sun 2019-02-06 14:31:02 -08:00
parent 8a8d1b0cea
commit f20258e9ed
3 changed files with 1 additions and 29 deletions

View file

@ -15,23 +15,11 @@ class InsertCastTransformer : public onnxruntime::GraphTransformer {
force_cpu_fp32_(true) {
}
void AddKernelRegistries(const std::vector<const KernelRegistry*>& kernels) {
for (auto* kernel : kernels) {
if (kernel)
kernels_registries_.push_back(kernel);
}
}
void AddKernelRegistry(const KernelRegistry& kernel) {
kernels_registries_.push_back(&kernel);
}
private:
Status ApplyImpl(onnxruntime::Graph& graph, bool& modified, int graph_level) const override;
bool NeedInsertCast(const onnxruntime::Node* node, const onnxruntime::NodeArg* input) const;
std::vector<const KernelRegistry*> kernels_registries_;
// Currently because we only have very few cpu kernels support float16, place those nodes on float16
// will introduce many cast between fp32 and fp16, which will slow the execution.
// A better solution is to have a cost model to evaluate does it works to place the node on float16.

View file

@ -341,9 +341,7 @@ class InferenceSession::Impl {
// The 1st ones should have already been registered via session-level API into KernelRegistryManager.
//
// Register 2nd registries into KernelRegistryManager.
kernel_registry_manager_.RegisterKernels(execution_providers_);
insert_cast_transformer_.AddKernelRegistries(kernel_registry_manager_.GetAllKernelRegistries());
kernel_registry_manager_.RegisterKernels(execution_providers_, KernelRegistryPriority::LowPriority);
SessionStateInitializer session_initializer{graph, session_state_, execution_providers_,
kernel_registry_manager_};

View file

@ -32,14 +32,7 @@ TEST(TransformerTest, InsertCastGPUTest) {
auto status = graph.Resolve();
ASSERT_TRUE(status.IsOK()) << status.ErrorMessage();
auto cpu_execution_provider = TestCPUExecutionProvider();
InsertCastTransformer transformer("Test");
transformer.AddKernelRegistry(*cpu_execution_provider->GetKernelRegistry().get());
#ifdef USE_CUDA
auto cuda_execution_provider = TestCudaExecutionProvider();
transformer.AddKernelRegistry(*cuda_execution_provider->GetKernelRegistry().get());
#endif
bool modified = true;
status = transformer.Apply(graph, modified);
@ -87,14 +80,7 @@ TEST(TransformerTest, InsertCastAllCPUTest) {
auto status = graph.Resolve();
ASSERT_TRUE(status.IsOK()) << status.ErrorMessage();
auto cpu_execution_provider = TestCPUExecutionProvider();
InsertCastTransformer transformer("Test");
transformer.AddKernelRegistry(*cpu_execution_provider->GetKernelRegistry().get());
#ifdef USE_CUDA
auto cuda_execution_provider = TestCudaExecutionProvider();
transformer.AddKernelRegistry(*cuda_execution_provider->GetKernelRegistry().get());
#endif
bool modified = true;
EXPECT_TRUE(transformer.Apply(graph, modified).IsOK());