tvm
Loading...
Searching...
No Matches
builtin.h
Go to the documentation of this file.
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19#ifndef TVM_RUNTIME_DISCO_BUILTIN_H_
20#define TVM_RUNTIME_DISCO_BUILTIN_H_
21
22#include <tvm/ffi/dtype.h>
23#include <tvm/ffi/extra/module.h>
24#include <tvm/runtime/tensor.h>
25
26#include <string>
27
28namespace tvm {
29namespace runtime {
30
34enum class ReduceKind : int32_t {
35 kSum = 0,
36 kProd = 1,
37 kMin = 2,
38 kMax = 3,
39 kAvg = 4,
40};
41
43inline std::string ReduceKind2String(ReduceKind kind) {
44 switch (kind) {
46 return "kSum";
48 return "kProd";
50 return "kMin";
52 return "kMax";
54 return "kAvg";
55 }
56 TVM_FFI_THROW(ValueError) << "Unknown ReduceKind: " << static_cast<int>(kind);
57}
58
65TVM_RUNTIME_DLL ffi::Module LoadVMModule(std::string path, ffi::Optional<Device> device);
74 ffi::Optional<Device> device);
104TVM_RUNTIME_DLL void ScatterFromWorker0(ffi::Optional<Tensor> send, bool in_group, Tensor recv);
112TVM_RUNTIME_DLL void GatherToWorker0(Tensor send, bool in_group, ffi::Optional<Tensor> recv);
150
151} // namespace runtime
152} // namespace tvm
153
154#endif // TVM_RUNTIME_DISCO_BUILTIN_H_
RAII wrapper function to enter and exit a context object similar to python's with syntax.
Definition with_context.h:59
Managed Tensor. The array is backed by reference counted blocks.
Definition tensor.h:49
TVM_RUNTIME_DLL Tensor DiscoEmptyTensor(ffi::Shape shape, DLDataType dtype, ffi::Optional< Device > device)
Create an uninitialized empty Tensor.
TVM_RUNTIME_DLL void SyncWorker()
Called by the worker thread. Waiting until the worker completes all its tasks. As a specific example,...
TVM_RUNTIME_DLL ffi::Module LoadVMModule(std::string path, ffi::Optional< Device > device)
Load a runtime Module, then create and initialize a RelaxVM.
std::string ReduceKind2String(ReduceKind kind)
Converts ReduceKind to string.
Definition builtin.h:43
TVM_RUNTIME_DLL void GatherToWorker0(Tensor send, bool in_group, ffi::Optional< Tensor > recv)
Perform a gather operation to worker-0.
TVM_RUNTIME_DLL void AllGather(Tensor send, bool in_group, Tensor recv)
Perform an allgather operation using the underlying communication library.
TVM_RUNTIME_DLL void RecvFromWorker(Tensor buffer, int sender_id)
Receive a buffer from the target sender worker (globally across all groups).
TVM_RUNTIME_DLL void RecvFromWorker0(Tensor buffer)
Receive a buffer from worker-0. No-op if the current worker is worker-0.
TVM_RUNTIME_DLL void BroadcastFromWorker0(Tensor send, bool in_group, Tensor recv)
Perform a broadcast operation from worker-0.
TVM_RUNTIME_DLL void ScatterFromWorker0(ffi::Optional< Tensor > send, bool in_group, Tensor recv)
Perform a scatter operation from worker-0, chunking the given buffer into equal parts.
TVM_RUNTIME_DLL void RecvFromPrevGroup(Tensor buffer)
Receive a buffer from the corresponding worker in the previous group. An error is thrown if the worke...
ReduceKind
Possible kinds of reduction operations.
Definition builtin.h:34
TVM_RUNTIME_DLL void SendToNextGroup(Tensor buffer)
Send a buffer to the corresponding worker in the next group. An error is thrown if the worker is alre...
TVM_RUNTIME_DLL void AllReduce(Tensor send, ReduceKind reduce_kind, bool in_group, Tensor recv)
Perform an allreduce operation using the underlying communication library.
TVM_RUNTIME_DLL void SendToWorker(Tensor buffer, int receiver_id)
Send a buffer to the target receiver worker (globally across all groups).
TVM_RUNTIME_DLL int WorkerId()
Get the local worker id.
An object that builds and maintains block scope and StmtSref mapping for Dependence analysis.
Definition analyzer.h:40
#define TVM_RUNTIME_DLL
Definition base.h:92
A device-independent managed Tensor abstraction.