Caffe2 - C++ API
A deep learning, cross platform ML framework
kernel_cache.h
1 #pragma once
2 
3 #include <c10/util/Optional.h>
4 #include <torch/csrc/WindowsTorchApiMacro.h>
5 #include <torch/csrc/jit/fuser/kernel_spec.h>
6 #include <torch/csrc/jit/ir.h>
7 
8 #include <cstdint>
9 #include <functional>
10 
11 namespace torch {
12 namespace jit {
13 namespace fuser {
14 
15 // A thread-safe cache interface.
16 
17 // Normalizes the graph by canonicalizing and erasing shape information
18 TORCH_API std::shared_ptr<Graph> normalizeGraphForCache(
19  const std::shared_ptr<Graph>& graph);
20 
21 // Stores the given graph, returning the key used to access it
22 TORCH_API int64_t store(std::shared_ptr<Graph> graph);
23 
24 // Given a graph, find a KernelSpec based on it
25 TORCH_API at::optional<KernelSpec*> lookupGraph(std::shared_ptr<Graph> graph);
26 
27 // Returns the graph corresponding to the given key (if it exists)
28 TORCH_API at::optional<KernelSpec*> retrieve(const int64_t key);
29 
30 // Returns the size of the fusion key -> KernelSpec cache.
31 // Only used for testing.
32 TORCH_API int64_t debugNumCachedKernelSpecs();
33 
34 } // namespace fuser
35 } // namespace jit
36 } // namespace torch
Definition: jit_type.h:17