Compute Library
 19.08
CLPixelWiseMultiplication.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2019 ARM Limited.
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
25 
29 
30 #include <utility>
31 
32 namespace arm_compute
33 {
36 {
37  auto k = arm_compute::support::cpp14::make_unique<CLPixelWiseMultiplicationKernel>();
38  k->configure(input1, input2, output, scale, overflow_policy, rounding_policy);
39  _kernel = std::move(k);
40 
41  if(output->info()->dimension(0) > 1)
42  {
43  ICLTensor *broadcasted_info = (input1->info()->dimension(0) == 1) ? input1 : input2;
44 
45  if(broadcasted_info->info()->dimension(0) == 1)
46  {
47  _border_handler.configure(broadcasted_info, _kernel->border_size(), BorderMode::REPLICATE);
48  }
49  }
50 }
51 
52 Status CLPixelWiseMultiplication::validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, float scale,
54 {
55  return CLPixelWiseMultiplicationKernel::validate(input1, input2, output, scale, overflow_policy, rounding_policy);
56 }
57 
59 {
60  auto k = arm_compute::support::cpp14::make_unique<CLComplexPixelWiseMultiplicationKernel>();
61  k->configure(input1, input2, output);
62  _kernel = std::move(k);
63 
64  if(output->info()->dimension(0) > 1)
65  {
66  ICLTensor *broadcasted_info = (input1->info()->dimension(0) == 1) ? input1 : input2;
67 
68  if(broadcasted_info->info()->dimension(0) == 1)
69  {
70  _border_handler.configure(broadcasted_info, _kernel->border_size(), BorderMode::REPLICATE);
71  }
72  }
73 }
74 
76 {
77  return CLComplexPixelWiseMultiplicationKernel::validate(input1, input2, output);
78 }
79 } // namespace arm_compute
static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output)
Static function to check if given info will lead to a valid configuration of CLComplexPixelWiseMultip...
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output)
Static function to check if given info will lead to a valid configuration of CLComplexPixelWiseMultip...
Store the tensor's metadata.
Definition: ITensorInfo.h:40
Status class.
Definition: Error.h:52
Copyright (c) 2017-2018 ARM Limited.
static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy)
Static function to check if given info will lead to a valid configuration of CLPixelWiseMultiplicatio...
RoundingPolicy
Rounding method.
Definition: Rounding.h:30
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy)
Initialise the kernel's inputs, output and convertion policy.
void configure(ICLTensor *input1, ICLTensor *input2, ICLTensor *output)
Initialise the kernel's inputs, output.
Interface for OpenCL tensor.
Definition: ICLTensor.h:42
Pixels outside the image are assumed to have the same value as the closest image pixel.
static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, float scale, ConvertPolicy overflow_policy, RoundingPolicy rounding_policy)
Static function to check if given info will lead to a valid configuration of CLPixelWiseMultiplicatio...
ConvertPolicy
Policy to handle overflow.
Definition: Types.h:349