Caffe2 - C++ API
A deep learning, cross platform ML framework
compiler.h
1 #pragma once
2 
3 #include <torch/csrc/WindowsTorchApiMacro.h>
4 #include <torch/csrc/jit/fuser/arg_spec.h>
5 #include <torch/csrc/jit/fuser/fused_kernel.h>
6 #include <torch/csrc/jit/fuser/interface.h>
7 #include <torch/csrc/jit/fuser/kernel_spec.h>
8 #include <torch/csrc/jit/ir.h>
9 #include <ATen/core/stack.h>
10 
11 #include <cstdint>
12 #include <vector>
13 
14 namespace torch {
15 namespace jit {
16 namespace fuser {
17 
18 // Performs device-independent "upfront" compilation of the given fusion_group,
19 // if it has not been registered already.
20 // Returns a key that can be used to run the fusion later
21 TORCH_API int64_t registerFusion(const Node* fusion_group);
22 
23 // Performs device-specific "runtime" compilation of the given kernel
24 // with the runtime arguments specified in ArgSpec.
25 // Outputs are allocated using map_size on the specified device.
26 TORCH_API std::shared_ptr<FusedKernel> compileKernel(
27  const KernelSpec& spec,
28  const ArgSpec& arg_spec,
29  const std::vector<int64_t>& map_size,
30  const at::Device device);
31 
32 TORCH_API size_t nCompiledKernels();
33 
34 TORCH_API int debugFuser();
35 
36 using FusedKernelConstructor = std::function<std::shared_ptr<FusedKernel>(
37  int16_t device,
38  std::string name,
39  std::string code,
40  std::vector<TensorDesc> input_desc,
41  std::vector<TensorDesc> output_desc,
42  std::vector<PartitionDesc> chunk_desc,
43  std::vector<PartitionDesc> concat_desc,
44  bool has_random)>;
45 
46 TORCH_API void registerFusionBackend(
47  at::Device::Type backend_type,
48  FusedKernelConstructor ctor);
49 TORCH_API bool hasFusionBackend(at::Device::Type backend_type);
50 struct TORCH_API RegisterFusionBackend {
52  at::Device::Type backend_type,
53  FusedKernelConstructor ctor) {
54  registerFusionBackend(backend_type, std::move(ctor));
55  }
56 };
57 
58 } // namespace fuser
59 } // namespace jit
60 } // namespace torch
Represents a a compute device on which a tensor is located.
Definition: Device.h:30
Definition: jit_type.h:17