-
Notifications
You must be signed in to change notification settings - Fork 1k
Expand file tree
/
Copy pathop_tile_crop_aot.cpp
More file actions
55 lines (43 loc) · 1.63 KB
/
op_tile_crop_aot.cpp
File metadata and controls
55 lines (43 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree.
*/
#include <executorch/extension/aten_util/make_aten_functor_from_et_functor.h>
#include <executorch/extension/kernel_util/make_boxed_from_unboxed_functor.h>
#include <executorch/extension/llm/custom_ops/op_tile_crop.h>
#include <torch/library.h>
namespace torch {
namespace executor {
namespace native {
Tensor&
tile_crop_out_no_context(const Tensor& input, int64_t tile_size, Tensor& out);
Tensor&
tile_crop_out_no_context(const Tensor& input, int64_t tile_size, Tensor& out) {
executorch::aten::RuntimeContext context{};
return tile_crop_out_impl(context, input, tile_size, out);
}
at::Tensor tile_crop_aten(const at::Tensor& input, int64_t tile_size);
at::Tensor tile_crop_aten(const at::Tensor& input, int64_t tile_size) {
// max_num_tiles = 4, num_channels = 3.
auto output = at::empty({4, 3, tile_size, tile_size});
WRAP_TO_ATEN(torch::executor::native::tile_crop_out_no_context, 2)
(input, tile_size, output);
return output;
}
} // namespace native
} // namespace executor
} // namespace torch
TORCH_LIBRARY(preprocess, m) {
m.def("tile_crop(Tensor input, int tile_size) -> Tensor");
m.def(
"tile_crop.out(Tensor input, int tile_size, *, Tensor(a!) out) -> Tensor(a!)");
}
TORCH_LIBRARY_IMPL(preprocess, CompositeExplicitAutograd, m) {
m.impl("tile_crop", torch::executor::native::tile_crop_aten);
m.impl(
"tile_crop.out",
WRAP_TO_ATEN(torch::executor::native::tile_crop_out_no_context, 2));
}