Skip to content

Commit bd61d18

Browse files
authored
[Relay] s/SEScope/VirtualDevice/g (#9759)
* [Relay] s/SEScope/VirtualDevice/g Nobody liked 'SEScope', and 'DeviceMcDeviceFace' is too verbose, so it seems 'VirtualDevice' has the popular vote.
1 parent 217204c commit bd61d18

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1514
-1424
lines changed

include/tvm/ir/expr.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ namespace tvm {
3939

4040
using tvm::runtime::String;
4141

42-
// Forward-declare SEScope to avoid circular imports.
43-
class SEScope;
42+
// Forward-declare VirtualDevice to avoid circular imports.
43+
class VirtualDevice;
4444

4545
/*!
4646
* \brief Base type of all the expressions.
@@ -169,7 +169,7 @@ class RelayExprNode : public BaseExprNode {
169169
inline const TTypeNode* type_as() const;
170170

171171
/*!
172-
* \brief The virtual device (SEScope) for this node (the result of device planning).
172+
* \brief The virtual device (VirtualDevice) for this node (the result of device planning).
173173
* For first-order expressions (non functions), this describes where the result of evaluating the
174174
* expression should be stored. Note that currently, all composite first-order values (tuples,
175175
* references, ADTs) must be stored on the same virtual device. This means that it is not possible
@@ -178,18 +178,18 @@ class RelayExprNode : public BaseExprNode {
178178
*
179179
* For expressions that have the function type, the virtual device describes where the result of
180180
* the call to the function or closure is stored (instead of where the function itself is stored).
181-
* The SEScope's Target field describes how the body of the function should be compiled.
181+
* The VirtualDevice's Target field describes how the body of the function should be compiled.
182182
*
183183
* \note Unfortunately, the type of virtual_device_ needs to be ObjectRef to avoid a circular
184184
* import.
185185
*/
186186
mutable ObjectRef virtual_device_;
187187

188188
/*!
189-
* \return The virtual device (SEScope).
190-
* If the virtual device is not defined, returns SEScope::FullyUnconstrained().
189+
* \return The virtual device (VirtualDevice).
190+
* If the virtual device is not defined, returns VirtualDevice::FullyUnconstrained().
191191
*/
192-
SEScope virtual_device() const;
192+
VirtualDevice virtual_device() const;
193193

194194
static constexpr const char* _type_key = "RelayExpr";
195195
static constexpr const uint32_t _type_child_slots = 22;

include/tvm/ir/function.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,24 +191,24 @@ constexpr const char* kTarget = "target";
191191
constexpr const char* kGlobalSymbol = "global_symbol";
192192

193193
/*!
194-
* \brief The SEScope which will hold each of the functions parameters.
194+
* \brief The \p VirtualDevice which will hold each of the functions parameters.
195195
*
196196
* Only supported on Relay \p Functions. Generally added by the \p PlanDevices pass, but
197197
* may be included as an annotation on user programs.
198198
*
199-
* Type: Array<SEScope>
199+
* Type: Array<VirtualDevice>
200200
*/
201-
constexpr const char* kParamSEScopes = "param_se_scopes";
201+
constexpr const char* kParamVirtualDevice = "param_virtual_devices";
202202

203203
/*!
204-
* \brief The SEScope which will hold the function result.
204+
* \brief The \p VirtualDevice which will hold the function result.
205205
*
206206
* Only supported on Relay \p Functions. Generally added by the \p PlanDevices pass, but
207207
* may be included as an annotation on user programs.
208208
*
209-
* Type: SEScope
209+
* Type: VirtualDevice
210210
*/
211-
constexpr const char* kResultSEScope = "result_se_scope";
211+
constexpr const char* kResultVirtualDevice = "result_virtual_device";
212212

213213
} // namespace attr
214214
} // namespace tvm

include/tvm/relay/attrs/device_copy.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#define TVM_RELAY_ATTRS_DEVICE_COPY_H_
2626

2727
#include <tvm/ir/attrs.h>
28-
#include <tvm/target/se_scope.h>
28+
#include <tvm/target/virtual_device.h>
2929

3030
#include <string>
3131

@@ -36,13 +36,13 @@ namespace relay {
3636
* \brief Options for the device copy operators.
3737
*/
3838
struct DeviceCopyAttrs : public tvm::AttrsNode<DeviceCopyAttrs> {
39-
SEScope src_se_scope = SEScope::FullyUnconstrained();
40-
SEScope dst_se_scope = SEScope::FullyUnconstrained();
39+
VirtualDevice src_virtual_device = VirtualDevice::FullyUnconstrained();
40+
VirtualDevice dst_virtual_device = VirtualDevice::FullyUnconstrained();
4141

4242
TVM_DECLARE_ATTRS(DeviceCopyAttrs, "relay.attrs.DeviceCopyAttrs") {
43-
TVM_ATTR_FIELD(src_se_scope)
43+
TVM_ATTR_FIELD(src_virtual_device)
4444
.describe("The (virtual) device and scope where the op copies data from.");
45-
TVM_ATTR_FIELD(dst_se_scope)
45+
TVM_ATTR_FIELD(dst_virtual_device)
4646
.describe("The (virtual) device and scope where the op copies data to.");
4747
}
4848
};

include/tvm/relay/attrs/memory.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
#include <tvm/ir/attrs.h>
2828
#include <tvm/relay/expr.h>
29-
#include <tvm/target/se_scope.h>
29+
#include <tvm/target/virtual_device.h>
3030

3131
#include <string>
3232
#include <vector>
@@ -43,13 +43,13 @@ Expr ToTupleType(const Type& t, const std::vector<Expr>& exprs);
4343
*/
4444
struct AllocStorageAttrs : public tvm::AttrsNode<AllocStorageAttrs> {
4545
DataType dtype;
46-
SEScope se_scope = SEScope::FullyUnconstrained();
46+
VirtualDevice virtual_device = VirtualDevice::FullyUnconstrained();
4747

4848
TVM_DECLARE_ATTRS(AllocStorageAttrs, "relay.attrs.AllocStorageAttrs") {
4949
TVM_ATTR_FIELD(dtype)
5050
.describe("The dtype of the tensor to allocate.")
5151
.set_default(DataType::Float(32, 1));
52-
TVM_ATTR_FIELD(se_scope).describe("The SEScope on which to allocate memory.");
52+
TVM_ATTR_FIELD(virtual_device).describe("The virtual device on which to allocate memory.");
5353
}
5454
};
5555

include/tvm/relay/attrs/on_device.h

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#define TVM_RELAY_ATTRS_ON_DEVICE_H_
2626

2727
#include <tvm/ir/attrs.h>
28-
#include <tvm/target/se_scope.h>
28+
#include <tvm/target/virtual_device.h>
2929

3030
#include <string>
3131

@@ -37,42 +37,43 @@ namespace relay {
3737
*
3838
* The Relay call:
3939
* \code
40-
* on_device(sub_expr, se_scope=S)
40+
* on_device(sub_expr, virtual_device=S)
4141
* \endcode
42-
* constrains \p sub_expr to execute and store its result on the \p SEScope \p S.
42+
* constrains \p sub_expr to execute and store its result on the \p VirtualDevice \p S.
4343
* However the annotation itself may appear in an expression to be executed and stored on a
44-
* different \p SEScope. If so the compiler will automatically insert a "device_copy" call to
45-
* mediate the transition between \p SEScopes.
44+
* different \p VirtualDevice. If so the compiler will automatically insert a "device_copy" call to
45+
* mediate the transition between \p VirtualDevices.
4646
*
4747
* E.g.: Assuming %x and %y reside on the GPU and %z on the CPU then:
4848
* \code
49-
* multiply(on_device(add(%x, %y), se_scope=GPU), %z)
49+
* multiply(on_device(add(%x, %y), virtual_device=GPU), %z)
5050
* \endcode
5151
* indicates the \p add should execute on the GPU but the \p multiply should execute on the CPU.
5252
* The compiler will rewrite this to:
5353
* \code
54-
* multiply(device_copy(add(%x, %y), src_se_scope=GPU, dst_se_scope=CPU), %z)
54+
* multiply(device_copy(add(%x, %y), src_virtual_device=GPU, dst_virtual_device=CPU), %z)
5555
* \endcode
5656
*
5757
* The \p constraint_body (default true) and \p constraint_result (default false) fields can be
58-
* used by passes for finer-grained control over how the \p SEScope constraint should be applied.
58+
* used by passes for finer-grained control over how the \p VirtualDevice constraint should be
59+
* applied.
5960
*/
6061
struct OnDeviceAttrs : public tvm::AttrsNode<OnDeviceAttrs> {
6162
/*!
62-
* \brief The \p SEScope to constraint to apply to the body, result, or both body and result
63+
* \brief The \p VirtualDevice to constraint to apply to the body, result, or both body and result
6364
* of the "on_device" call.
6465
*/
65-
SEScope se_scope = SEScope::FullyUnconstrained();
66+
VirtualDevice virtual_device = VirtualDevice::FullyUnconstrained();
6667

6768
/*!
6869
* \brief If false (the default), the result of the "on_device" call is not constrained to be
69-
* \p se_scope.
70+
* \p virtual_device.
7071
*/
7172
bool constrain_result = false;
7273

7374
/*!
7475
* \brief If true (the default), the body of the "on_device" call is constrained to be \p
75-
* se_scope.
76+
* virtual_device.
7677
*/
7778
bool constrain_body = true;
7879

@@ -87,9 +88,9 @@ struct OnDeviceAttrs : public tvm::AttrsNode<OnDeviceAttrs> {
8788
bool is_normal() const { return !constrain_result && constrain_body; }
8889

8990
TVM_DECLARE_ATTRS(OnDeviceAttrs, "relay.attrs.OnDeviceAttrs") {
90-
TVM_ATTR_FIELD(se_scope)
91+
TVM_ATTR_FIELD(virtual_device)
9192
.describe("The (virtual) device to constrain to.")
92-
.set_default(SEScope::FullyUnconstrained());
93+
.set_default(VirtualDevice::FullyUnconstrained());
9394
TVM_ATTR_FIELD(constrain_result)
9495
.describe("Whether the constraint applies to the overall expression")
9596
.set_default(false);

include/tvm/relay/expr.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <tvm/ir/expr.h>
2929
#include <tvm/ir/module.h>
3030
#include <tvm/ir/op.h>
31-
#include <tvm/target/se_scope.h>
31+
#include <tvm/target/virtual_device.h>
3232

3333
#include <functional>
3434
#include <stack>
@@ -158,7 +158,7 @@ class Tuple : public Expr {
158158
* ret_tuple->span = tuple->span.
159159
*/
160160
Tuple WithFields(Tuple tuple, Optional<Array<Expr>> opt_fields = Optional<Array<Expr>>(),
161-
Optional<SEScope> opt_virtual_device = Optional<SEScope>(),
161+
Optional<VirtualDevice> opt_virtual_device = Optional<VirtualDevice>(),
162162
Optional<Span> opt_span = Optional<Span>());
163163

164164
/*!
@@ -264,7 +264,7 @@ class Var : public Expr {
264264
*/
265265
Var WithFields(Var var, Optional<Id> opt_vid = Optional<Id>(),
266266
Optional<Type> opt_type_annotation = Optional<Type>(),
267-
Optional<SEScope> opt_virtual_device = Optional<SEScope>(),
267+
Optional<VirtualDevice> opt_virtual_device = Optional<VirtualDevice>(),
268268
Optional<Span> opt_span = Optional<Span>());
269269

270270
/*!
@@ -391,7 +391,7 @@ Call WithFields(Call call, Optional<Expr> opt_op = Optional<Expr>(),
391391
Optional<Array<Expr>> opt_args = Optional<Array<Expr>>(),
392392
Optional<Attrs> opt_attrs = Optional<Attrs>(),
393393
Optional<Array<Type>> opt_type_args = Optional<Array<Type>>(),
394-
Optional<SEScope> opt_virtual_device = Optional<SEScope>(),
394+
Optional<VirtualDevice> opt_virtual_device = Optional<VirtualDevice>(),
395395
Optional<Span> opt_span = Optional<Span>());
396396

397397
/*!
@@ -487,7 +487,7 @@ class Let : public Expr {
487487
Let WithFields(Let let, Optional<Var> opt_var = Optional<Var>(),
488488
Optional<Expr> opt_value = Optional<Expr>(),
489489
Optional<Expr> opt_body = Optional<Expr>(),
490-
Optional<SEScope> opt_virtual_device = Optional<SEScope>(),
490+
Optional<VirtualDevice> opt_virtual_device = Optional<VirtualDevice>(),
491491
Optional<Span> opt_span = Optional<Span>());
492492

493493
/*!
@@ -574,7 +574,7 @@ class If : public Expr {
574574
If WithFields(If if_expr, Optional<Expr> opt_cond = Optional<Expr>(),
575575
Optional<Expr> opt_true_branch = Optional<Expr>(),
576576
Optional<Expr> opt_false_branch = Optional<Expr>(),
577-
Optional<SEScope> opt_virtual_device = Optional<SEScope>(),
577+
Optional<VirtualDevice> opt_virtual_device = Optional<VirtualDevice>(),
578578
Optional<Span> opt_span = Optional<Span>());
579579

580580
/*! \brief Get index-th field out of a tuple. */
@@ -640,7 +640,7 @@ class TupleGetItem : public Expr {
640640
*/
641641
TupleGetItem WithFields(TupleGetItem tuple_get_item, Optional<Expr> opt_tuple = Optional<Expr>(),
642642
Optional<Integer> opt_index = Optional<Integer>(),
643-
Optional<SEScope> opt_virtual_device = Optional<SEScope>(),
643+
Optional<VirtualDevice> opt_virtual_device = Optional<VirtualDevice>(),
644644
Optional<Span> opt_span = Optional<Span>());
645645

646646
/*! \brief Create a new Reference out of initial value. */
@@ -701,7 +701,7 @@ class RefCreate : public Expr {
701701
* ret_ref_create->value = opt_value.value()).
702702
*/
703703
RefCreate WithFields(RefCreate ref_create, Optional<Expr> opt_value = Optional<Expr>(),
704-
Optional<SEScope> opt_virtual_device = Optional<SEScope>(),
704+
Optional<VirtualDevice> opt_virtual_device = Optional<VirtualDevice>(),
705705
Optional<Span> opt_span = Optional<Span>());
706706

707707
/*! \brief Get value out of Reference. */
@@ -761,7 +761,7 @@ class RefRead : public Expr {
761761
* if opt_ref.value() != ref_read->ref, then ret_ref_read->ref = opt_ref.value()).
762762
*/
763763
RefRead WithFields(RefRead ref_read, Optional<Expr> opt_ref = Optional<Expr>(),
764-
Optional<SEScope> opt_virtual_device = Optional<SEScope>(),
764+
Optional<VirtualDevice> opt_virtual_device = Optional<VirtualDevice>(),
765765
Optional<Span> opt_span = Optional<Span>());
766766

767767
/*! \brief Set value of Reference. The whole expression evaluates to an Empty Tuple. */
@@ -829,7 +829,7 @@ class RefWrite : public Expr {
829829
*/
830830
RefWrite WithFields(RefWrite ref_write, Optional<Expr> opt_ref = Optional<Expr>(),
831831
Optional<Expr> opt_value = Optional<Expr>(),
832-
Optional<SEScope> opt_virtual_device = Optional<SEScope>(),
832+
Optional<VirtualDevice> opt_virtual_device = Optional<VirtualDevice>(),
833833
Optional<Span> opt_span = Optional<Span>());
834834

835835
/*!

include/tvm/relay/function.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ Function WithFields(Function function, Optional<Array<Var>> opt_params = Optiona
148148
Optional<Type> opt_ret_type = Optional<Type>(),
149149
Optional<Array<TypeVar>> opt_ty_params = Optional<Array<TypeVar>>(),
150150
Optional<DictAttrs> opt_attrs = Optional<DictAttrs>(),
151-
Optional<SEScope> opt_virtual_device = Optional<SEScope>(),
151+
Optional<VirtualDevice> opt_virtual_device = Optional<VirtualDevice>(),
152152
Optional<Span> opt_span = Optional<Span>());
153153

154154
/*

include/tvm/relay/transform.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@
3131
#include <tvm/relay/op.h>
3232
#include <tvm/relay/op_attr_types.h>
3333
#include <tvm/target/compilation_config.h>
34-
#include <tvm/target/se_scope.h>
3534
#include <tvm/target/target.h>
35+
#include <tvm/target/virtual_device.h>
3636

3737
#include <string>
3838

@@ -449,22 +449,22 @@ TVM_DLL Pass RelayToTIRTargetHook();
449449
* \brief A pass for manifesting explicit memory allocations and rewriting
450450
* specific dialects.
451451
*
452-
* \param cpu_se_scope SEScope for computations and data which must reside on a CPU, such as
453-
* shapes and shape functions.
452+
* \param cpu_virtual_device VirtualDevice for computations and data which must reside on a CPU,
453+
* such as shapes and shape functions.
454454
*
455455
* \return The pass.
456456
*/
457-
TVM_DLL Pass ManifestAlloc(SEScope cpu_se_scope);
457+
TVM_DLL Pass ManifestAlloc(VirtualDevice cpu_virtual_device);
458458

459459
/*!
460-
* \brief Uses existing "on_device" and "device_copy" CallNodes to infer the \p SEScope on which
461-
* every Relay sub-expression should run and the result stored. Captures the result of that
460+
* \brief Uses existing "on_device" and "device_copy" CallNodes to infer the \p VirtualDevice on
461+
* which every Relay sub-expression should run and the result stored. Captures the result of that
462462
* analysis using new "on_device" and "device_copy" CallNodes.
463463
*
464464
* See tvm::relay::transform::{LexicalOnDeviceMixin,DeviceAwareExprVisitor,DeviceAwareExprMutator}
465465
* for help recovering the device for an arbitrary sub-expression in downstream transformations.
466466
*
467-
* \param config Describes the targets and default \p SEScope for all primitive operators and
467+
* \param config Describes the targets and default \p VirtualDevice for all primitive operators and
468468
* host sub-expressions.
469469
*
470470
* \return The pass.

0 commit comments

Comments
 (0)