Skip to content

Commit c9e093c

Browse files
davidberard98ignaciobartol
authored andcommitted
[Static Runtime] Fix & run gen_static_runtime_ops (pytorch#128299)
gen_static_runtime_ops hasn't been updated in a while. In preparation for pytorch#127675 in which I need to re-run the codegen step for cumprod, I want to land these changes beforehand in case there are any other issues that arise. I added a number of ops to the blocklist: ``` + "_nested_tensor_storage_offsets", + "_nested_get_values", # no CPU backend + "_nested_get_values_copy", # no CPU backend + "_nested_view_from_jagged", # testing needs to be patched + "_nested_view_from_jagged_copy", # testing needs to be patched + "_nested_view_from_buffer", # testing needs to be patched + "_nested_view_from_buffer_copy", # testing needs to be patched + "_int_mm", # testing needs to be patched + "_to_sparse_csc", # testing needs to be patched + "_to_sparse_csr", # testing needs to be patched + "segment_reduce", # testing needs to be patched ``` Most of these are added just because testing doesn't work right now. Additionally, a few `fft` ops seem to have been removed from native_functions.yaml; I'm guessing it's unlikely FFT would have been used in many real models though. Differential Revision: [D58329403](https://our.internmc.facebook.com/intern/diff/D58329403/) Pull Request resolved: pytorch#128299 Approved by: https://github.com/YuqingJ
1 parent 4cd474b commit c9e093c

File tree

4 files changed

+148
-345
lines changed

4 files changed

+148
-345
lines changed

benchmarks/static_runtime/test_generated_ops.cc

Lines changed: 66 additions & 216 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,38 @@ TEST(StaticRuntime, autogen_addr) {
272272
/*check_resize=*/true);
273273
}
274274

275+
TEST(StaticRuntime, autogen__test_functorch_fallback) {
276+
const std::string script = R"IR(
277+
graph(%self: Tensor, %other: Tensor):
278+
%bias: None = prim::Constant()
279+
%ret = aten::_test_functorch_fallback(%self, %other)
280+
%cloned = aten::clone(%ret, %bias)
281+
return (%cloned)
282+
)IR";
283+
284+
auto self0 = at::rand({6, 6, 6});
285+
auto other0 = at::rand({6, 6, 6});
286+
std::vector<IValue> args{self0, other0};
287+
testStaticRuntime(
288+
script,
289+
args,
290+
{},
291+
/*use_allclose=*/false,
292+
/*use_equalnan=*/false,
293+
/*check_resize=*/true);
294+
295+
auto self1 = at::rand({22, 22, 22});
296+
auto other1 = at::rand({22, 22, 22});
297+
std::vector<IValue> args2{self1, other1};
298+
testStaticRuntime(
299+
script,
300+
args,
301+
args2,
302+
/*use_allclose=*/false,
303+
/*use_equalnan=*/false,
304+
/*check_resize=*/true);
305+
}
306+
275307
TEST(StaticRuntime, autogen_argmax) {
276308
const std::string script = R"IR(
277309
graph(%self: Tensor, %dim: int?, %keepdim: bool):
@@ -4440,6 +4472,40 @@ TEST(StaticRuntime, autogen_masked_select) {
44404472
/*check_resize=*/true);
44414473
}
44424474

4475+
TEST(StaticRuntime, autogen_nonzero_static) {
4476+
const std::string script = R"IR(
4477+
graph(%self: Tensor, %size: int, %fill_value: int):
4478+
%bias: None = prim::Constant()
4479+
%ret = aten::nonzero_static(%self, %size, %fill_value)
4480+
%cloned = aten::clone(%ret, %bias)
4481+
return (%cloned)
4482+
)IR";
4483+
4484+
auto self0 = at::rand({6, 6, 6});
4485+
auto size0 = 1;
4486+
auto fill_value0 = 1;
4487+
std::vector<IValue> args{self0, size0, fill_value0};
4488+
testStaticRuntime(
4489+
script,
4490+
args,
4491+
{},
4492+
/*use_allclose=*/false,
4493+
/*use_equalnan=*/false,
4494+
/*check_resize=*/true);
4495+
4496+
auto self1 = at::rand({22, 22, 22});
4497+
auto size1 = 1;
4498+
auto fill_value1 = 1;
4499+
std::vector<IValue> args2{self1, size1, fill_value1};
4500+
testStaticRuntime(
4501+
script,
4502+
args,
4503+
args2,
4504+
/*use_allclose=*/false,
4505+
/*use_equalnan=*/false,
4506+
/*check_resize=*/true);
4507+
}
4508+
44434509
TEST(StaticRuntime, autogen_gather) {
44444510
const std::string script = R"IR(
44454511
graph(%self: Tensor, %dim: int, %index: Tensor, %sparse_grad: bool):
@@ -7106,222 +7172,6 @@ TEST(StaticRuntime, autogen_special_multigammaln) {
71067172
/*check_resize=*/true);
71077173
}
71087174

7109-
TEST(StaticRuntime, autogen_fft_fft) {
7110-
const std::string script = R"IR(
7111-
graph(%self: Tensor, %n: int?, %dim: int, %norm: str?):
7112-
%bias: None = prim::Constant()
7113-
%ret = aten::fft_fft(%self, %n, %dim, %norm)
7114-
%cloned = aten::clone(%ret, %bias)
7115-
return (%cloned)
7116-
)IR";
7117-
7118-
auto self0 = at::rand({6, 6, 6});
7119-
auto n0 = 1;
7120-
auto dim0 = 1;
7121-
auto norm0 = "forward";
7122-
std::vector<IValue> args{self0, n0, dim0, norm0};
7123-
testStaticRuntime(
7124-
script,
7125-
args,
7126-
{},
7127-
/*use_allclose=*/false,
7128-
/*use_equalnan=*/false,
7129-
/*check_resize=*/true);
7130-
7131-
auto self1 = at::rand({22, 22, 22});
7132-
auto n1 = 1;
7133-
auto dim1 = 1;
7134-
auto norm1 = "forward";
7135-
std::vector<IValue> args2{self1, n1, dim1, norm1};
7136-
testStaticRuntime(
7137-
script,
7138-
args,
7139-
args2,
7140-
/*use_allclose=*/false,
7141-
/*use_equalnan=*/false,
7142-
/*check_resize=*/true);
7143-
}
7144-
7145-
TEST(StaticRuntime, autogen_fft_ifft) {
7146-
const std::string script = R"IR(
7147-
graph(%self: Tensor, %n: int?, %dim: int, %norm: str?):
7148-
%bias: None = prim::Constant()
7149-
%ret = aten::fft_ifft(%self, %n, %dim, %norm)
7150-
%cloned = aten::clone(%ret, %bias)
7151-
return (%cloned)
7152-
)IR";
7153-
7154-
auto self0 = at::rand({6, 6, 6});
7155-
auto n0 = 1;
7156-
auto dim0 = 1;
7157-
auto norm0 = "forward";
7158-
std::vector<IValue> args{self0, n0, dim0, norm0};
7159-
testStaticRuntime(
7160-
script,
7161-
args,
7162-
{},
7163-
/*use_allclose=*/false,
7164-
/*use_equalnan=*/false,
7165-
/*check_resize=*/true);
7166-
7167-
auto self1 = at::rand({22, 22, 22});
7168-
auto n1 = 1;
7169-
auto dim1 = 1;
7170-
auto norm1 = "forward";
7171-
std::vector<IValue> args2{self1, n1, dim1, norm1};
7172-
testStaticRuntime(
7173-
script,
7174-
args,
7175-
args2,
7176-
/*use_allclose=*/false,
7177-
/*use_equalnan=*/false,
7178-
/*check_resize=*/true);
7179-
}
7180-
7181-
TEST(StaticRuntime, autogen_fft_rfft) {
7182-
const std::string script = R"IR(
7183-
graph(%self: Tensor, %n: int?, %dim: int, %norm: str?):
7184-
%bias: None = prim::Constant()
7185-
%ret = aten::fft_rfft(%self, %n, %dim, %norm)
7186-
%cloned = aten::clone(%ret, %bias)
7187-
return (%cloned)
7188-
)IR";
7189-
7190-
auto self0 = at::rand({6, 6, 6});
7191-
auto n0 = 1;
7192-
auto dim0 = 1;
7193-
auto norm0 = "forward";
7194-
std::vector<IValue> args{self0, n0, dim0, norm0};
7195-
testStaticRuntime(
7196-
script,
7197-
args,
7198-
{},
7199-
/*use_allclose=*/false,
7200-
/*use_equalnan=*/false,
7201-
/*check_resize=*/true);
7202-
7203-
auto self1 = at::rand({22, 22, 22});
7204-
auto n1 = 1;
7205-
auto dim1 = 1;
7206-
auto norm1 = "forward";
7207-
std::vector<IValue> args2{self1, n1, dim1, norm1};
7208-
testStaticRuntime(
7209-
script,
7210-
args,
7211-
args2,
7212-
/*use_allclose=*/false,
7213-
/*use_equalnan=*/false,
7214-
/*check_resize=*/true);
7215-
}
7216-
7217-
TEST(StaticRuntime, autogen_fft_irfft) {
7218-
const std::string script = R"IR(
7219-
graph(%self: Tensor, %n: int?, %dim: int, %norm: str?):
7220-
%bias: None = prim::Constant()
7221-
%ret = aten::fft_irfft(%self, %n, %dim, %norm)
7222-
%cloned = aten::clone(%ret, %bias)
7223-
return (%cloned)
7224-
)IR";
7225-
7226-
auto self0 = at::rand({6, 6, 6});
7227-
auto n0 = 1;
7228-
auto dim0 = 1;
7229-
auto norm0 = "forward";
7230-
std::vector<IValue> args{self0, n0, dim0, norm0};
7231-
testStaticRuntime(
7232-
script,
7233-
args,
7234-
{},
7235-
/*use_allclose=*/false,
7236-
/*use_equalnan=*/false,
7237-
/*check_resize=*/true);
7238-
7239-
auto self1 = at::rand({22, 22, 22});
7240-
auto n1 = 1;
7241-
auto dim1 = 1;
7242-
auto norm1 = "forward";
7243-
std::vector<IValue> args2{self1, n1, dim1, norm1};
7244-
testStaticRuntime(
7245-
script,
7246-
args,
7247-
args2,
7248-
/*use_allclose=*/false,
7249-
/*use_equalnan=*/false,
7250-
/*check_resize=*/true);
7251-
}
7252-
7253-
TEST(StaticRuntime, autogen_fft_hfft) {
7254-
const std::string script = R"IR(
7255-
graph(%self: Tensor, %n: int?, %dim: int, %norm: str?):
7256-
%bias: None = prim::Constant()
7257-
%ret = aten::fft_hfft(%self, %n, %dim, %norm)
7258-
%cloned = aten::clone(%ret, %bias)
7259-
return (%cloned)
7260-
)IR";
7261-
7262-
auto self0 = at::rand({6, 6, 6});
7263-
auto n0 = 1;
7264-
auto dim0 = 1;
7265-
auto norm0 = "forward";
7266-
std::vector<IValue> args{self0, n0, dim0, norm0};
7267-
testStaticRuntime(
7268-
script,
7269-
args,
7270-
{},
7271-
/*use_allclose=*/false,
7272-
/*use_equalnan=*/false,
7273-
/*check_resize=*/true);
7274-
7275-
auto self1 = at::rand({22, 22, 22});
7276-
auto n1 = 1;
7277-
auto dim1 = 1;
7278-
auto norm1 = "forward";
7279-
std::vector<IValue> args2{self1, n1, dim1, norm1};
7280-
testStaticRuntime(
7281-
script,
7282-
args,
7283-
args2,
7284-
/*use_allclose=*/false,
7285-
/*use_equalnan=*/false,
7286-
/*check_resize=*/true);
7287-
}
7288-
7289-
TEST(StaticRuntime, autogen_fft_ihfft) {
7290-
const std::string script = R"IR(
7291-
graph(%self: Tensor, %n: int?, %dim: int, %norm: str?):
7292-
%bias: None = prim::Constant()
7293-
%ret = aten::fft_ihfft(%self, %n, %dim, %norm)
7294-
%cloned = aten::clone(%ret, %bias)
7295-
return (%cloned)
7296-
)IR";
7297-
7298-
auto self0 = at::rand({6, 6, 6});
7299-
auto n0 = 1;
7300-
auto dim0 = 1;
7301-
auto norm0 = "forward";
7302-
std::vector<IValue> args{self0, n0, dim0, norm0};
7303-
testStaticRuntime(
7304-
script,
7305-
args,
7306-
{},
7307-
/*use_allclose=*/false,
7308-
/*use_equalnan=*/false,
7309-
/*check_resize=*/true);
7310-
7311-
auto self1 = at::rand({22, 22, 22});
7312-
auto n1 = 1;
7313-
auto dim1 = 1;
7314-
auto norm1 = "forward";
7315-
std::vector<IValue> args2{self1, n1, dim1, norm1};
7316-
testStaticRuntime(
7317-
script,
7318-
args,
7319-
args2,
7320-
/*use_allclose=*/false,
7321-
/*use_equalnan=*/false,
7322-
/*check_resize=*/true);
7323-
}
7324-
73257175
TEST(StaticRuntime, autogen_linalg_cross) {
73267176
const std::string script = R"IR(
73277177
graph(%self: Tensor, %other: Tensor, %dim: int):

0 commit comments

Comments
 (0)