Skip to content

MIOpen: Honor Max Dim #222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Sep 26, 2018
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
6 changes: 5 additions & 1 deletion aten/src/ATen/native/Convolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

#include "ATen/Config.h"

static const int MIOPEN_DIM_MAX = 4;
static const bool MIOPEN_ENABLED = getenv("DISABLE_MIOPEN") != NULL;

namespace at { namespace native {

struct ConvParams {
Expand Down Expand Up @@ -123,7 +126,8 @@ auto ConvParams::use_miopen(const at::Tensor& input) const -> bool {
return ((input.type().scalarType() == at::kFloat) || (input.type().scalarType() == at::kHalf))
&& detail::getCUDAHooks().compiledWithMIOpen()
&& input.type().is_cuda()
&& cudnn_enabled
&& input.dim() > MIOPEN_DIM_MAX
&& MIOPEN_ENABLED
;
}

Expand Down
9 changes: 7 additions & 2 deletions aten/src/ATen/native/Normalization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@

#include <vector>

static const int MIOPEN_DIM_MAX = 4;
static const bool MIOPEN_ENABLED = getenv("DISABLE_MIOPEN") != NULL;

namespace at { namespace native {

namespace {
Expand Down Expand Up @@ -67,12 +70,14 @@ Tensor batch_norm(
}

bool use_miopen = (input.type().is_cuda()
&& (input.type().scalarType() != at::kHalf
|| weight.type().scalarType() == at::kFloat)
&& input.dim() < MIOPEN_DIM_MAX
&& input.type().scalarType() != at::kDouble
&& (input.type().scalarType() == weight.type().scalarType())
&& weight.defined() && bias.defined()
&& ((running_mean.defined() && running_var.defined())
|| (!running_mean.defined() && !running_var.defined() && training))
&& detail::getCUDAHooks().compiledWithMIOpen()
&& MIOPEN_ENABLED
);

if (use_miopen) {
Expand Down
4 changes: 1 addition & 3 deletions aten/src/ATen/native/miopen/BatchNorm_miopen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ std::tuple<Tensor, Tensor, Tensor> miopen_batch_norm(
checkAllDefined(c, {running_mean, running_var});
}
checkAllSameGPU(c, {input, weight, bias, running_mean, running_var});
if (input->type().scalarType() == ScalarType::Half) {
checkScalarType(c, weight, ScalarType::Float);
} else {
if (input->type().scalarType() != ScalarType::Half) {
checkAllSameType(c, {input, weight});
}
checkAllSameType(c, {weight, bias, running_mean, running_var});
Expand Down