Unverified Commit 7d831a2f authored by Vasilis Vryniotis's avatar Vasilis Vryniotis Committed by GitHub
Browse files

Restructuring C++ project: (#3146)

Summary:
* Reduce unnecessary header inclusions in models and io.

* Move autocast to separate folder and hide autograd implementation in an anonymous namespace.

* Moving files in subfolders.

Reviewed By: fmassa

Differential Revision: D25461523

fbshipit-source-id: 756eeb6848aacaa474de4825ed4c1045d17e2cea
parent 4d3a3093
#include "googlenet.h"
#include "modelsimpl.h"
namespace vision {
namespace models {
......
#pragma once
#include <torch/torch.h>
#include <torch/nn.h>
#include "../macros.h"
namespace vision {
......
#pragma once
#include <torch/torch.h>
#include <torch/nn.h>
#include "../macros.h"
namespace vision {
......
#pragma once
#include <torch/torch.h>
#include <torch/nn.h>
#include "../macros.h"
namespace vision {
......
#pragma once
#include <torch/torch.h>
#include <torch/nn.h>
#include "../macros.h"
namespace vision {
......
#pragma once
#include <torch/torch.h>
#ifndef TORCH_CHECK
#define TORCH_CHECK AT_CHECK
#endif
#include <torch/nn.h>
namespace vision {
namespace models {
......
#include "resnet.h"
#include "modelsimpl.h"
namespace vision {
namespace models {
namespace _resnetimpl {
......
#pragma once
#include <torch/torch.h>
#include <torch/nn.h>
#include "../macros.h"
namespace vision {
......
#pragma once
#include <torch/torch.h>
#include <torch/nn.h>
#include "../macros.h"
namespace vision {
......
#pragma once
#include <torch/torch.h>
#include <torch/nn.h>
#include "../macros.h"
namespace vision {
......
#pragma once
#include <torch/torch.h>
#include <torch/nn.h>
#include "../macros.h"
namespace vision {
......
#include "../deform_conv2d.h"
#include <ATen/autocast_mode.h>
#include <torch/types.h>
namespace vision {
namespace ops {
namespace {
at::Tensor deform_conv2d_autocast(
const at::Tensor& input,
const at::Tensor& weight,
const at::Tensor& offset,
const at::Tensor& mask,
const at::Tensor& bias,
int64_t stride_h,
int64_t stride_w,
int64_t pad_h,
int64_t pad_w,
int64_t dilation_h,
int64_t dilation_w,
int64_t groups,
int64_t offset_groups,
bool use_mask) {
c10::impl::ExcludeDispatchKeyGuard no_autocast(c10::DispatchKey::Autocast);
return deform_conv2d(
at::autocast::cached_cast(at::kFloat, input),
at::autocast::cached_cast(at::kFloat, weight),
at::autocast::cached_cast(at::kFloat, offset),
at::autocast::cached_cast(at::kFloat, mask),
at::autocast::cached_cast(at::kFloat, bias),
stride_h,
stride_w,
pad_h,
pad_w,
dilation_h,
dilation_w,
groups,
offset_groups,
use_mask)
.to(input.scalar_type());
}
} // namespace
TORCH_LIBRARY_IMPL(torchvision, Autocast, m) {
m.impl("deform_conv2d", deform_conv2d_autocast);
}
} // namespace ops
} // namespace vision
#include "../nms.h"
#include <ATen/autocast_mode.h>
#include <torch/types.h>
namespace vision {
namespace ops {
namespace {
at::Tensor nms_autocast(
const at::Tensor& dets,
const at::Tensor& scores,
double iou_threshold) {
c10::impl::ExcludeDispatchKeyGuard no_autocast(c10::DispatchKey::Autocast);
return nms(
at::autocast::cached_cast(at::kFloat, dets),
at::autocast::cached_cast(at::kFloat, scores),
iou_threshold);
}
} // namespace
TORCH_LIBRARY_IMPL(torchvision, Autocast, m) {
m.impl("nms", nms_autocast);
}
} // namespace ops
} // namespace vision
#include "../ps_roi_align.h"
#include <ATen/autocast_mode.h>
#include <torch/types.h>
namespace vision {
namespace ops {
namespace {
std::tuple<at::Tensor, at::Tensor> ps_roi_align_autocast(
const at::Tensor& input,
const at::Tensor& rois,
double spatial_scale,
int64_t pooled_height,
int64_t pooled_width,
int64_t sampling_ratio) {
c10::impl::ExcludeDispatchKeyGuard no_autocast(c10::DispatchKey::Autocast);
auto result = ps_roi_align(
at::autocast::cached_cast(at::kFloat, input),
at::autocast::cached_cast(at::kFloat, rois),
spatial_scale,
pooled_height,
pooled_width,
sampling_ratio);
return std::make_tuple(
std::get<0>(result).to(input.scalar_type()),
std::get<1>(result).to(input.scalar_type()));
}
} // namespace
TORCH_LIBRARY_IMPL(torchvision, Autocast, m) {
m.impl("ps_roi_align", ps_roi_align_autocast);
}
} // namespace ops
} // namespace vision
#include "../ps_roi_pool.h"
#include <ATen/autocast_mode.h>
#include <torch/types.h>
namespace vision {
namespace ops {
namespace {
std::tuple<at::Tensor, at::Tensor> ps_roi_pool_autocast(
const at::Tensor& input,
const at::Tensor& rois,
double spatial_scale,
int64_t pooled_height,
int64_t pooled_width) {
c10::impl::ExcludeDispatchKeyGuard no_autocast(c10::DispatchKey::Autocast);
auto result = ps_roi_pool(
at::autocast::cached_cast(at::kFloat, input),
at::autocast::cached_cast(at::kFloat, rois),
spatial_scale,
pooled_height,
pooled_width);
return std::make_tuple(
std::get<0>(result).to(input.scalar_type()),
std::get<1>(result).to(input.scalar_type()));
}
} // namespace
TORCH_LIBRARY_IMPL(torchvision, Autocast, m) {
m.impl("ps_roi_pool", ps_roi_pool_autocast);
}
} // namespace ops
} // namespace vision
#include "../roi_align.h"
#include <ATen/autocast_mode.h>
#include <torch/types.h>
namespace vision {
namespace ops {
namespace {
at::Tensor roi_align_autocast(
const at::Tensor& input,
const at::Tensor& rois,
double spatial_scale,
int64_t pooled_height,
int64_t pooled_width,
int64_t sampling_ratio,
bool aligned) {
c10::impl::ExcludeDispatchKeyGuard no_autocast(c10::DispatchKey::Autocast);
return roi_align(
at::autocast::cached_cast(at::kFloat, input),
at::autocast::cached_cast(at::kFloat, rois),
spatial_scale,
pooled_height,
pooled_width,
sampling_ratio,
aligned)
.to(input.scalar_type());
}
} // namespace
TORCH_LIBRARY_IMPL(torchvision, Autocast, m) {
m.impl("roi_align", roi_align_autocast);
}
} // namespace ops
} // namespace vision
#include "../roi_pool.h"
#include <ATen/autocast_mode.h>
#include <torch/types.h>
namespace vision {
namespace ops {
namespace {
std::tuple<at::Tensor, at::Tensor> roi_pool_autocast(
const at::Tensor& input,
const at::Tensor& rois,
double spatial_scale,
int64_t pooled_height,
int64_t pooled_width) {
c10::impl::ExcludeDispatchKeyGuard no_autocast(c10::DispatchKey::Autocast);
auto result = roi_pool(
at::autocast::cached_cast(at::kFloat, input),
at::autocast::cached_cast(at::kFloat, rois),
spatial_scale,
pooled_height,
pooled_width);
return std::make_tuple(
std::get<0>(result).to(input.scalar_type()),
std::get<1>(result).to(input.scalar_type()));
}
} // namespace
TORCH_LIBRARY_IMPL(torchvision, Autocast, m) {
m.impl("roi_pool", roi_pool_autocast);
}
} // namespace ops
} // namespace vision
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment