resize_bilinear.cc 1.7 KB
Newer Older
L
Liangliang He 已提交
1
// Copyright 2018 Xiaomi, Inc.  All rights reserved.
2
//
L
Liangliang He 已提交
3 4 5
// 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
6
//
L
Liangliang He 已提交
7 8 9 10 11 12 13
//     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.
14

15
#include "mace/kernels/resize_bilinear.h"
16
#include "mace/kernels/opencl/image/resize_bilinear.h"
17 18 19 20

namespace mace {
namespace kernels {

21 22 23 24 25 26 27 28 29 30
template <typename T>
ResizeBilinearFunctor<DeviceType::GPU, T>::ResizeBilinearFunctor(
    OpKernelContext *context,
    const std::vector<index_t> &size,
    bool align_corners) : OpKernel(context) {
  MACE_CHECK(size.size() == 2);
  if (context->device()->opencl_runtime()->UseImageMemory()) {
    kernel_.reset(new opencl::image::ResizeBilinearKernel<T>(align_corners,
                                                             size[0],
                                                             size[1]));
31
  } else {
32
    MACE_NOT_IMPLEMENTED;
33 34
  }
}
35
template <typename T>
李寅 已提交
36
MaceStatus ResizeBilinearFunctor<DeviceType::GPU, T>::operator()(
37
    const Tensor *input, Tensor *output, StatsFuture *future) {
38
  return kernel_->Compute(context_, input, output, future);
39
}
40

41 42
template struct ResizeBilinearFunctor<DeviceType::GPU, float>;
template struct ResizeBilinearFunctor<DeviceType::GPU, half>;
43

44 45
}  // namespace kernels
}  // namespace mace