Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion docs/source/nn.functional.rst
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ Vision functions
deform_conv2d
pad
interpolate
interpolate_like
upsample
grid_sample
affine_grid
Expand Down
8 changes: 3 additions & 5 deletions oneflow/core/functional/functional_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1793,11 +1793,9 @@
bind_python: False

- name: "upsample_nearest_2d"
signature: [
'Tensor (Tensor x, Double height_scale=0.0, Double width_scale=0.0, Int64List[2] output_size=None,
String data_format="channels_first") => UpsampleNearest2D',
'Tensor (Tensor x, Tensor like, String data_format="channels_first") => UpsampleNearest2D'
]
signature:
'Tensor (Tensor x, Double height_scale=0.0, Double width_scale=0.0, Int64List[2] output_size=None,
String data_format="channels_first") => UpsampleNearest2D'
bind_python: True

- name: "upsample_nearest_2d_grad"
Expand Down
21 changes: 1 addition & 20 deletions oneflow/core/functional/impl/array_functor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1991,24 +1991,6 @@ class UpsampleNearest2DFunctor {
std::shared_ptr<OpExpr> op_;
};

class UpsampleNearestLike2DFunctor {
public:
UpsampleNearestLike2DFunctor() {
op_ = CHECK_JUST(
one::OpBuilder("upsample_nearest_2d").Input("x").Input("like").Output("y").Build());
}
Maybe<Tensor> operator()(const std::shared_ptr<one::Tensor>& x,
const std::shared_ptr<one::Tensor>& like,
const std::string& data_format) const {
auto& attrs = THREAD_CACHED_MUTABLE_ATTR_MAP("data_format");
attrs.SetAllAttrs(data_format);
return OpInterpUtil::Dispatch<Tensor>(*op_, {x, like}, attrs);
}

private:
std::shared_ptr<OpExpr> op_;
};

class UpsampleNearest2DGradFunctor {
public:
UpsampleNearest2DGradFunctor() {
Expand Down Expand Up @@ -4136,8 +4118,7 @@ ONEFLOW_FUNCTION_LIBRARY(m) {
m.add_functor<impl::UnfoldTensorFunctor>("UnfoldTensor");
m.add_functor<impl::UnfoldTensorGradFunctor>("UnfoldTensorGrad");
m.add_functor<impl::UpsampleGradFunctor>("UpsampleGrad");
m.add_functor<impl::UpsampleNearest2DFunctor, impl::UpsampleNearestLike2DFunctor>(
"UpsampleNearest2D");
m.add_functor<impl::UpsampleNearest2DFunctor>("UpsampleNearest2D");
m.add_functor<impl::UpsampleNearest2DGradFunctor>("UpsampleNearest2DGrad");
m.add_functor<impl::UpsampleBilinear2DFunctor>("UpsampleBilinear2D");
m.add_functor<impl::UpsampleBilinear2DGradFunctor>("UpsampleBilinear2DGrad");
Expand Down
2 changes: 1 addition & 1 deletion oneflow/user/kernels/upsample_nearest_kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class UpsampleNearest2DCPUKernel final : public user_op::OpKernel {
const int64_t out_height = y_tensor->shape_view().At(2);
const int64_t out_width = y_tensor->shape_view().At(3);
const int64_t elem_cnt = y_tensor->shape_view().elem_cnt();
if (!output_size.empty() || ctx->Tensor4ArgNameAndIndex("like", 0)) {
if (!output_size.empty()) {
height_scale = static_cast<double>(out_height) / static_cast<double>(in_height);
width_scale = static_cast<double>(out_width) / static_cast<double>(in_width);
}
Expand Down
12 changes: 0 additions & 12 deletions oneflow/user/ops/upsample_op.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,6 @@ typename std::enable_if<(N <= 3), Maybe<void>>::type UpsamplingInferLogicalDesc(
user_op::InferContext* ctx, const std::string& func_name) {
const user_op::TensorDesc& x_desc = ctx->InputTensorDesc("x", 0);
user_op::TensorDesc* y_desc = ctx->MutOutputTensorDesc("y", 0);
if (ctx->has_input("like", 0)) {
const user_op::TensorDesc& like_desc = ctx->InputTensorDesc("like", 0);
int64_t like_num_axes = like_desc.shape().NumAxes();
CHECK_GT_OR_RETURN(like_num_axes, N)
<< "like shape size should > " << N << ", but got " << like_desc.shape().ToString();
Shape output_shape = x_desc.shape();
for (int i = 0; i < N; ++i) {
output_shape[i + 2] = like_desc.shape().At(like_num_axes - N + i);
}
y_desc->set_shape(output_shape);
return Maybe<void>::Ok();
}
if (N == 1) {
CHECK_OR_RETURN(ctx->Attr<std::string>("data_format") == "channels_first"
&& x_desc.shape().NumAxes() == (N + 2))
Expand Down
1 change: 0 additions & 1 deletion python/oneflow/nn/functional/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
limitations under the License.
"""
from oneflow.nn.modules.interpolate import interpolate
from oneflow.nn.modules.interpolate_like import interpolate_like
from oneflow.nn.modules.affine_grid import affine_grid
from oneflow.nn.modules.grid_sample import grid_sample
from oneflow.nn.modules.sparse_softmax_cross_entropy import sparse_softmax_cross_entropy
Expand Down
156 changes: 0 additions & 156 deletions python/oneflow/nn/modules/interpolate_like.py

This file was deleted.

77 changes: 0 additions & 77 deletions python/oneflow/test/modules/test_upsample_like.py

This file was deleted.

Loading