Skip to content

Commit 8a975c0

Browse files
desertfirefacebook-github-bot
authored andcommitted
[LT] Sync with the lazy_tensor_staging branch (pytorch#69527)
Summary: Pull Request resolved: pytorch#69527 - Add missing TORCH_API in class/struct declarations; - Fix internal op declarations in ltc_ops; - Update lazy_ts_lowering.py Test Plan: Imported from OSS Reviewed By: alanwaketan Differential Revision: D32918929 Pulled By: desertfire fbshipit-source-id: e956d51aff5ef593fdf4cd5ad2a38e38788913d8
1 parent 049debd commit 8a975c0

17 files changed

+43
-69
lines changed

tools/build_variables.bzl

+2-3
Original file line numberDiff line numberDiff line change
@@ -374,13 +374,14 @@ lazy_tensor_core_sources = [
374374
"torch/csrc/lazy/core/config.cpp",
375375
"torch/csrc/lazy/core/hash.cpp",
376376
"torch/csrc/lazy/core/helpers.cpp",
377-
"torch/csrc/lazy/core/internal_ops/ltc_ops.cpp",
378377
"torch/csrc/lazy/core/ir.cpp",
379378
"torch/csrc/lazy/core/ir_dump_util.cpp",
380379
"torch/csrc/lazy/core/ir_metadata.cpp",
381380
"torch/csrc/lazy/core/ir_util.cpp",
381+
"torch/csrc/lazy/core/lazy_view.cpp",
382382
"torch/csrc/lazy/core/permutation_util.cpp",
383383
"torch/csrc/lazy/core/shape.cpp",
384+
"torch/csrc/lazy/core/tensor_util.cpp",
384385
"torch/csrc/lazy/core/view_ops/as_strided.cpp",
385386
"torch/csrc/lazy/core/view_ops/as_strided_view_update.cpp",
386387
"torch/csrc/lazy/core/view_ops/diagonal.cpp",
@@ -392,8 +393,6 @@ lazy_tensor_core_sources = [
392393
"torch/csrc/lazy/core/view_ops/select.cpp",
393394
"torch/csrc/lazy/core/view_ops/select_view_update.cpp",
394395
"torch/csrc/lazy/core/view_ops/view.cpp",
395-
"torch/csrc/lazy/core/tensor_util.cpp",
396-
"torch/csrc/lazy/core/lazy_view.cpp",
397396
"torch/csrc/lazy/ts_backend/config.cpp",
398397
"torch/csrc/lazy/ts_backend/ts_node.cpp",
399398
]

tools/codegen/dest/lazy_ts_lowering.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def ts_lowering_body(f: Union[NativeFunctionsGroup, NativeFunction]) -> str:
3535
size_t i = 0;
3636
{emplace_arguments_str}
3737
{emplace_kwarguments}
38-
TSOpVector {schema.aten_name}_out = compiler::LowerTSBuiltin(function, op().op, arguments, kwarguments);
38+
torch::lazy::TSOpVector {schema.aten_name}_out = torch::lazy::LowerTSBuiltin(function, op().op, arguments, kwarguments);
3939
CHECK_EQ({schema.aten_name}_out.size(), {len(func.returns)});
4040
4141
// TODO: need to call GenerateClone sometimes? Or else return LowerBuiltIn() directly

torch/csrc/lazy/core/internal_ops/ltc_ops.cpp

-30
This file was deleted.

torch/csrc/lazy/core/internal_ops/ltc_ops.h

+21-18
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
namespace torch {
99
namespace lazy {
1010

11-
class OpKindWrapper {
11+
class TORCH_API OpKindWrapper {
1212
public:
1313
explicit OpKindWrapper(const char* name) : name_(name) {}
1414

@@ -31,25 +31,28 @@ class OpKindWrapper {
3131
mutable std::once_flag once_;
3232
};
3333

34-
// TODO: some ops may be obsolete
35-
extern const OpKindWrapper ltc_all_to_all;
36-
extern const OpKindWrapper ltc_cast;
37-
extern const OpKindWrapper ltc_collective_permute;
38-
extern const OpKindWrapper ltc_cross_replica_sum;
39-
extern const OpKindWrapper ltc_device_data;
40-
extern const OpKindWrapper ltc_get_dimensions_size;
41-
extern const OpKindWrapper ltc_moving_average;
42-
extern const OpKindWrapper ltc_nms;
43-
extern const OpKindWrapper ltc_not_supported;
44-
extern const OpKindWrapper ltc_replication_pad;
45-
extern const OpKindWrapper ltc_replication_pad_backward;
46-
extern const OpKindWrapper ltc_tensor_data;
34+
const OpKindWrapper ltc_all_to_all("lazy_tensors::all_to_all");
35+
const OpKindWrapper ltc_cast("lazy_tensors::cast");
36+
const OpKindWrapper ltc_collective_permute("lazy_tensors::collective_permute");
37+
const OpKindWrapper ltc_cross_replica_sum("lazy_tensors::cross_replica_sum");
38+
const OpKindWrapper ltc_device_data("lazy_tensors::device_data");
39+
const OpKindWrapper ltc_get_dimensions_size(
40+
"lazy_tensors::ltc_get_dimensions_size");
41+
const OpKindWrapper ltc_moving_average("lazy_tensors::moving_average");
42+
const OpKindWrapper ltc_nms("lazy_tensors::nms");
43+
const OpKindWrapper ltc_not_supported("lazy_tensors::not_supported");
44+
const OpKindWrapper ltc_replication_pad("lazy_tensors::replication_pad");
45+
const OpKindWrapper ltc_replication_pad_backward(
46+
"lazy_tensors::replication_pad_backward");
47+
const OpKindWrapper ltc_tensor_data("lazy_tensors::tensor_data");
4748

4849
// For view ops
49-
extern const OpKindWrapper ltc_as_strided_view_update;
50-
extern const OpKindWrapper ltc_diagonal_view_update;
51-
extern const OpKindWrapper ltc_narrow_view_update;
52-
extern const OpKindWrapper ltc_select_view_update;
50+
const OpKindWrapper ltc_as_strided_view_update(
51+
"lazy_tensors::as_strided_view_update");
52+
const OpKindWrapper ltc_diagonal_view_update(
53+
"lazy_tensors::diagonal_view_update");
54+
const OpKindWrapper ltc_narrow_view_update("lazy_tensors::narrow_view_update");
55+
const OpKindWrapper ltc_select_view_update("lazy_tensors::select_view_update");
5356

5457
} // namespace lazy
5558
} // namespace torch

torch/csrc/lazy/core/lazy_view.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
namespace torch {
1111
namespace lazy {
1212

13-
struct SelectInfo {
13+
struct TORCH_API SelectInfo {
1414
bool operator==(const SelectInfo& ref) const {
1515
return dim == ref.dim && start == ref.start && end == ref.end &&
1616
stride == ref.stride;
@@ -22,7 +22,7 @@ struct SelectInfo {
2222
int64_t stride = 0;
2323
};
2424

25-
struct AsStridedInfo {
25+
struct TORCH_API AsStridedInfo {
2626
bool operator==(const AsStridedInfo& ref) const {
2727
return offset == ref.offset && stride == ref.stride;
2828
}
@@ -31,7 +31,7 @@ struct AsStridedInfo {
3131
int64_t offset = 0;
3232
};
3333

34-
struct DiagonalInfo {
34+
struct TORCH_API DiagonalInfo {
3535
bool operator==(const DiagonalInfo& ref) const {
3636
return offset == ref.offset && dim1 == ref.dim1 && dim2 == ref.dim2;
3737
}
@@ -41,7 +41,7 @@ struct DiagonalInfo {
4141
int64_t dim2 = 1;
4242
};
4343

44-
struct ViewInfo {
44+
struct TORCH_API ViewInfo {
4545
enum class Type {
4646
kInvalid,
4747
kNarrow,
@@ -96,7 +96,7 @@ struct ViewInfo {
9696

9797
// When a "view" (capture by reference) is taken on a node, an Alias object is
9898
// created on the captured node itself, with its current IR Node value.
99-
class Alias {
99+
class TORCH_API Alias {
100100
public:
101101
struct UpdateData {
102102
Value ir_value;
@@ -127,7 +127,7 @@ class Alias {
127127
size_t generation_ = 0;
128128
};
129129

130-
class LazyView {
130+
class TORCH_API LazyView {
131131
public:
132132
LazyView(Shape shape, std::shared_ptr<Alias> alias, ViewInfo view_info);
133133
LazyView(

torch/csrc/lazy/core/view_ops/as_strided.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace torch {
88
namespace lazy {
99

10-
class AsStrided : public TsNode {
10+
class TORCH_API AsStrided : public TsNode {
1111
public:
1212
AsStrided(
1313
const Value& input,

torch/csrc/lazy/core/view_ops/as_strided_view_update.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace torch {
88
namespace lazy {
99

10-
class AsStridedViewUpdate : public TsNode {
10+
class TORCH_API AsStridedViewUpdate : public TsNode {
1111
public:
1212
AsStridedViewUpdate(
1313
const Value& target,

torch/csrc/lazy/core/view_ops/diagonal.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace torch {
66
namespace lazy {
77

8-
class Diagonal : public TsNode {
8+
class TORCH_API Diagonal : public TsNode {
99
public:
1010
Diagonal(const Value& input, int64_t offset, int64_t dim1, int64_t dim2);
1111

torch/csrc/lazy/core/view_ops/diagonal_view_update.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace torch {
66
namespace lazy {
77

8-
class DiagonalViewUpdate : public TsNode {
8+
class TORCH_API DiagonalViewUpdate : public TsNode {
99
public:
1010
DiagonalViewUpdate(
1111
const Value& target,

torch/csrc/lazy/core/view_ops/narrow.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace torch {
66
namespace lazy {
77

8-
class Narrow : public TsNode {
8+
class TORCH_API Narrow : public TsNode {
99
public:
1010
Narrow(
1111
const Value& input,

torch/csrc/lazy/core/view_ops/narrow_view_update.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace torch {
66
namespace lazy {
77

8-
class NarrowViewUpdate : public TsNode {
8+
class TORCH_API NarrowViewUpdate : public TsNode {
99
public:
1010
NarrowViewUpdate(
1111
const Value& input,

torch/csrc/lazy/core/view_ops/permute.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace torch {
66
namespace lazy {
77

8-
class Permute : public TsNode {
8+
class TORCH_API Permute : public TsNode {
99
public:
1010
Permute(const Value& input, std::vector<int64_t> dims);
1111

torch/csrc/lazy/core/view_ops/resize.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace torch {
66
namespace lazy {
77

8-
class Resize : public TsNode {
8+
class TORCH_API Resize : public TsNode {
99
public:
1010
Resize(const Value& input, std::vector<int64_t> size);
1111

torch/csrc/lazy/core/view_ops/select.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace torch {
66
namespace lazy {
77

8-
class Select : public TsNode {
8+
class TORCH_API Select : public TsNode {
99
public:
1010
Select(
1111
const Value& input,

torch/csrc/lazy/core/view_ops/select_view_update.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace torch {
66
namespace lazy {
77

8-
class SelectViewUpdate : public TsNode {
8+
class TORCH_API SelectViewUpdate : public TsNode {
99
public:
1010
SelectViewUpdate(
1111
const Value& target,

torch/csrc/lazy/core/view_ops/view.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include <torch/csrc/lazy/core/view_ops/view.h>
22

3+
#include <ATen/InferSize.h>
4+
35
namespace torch {
46
namespace lazy {
57

torch/csrc/lazy/core/view_ops/view.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
namespace torch {
88
namespace lazy {
99

10-
class View : public TsNode {
10+
class TORCH_API View : public TsNode {
1111
public:
1212
View(const Value& input, std::vector<int64_t> output_size);
1313

0 commit comments

Comments
 (0)