Skip to content

Commit

Permalink
Extract kSpatialLayouts
Browse files Browse the repository at this point in the history
Signed-off-by: Joaquin Anton <janton@nvidia.com>
  • Loading branch information
jantonguirao committed Mar 7, 2022
1 parent d2c62c5 commit 73bafce
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 6 deletions.
5 changes: 3 additions & 2 deletions dali/operators/generic/flip.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2019-2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// Copyright (c) 2019-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -17,6 +17,7 @@
#include "dali/kernels/imgproc/flip_cpu.h"
#include "dali/kernels/kernel_params.h"
#include "dali/pipeline/data/views.h"
#include "dali/pipeline/data/layouts.h"
#include "dali/util/ocv.h"
#include "dali/operators/generic/flip_util.h"

Expand All @@ -30,7 +31,7 @@ and depthwise).)code")
.AddOptionalArg("horizontal", R"code(Flip the horizontal dimension.)code", 1, true)
.AddOptionalArg("vertical", R"code(Flip the vertical dimension.)code", 0, true)
.AddOptionalArg("depthwise", R"code(Flip the depthwise dimension.)code", 0, true)
.InputLayout({"FDHWC", "FHWC", "DHWC", "HWC", "FCDHW", "FCHW", "CDHW", "CHW"})
.InputLayout(0, kSpatialLayouts)
.AllowSequences()
.SupportVolumetric();

Expand Down
4 changes: 3 additions & 1 deletion dali/operators/image/crop/crop.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
// Copyright (c) 2019-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -18,6 +18,7 @@
#include "dali/core/static_switch.h"
#include "dali/kernels/slice/slice_cpu.h"
#include "dali/pipeline/data/views.h"
#include "dali/pipeline/data/layouts.h"
#include "dali/util/half.hpp"

namespace dali {
Expand All @@ -27,6 +28,7 @@ DALI_SCHEMA(Crop)
(upper left corner).)code")
.NumInput(1)
.NumOutput(1)
.InputLayout(0, kSpatialLayouts)
.AllowSequences()
.SupportVolumetric()
.AddOptionalArg<DALIImageType>("image_type", "Image type", nullptr)
Expand Down
2 changes: 2 additions & 0 deletions dali/operators/image/crop/crop_mirror_normalize.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "dali/core/tensor_layout.h"
#include "dali/kernels/slice/slice_flip_normalize_permute_pad_cpu.h"
#include "dali/pipeline/data/views.h"
#include "dali/pipeline/data/layouts.h"
#include "dali/util/half.hpp"

namespace dali {
Expand All @@ -34,6 +35,7 @@ Normalization takes the input images and produces the output by using the follow
)code")
.NumInput(1)
.NumOutput(1)
.InputLayout(0, kSpatialLayouts)
.AllowSequences()
.SupportVolumetric()
.AddOptionalArg<DALIImageType>("image_type", "Image type", nullptr)
Expand Down
6 changes: 3 additions & 3 deletions dali/operators/image/resize/resize.cc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2017-2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
// Copyright (c) 2017-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand All @@ -15,6 +15,7 @@
#include "dali/operators/image/resize/resize.h"
#include <cassert>
#include "dali/pipeline/data/views.h"
#include "dali/pipeline/data/layouts.h"

namespace dali {

Expand All @@ -25,8 +26,7 @@ DALI_SCHEMA(Resize)
.AdditionalOutputsFn([](const OpSpec& spec) {
return static_cast<int>(spec.GetArgument<bool>("save_attrs"));
})
.InputLayout(0, {"HWC", "FHWC", "CHW", "FCHW", "CFHW" ,
"DHWC", "FDHWC", "CDHW", "FCDHW", "CFDHW" })
.InputLayout(0, kSpatialLayouts)
.AddOptionalArg("save_attrs",
R"code(Save reshape attributes for testing.)code", false)
.AddOptionalArg<DALIImageType>("image_type", "Image type", nullptr)
Expand Down
30 changes: 30 additions & 0 deletions dali/pipeline/data/layouts.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef DALI_PIPELINE_DATA_LAYOUTS_H_
#define DALI_PIPELINE_DATA_LAYOUTS_H_

#include "dali/core/tensor_layout.h"

namespace dali {

// Layouts containing spatial dimensions such as height, width, depth
// Contains Image, Volumetric Images, and Sequence layouts
static std::initializer_list<TensorLayout> kSpatialLayouts {
"HWC", "CHW", "DHWC", "FHWC", "FCHW", "CDHW", "CFHW", "FDHWC", "FCDHW", "CFDHW"
};

} // namespace dali

#endif // DALI_PIPELINE_DATA_LAYOUTS_H_

0 comments on commit 73bafce

Please sign in to comment.