forked from mindspore-Ecosystem/mindspore
!20685 Gpu operators DTS tickets fix
Merge pull request !20685 from Peilin/gpu-mem-ticket-fix
This commit is contained in:
commit
14b290f760
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -37,6 +37,8 @@ class ArgmaxGpuKernel : public GpuKernel {
|
||||||
const std::vector<AddressPtr> &outputs, void *stream_ptr) override {
|
const std::vector<AddressPtr> &outputs, void *stream_ptr) override {
|
||||||
T *input = GetDeviceAddress<T>(inputs, 0);
|
T *input = GetDeviceAddress<T>(inputs, 0);
|
||||||
S *output = GetDeviceAddress<S>(outputs, 0);
|
S *output = GetDeviceAddress<S>(outputs, 0);
|
||||||
|
MS_EXCEPTION_IF_NULL(input);
|
||||||
|
MS_EXCEPTION_IF_NULL(output);
|
||||||
CalArgmax(input, bound_, outer_size_, inner_size_, output, reinterpret_cast<cudaStream_t>(stream_ptr));
|
CalArgmax(input, bound_, outer_size_, inner_size_, output, reinterpret_cast<cudaStream_t>(stream_ptr));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -46,6 +48,10 @@ class ArgmaxGpuKernel : public GpuKernel {
|
||||||
auto output_shape = AnfAlgo::GetOutputInferShape(kernel_node, 0);
|
auto output_shape = AnfAlgo::GetOutputInferShape(kernel_node, 0);
|
||||||
int64_t dims = shape.size();
|
int64_t dims = shape.size();
|
||||||
int64_t axis = GetAttr<int64_t>(kernel_node, "axis");
|
int64_t axis = GetAttr<int64_t>(kernel_node, "axis");
|
||||||
|
if (axis < -dims || axis >= dims) {
|
||||||
|
MS_LOG(EXCEPTION) << "axis must be in the range [-rank, rank)";
|
||||||
|
}
|
||||||
|
|
||||||
if (axis < 0) {
|
if (axis < 0) {
|
||||||
axis += dims;
|
axis += dims;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -52,6 +52,10 @@ class BroadcastToGpuKernel : public GpuKernel {
|
||||||
MS_LOG(EXCEPTION) << "BroadcastTo operation not support dim greater than " << SHAPE_SIZE;
|
MS_LOG(EXCEPTION) << "BroadcastTo operation not support dim greater than " << SHAPE_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (output_shapes.size() < input_shapes.size()) {
|
||||||
|
MS_LOG(EXCEPTION) << "The rank of BroadcastTo's output cannot be smaller than the rank of the input.";
|
||||||
|
}
|
||||||
|
|
||||||
size_t offset = output_shapes.size() - input_shapes.size();
|
size_t offset = output_shapes.size() - input_shapes.size();
|
||||||
for (size_t i = 0; i < input_shapes.size(); i++) {
|
for (size_t i = 0; i < input_shapes.size(); i++) {
|
||||||
input_shape_[i + offset] = input_shapes[i];
|
input_shape_[i + offset] = input_shapes[i];
|
||||||
|
|
|
@ -53,6 +53,9 @@ class GatherV2GpuFwdKernel : public GpuKernel {
|
||||||
Reshape();
|
Reshape();
|
||||||
}
|
}
|
||||||
auto input_dim1 = input_shapes_[IntToSize(axis_)];
|
auto input_dim1 = input_shapes_[IntToSize(axis_)];
|
||||||
|
|
||||||
|
MS_EXCEPTION_IF_NULL(input_addr);
|
||||||
|
MS_EXCEPTION_IF_NULL(indices_addr);
|
||||||
GatherV2(input_addr, indices_addr, output_addr, dims_[0], dims_[1], dims_[2], input_dim1,
|
GatherV2(input_addr, indices_addr, output_addr, dims_[0], dims_[1], dims_[2], input_dim1,
|
||||||
reinterpret_cast<cudaStream_t>(stream_ptr));
|
reinterpret_cast<cudaStream_t>(stream_ptr));
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -37,6 +37,7 @@ class OnesLikeGpuKernel : public GpuKernel {
|
||||||
T *input = GetDeviceAddress<T>(inputs, 0);
|
T *input = GetDeviceAddress<T>(inputs, 0);
|
||||||
T *output = GetDeviceAddress<T>(outputs, 0);
|
T *output = GetDeviceAddress<T>(outputs, 0);
|
||||||
int size = SizeToInt(input_size_ / sizeof(T));
|
int size = SizeToInt(input_size_ / sizeof(T));
|
||||||
|
MS_EXCEPTION_IF_NULL(output);
|
||||||
CalOnesLike(size, input, output, reinterpret_cast<cudaStream_t>(stream_ptr));
|
CalOnesLike(size, input, output, reinterpret_cast<cudaStream_t>(stream_ptr));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -73,6 +73,12 @@ class DetTriangleGpuKernel : public GpuKernel {
|
||||||
for (size_t i = 0; i < input_shape.size(); i++) {
|
for (size_t i = 0; i < input_shape.size(); i++) {
|
||||||
input_size_ *= input_shape[i];
|
input_size_ *= input_shape[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (input_shape.size() < 2) {
|
||||||
|
MS_LOG(ERROR) << "The input should have rank at least 2.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
matrix_n_ = input_shape[input_shape.size() - 1];
|
matrix_n_ = input_shape[input_shape.size() - 1];
|
||||||
auto output_shape = AnfAlgo::GetOutputInferShape(kernel_node, 0);
|
auto output_shape = AnfAlgo::GetOutputInferShape(kernel_node, 0);
|
||||||
for (size_t i = 0; i < output_shape.size(); i++) {
|
for (size_t i = 0; i < output_shape.size(); i++) {
|
||||||
|
|
|
@ -79,6 +79,12 @@ class AdaptiveAvgPool2DKernel : public GpuKernel {
|
||||||
|
|
||||||
auto input_shape = AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, 0);
|
auto input_shape = AnfAlgo::GetPrevNodeOutputInferShape(kernel_node, 0);
|
||||||
len = static_cast<uint>(input_shape.size());
|
len = static_cast<uint>(input_shape.size());
|
||||||
|
|
||||||
|
if (len < 2) {
|
||||||
|
MS_LOG(ERROR) << "The input should have rank at least 2.";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
input_height = static_cast<uint>(input_shape[len - 2]);
|
input_height = static_cast<uint>(input_shape[len - 2]);
|
||||||
input_width = static_cast<uint>(input_shape[len - 1]);
|
input_width = static_cast<uint>(input_shape[len - 1]);
|
||||||
size = static_cast<uint>(len == 3 ? input_shape[0] : input_shape[0] * input_shape[1]);
|
size = static_cast<uint>(len == 3 ? input_shape[0] : input_shape[0] * input_shape[1]);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
* Copyright 2019 Huawei Technologies Co., Ltd
|
* Copyright 2019-2021 Huawei Technologies Co., Ltd
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -113,6 +113,10 @@ class Conv2dGpuFwdKernel : public GpuKernel {
|
||||||
std::vector<int64_t> pad_list_me = GetAttr<std::vector<int64_t>>(kernel_node, "pad_list");
|
std::vector<int64_t> pad_list_me = GetAttr<std::vector<int64_t>>(kernel_node, "pad_list");
|
||||||
(void)std::transform(pad_list_me.begin(), pad_list_me.end(), std::back_inserter(pad_list),
|
(void)std::transform(pad_list_me.begin(), pad_list_me.end(), std::back_inserter(pad_list),
|
||||||
[](const int64_t &value) { return static_cast<int>(value); });
|
[](const int64_t &value) { return static_cast<int>(value); });
|
||||||
|
if (pad_list.size() != 4) {
|
||||||
|
MS_LOG(EXCEPTION) << "Conv2dGpuFwdKernel pad_list must have length 4.";
|
||||||
|
}
|
||||||
|
|
||||||
pad_height_ = pad_list[0];
|
pad_height_ = pad_list[0];
|
||||||
pad_width_ = pad_list[2];
|
pad_width_ = pad_list[2];
|
||||||
use_pad_ = !((pad_height_ == pad_list[1]) && (pad_width_ == pad_list[3]));
|
use_pad_ = !((pad_height_ == pad_list[1]) && (pad_width_ == pad_list[3]));
|
||||||
|
|
|
@ -90,6 +90,9 @@ class Conv3dGpuKernel : public GpuKernel {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
CheckTensorSize({in_shape});
|
CheckTensorSize({in_shape});
|
||||||
|
if (in_shape.size() != 5) {
|
||||||
|
MS_LOG(EXCEPTION) << "Conv3dGpuKernel input must have rank 5.";
|
||||||
|
}
|
||||||
n_ = SizeToInt(in_shape[0]);
|
n_ = SizeToInt(in_shape[0]);
|
||||||
c_ = SizeToInt(in_shape[1]);
|
c_ = SizeToInt(in_shape[1]);
|
||||||
old_depth_ = SizeToInt(in_shape[2]);
|
old_depth_ = SizeToInt(in_shape[2]);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
* Copyright 2020 Huawei Technologies Co., Ltd
|
* Copyright 2020-2021 Huawei Technologies Co., Ltd
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -123,6 +123,10 @@ class MaxPoolWithArgmaxGpuFwdKernel : public GpuKernel {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetPad() {
|
void SetPad() {
|
||||||
|
if (stride_height_ == 0) {
|
||||||
|
MS_LOG(EXCEPTION) << "stride height cannot be 0.";
|
||||||
|
}
|
||||||
|
|
||||||
pad_height_ = std::max<int>(
|
pad_height_ = std::max<int>(
|
||||||
0, (((input_height_ / stride_height_) * stride_height_ == input_height_ ? (input_height_ / stride_height_)
|
0, (((input_height_ / stride_height_) * stride_height_ == input_height_ ? (input_height_ / stride_height_)
|
||||||
: (input_height_ / stride_height_) + 1) -
|
: (input_height_ / stride_height_) + 1) -
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/**
|
/**
|
||||||
* Copyright 2019 Huawei Technologies Co., Ltd
|
* Copyright 2019-2021 Huawei Technologies Co., Ltd
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
@ -171,6 +171,10 @@ class SoftmaxCrossEntropyWithLogitsGpuKernel : public GpuKernel {
|
||||||
void CheckShapeValidation(const std::vector<size_t> &logits_shape, const std::vector<size_t> &labels_shape) {
|
void CheckShapeValidation(const std::vector<size_t> &logits_shape, const std::vector<size_t> &labels_shape) {
|
||||||
size_t logits_dim_length = logits_shape.size();
|
size_t logits_dim_length = logits_shape.size();
|
||||||
size_t labels_dim_length = labels_shape.size();
|
size_t labels_dim_length = labels_shape.size();
|
||||||
|
if (logits_dim_length == 0) {
|
||||||
|
MS_LOG(EXCEPTION) << "Logits shape cannot be empty";
|
||||||
|
}
|
||||||
|
|
||||||
if (labels_dim_length != logits_dim_length) {
|
if (labels_dim_length != logits_dim_length) {
|
||||||
MS_LOG(EXCEPTION) << "Labels shape length should be equal to Logits shape length for "
|
MS_LOG(EXCEPTION) << "Labels shape length should be equal to Logits shape length for "
|
||||||
"SoftmaxCrossEntropyWithLogits, but got Labels "
|
"SoftmaxCrossEntropyWithLogits, but got Labels "
|
||||||
|
@ -178,7 +182,7 @@ class SoftmaxCrossEntropyWithLogitsGpuKernel : public GpuKernel {
|
||||||
<< labels_dim_length << ", Logits shape length:" << logits_dim_length;
|
<< labels_dim_length << ", Logits shape length:" << logits_dim_length;
|
||||||
}
|
}
|
||||||
if (!std::equal(labels_shape.begin(), labels_shape.end(), logits_shape.begin())) {
|
if (!std::equal(labels_shape.begin(), labels_shape.end(), logits_shape.begin())) {
|
||||||
MS_LOG(EXCEPTION) << "The shape of labels should be the same as the shape of logits except its last demension.";
|
MS_LOG(EXCEPTION) << "The shape of labels should be the same as the shape of logits except its last dimension.";
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue