mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 13:44:15 +08:00
Check function declarations of Vulkan code (#134550)
Fixes #ISSUE_NUMBER Pull Request resolved: https://github.com/pytorch/pytorch/pull/134550 Approved by: https://github.com/ezyang
This commit is contained in:
@ -230,7 +230,7 @@ void swap(ComputePipeline& lhs, ComputePipeline& rhs) noexcept {
|
||||
rhs.handle_ = tmp_handle;
|
||||
}
|
||||
|
||||
bool operator==(
|
||||
static bool operator==(
|
||||
const ComputePipeline::Descriptor& _1,
|
||||
const ComputePipeline::Descriptor& _2) {
|
||||
return (
|
||||
|
@ -170,13 +170,7 @@ void QueryPool::extract_results() {
|
||||
results_pending_ = false;
|
||||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& os, const VkExtent3D& extents) {
|
||||
os << "{" << extents.width << ", " << extents.height << ", " << extents.depth
|
||||
<< "}";
|
||||
return os;
|
||||
}
|
||||
|
||||
std::string stringize(const VkExtent3D& extents) {
|
||||
static std::string stringize(const VkExtent3D& extents) {
|
||||
std::stringstream ss;
|
||||
ss << "{" << extents.width << ", " << extents.height << ", " << extents.depth
|
||||
<< "}";
|
||||
|
@ -253,7 +253,7 @@ BufferMemoryBarrier::BufferMemoryBarrier(
|
||||
// ImageSampler
|
||||
//
|
||||
|
||||
bool operator==(
|
||||
static bool operator==(
|
||||
const ImageSampler::Properties& _1,
|
||||
const ImageSampler::Properties& _2) {
|
||||
return (
|
||||
|
@ -460,7 +460,7 @@ void vTensor::virtual_resize(const std::vector<int64_t>& new_sizes) {
|
||||
// vTensorStorage
|
||||
//
|
||||
|
||||
api::VulkanImage allocate_image(
|
||||
static api::VulkanImage allocate_image(
|
||||
api::Context* const context_ptr,
|
||||
api::utils::uvec3& extents,
|
||||
const api::StorageType storage_type,
|
||||
@ -505,7 +505,7 @@ api::VulkanImage allocate_image(
|
||||
/*allocate_memory = */ allocate_memory);
|
||||
}
|
||||
|
||||
api::VulkanBuffer allocate_buffer(
|
||||
static api::VulkanBuffer allocate_buffer(
|
||||
api::Context* const context_ptr,
|
||||
const int64_t numel,
|
||||
const api::StorageType storage_type,
|
||||
|
@ -296,7 +296,7 @@ bool record_buffer_to_nchw_op(
|
||||
v_src.buffer_metadata());
|
||||
}
|
||||
|
||||
vTensor channel_image_repacking(
|
||||
static vTensor channel_image_repacking(
|
||||
const vTensor& v_input,
|
||||
api::GPUMemoryLayout target_layout,
|
||||
const api::ShaderInfo& shader_descriptor) {
|
||||
|
@ -15,7 +15,7 @@ struct Params final {
|
||||
float eps;
|
||||
};
|
||||
|
||||
void record_op(
|
||||
static void record_op(
|
||||
api::Context* const context,
|
||||
vTensor& v_output,
|
||||
const vTensor& v_input,
|
||||
|
@ -1,9 +1,9 @@
|
||||
#ifdef USE_VULKAN_API
|
||||
#include <ATen/ArrayRef.h>
|
||||
#include <ATen/native/vulkan/ops/Common.h>
|
||||
#include <ATen/native/vulkan/ops/QuantizedFunctions.h>
|
||||
#include <ATen/native/vulkan/ops/Utils.h>
|
||||
#include <torch/library.h>
|
||||
#include <vector>
|
||||
|
||||
namespace at {
|
||||
namespace native {
|
||||
@ -12,7 +12,7 @@ namespace ops {
|
||||
|
||||
using namespace api::utils;
|
||||
|
||||
Tensor binary_op_scalar(
|
||||
static Tensor binary_op_scalar(
|
||||
const Tensor& self_arg,
|
||||
const Scalar& other,
|
||||
const std::optional<Scalar>& alpha_arg,
|
||||
@ -66,7 +66,7 @@ Tensor binary_op_scalar(
|
||||
return convert(v_output);
|
||||
}
|
||||
|
||||
Tensor binary_op_preprocess_other_arg(const Tensor& other_arg) {
|
||||
static Tensor binary_op_preprocess_other_arg(const Tensor& other_arg) {
|
||||
// Similar to binary_op_scalar where tensors is mapped to float, we
|
||||
// also map known integer types (but not quant types) tensor to float.
|
||||
|
||||
@ -99,7 +99,7 @@ Tensor binary_op_preprocess_other_arg(const Tensor& other_arg) {
|
||||
return other;
|
||||
}
|
||||
|
||||
Tensor& binary_op_scalar_(
|
||||
static Tensor& binary_op_scalar_(
|
||||
Tensor& self_arg,
|
||||
const Scalar& other,
|
||||
const std::optional<Scalar>& alpha_arg,
|
||||
@ -149,7 +149,7 @@ Tensor& binary_op_scalar_(
|
||||
return self_arg;
|
||||
}
|
||||
|
||||
Tensor binary_op_tensor(
|
||||
static Tensor binary_op_tensor(
|
||||
const Tensor& self_arg,
|
||||
const Tensor& other_arg,
|
||||
const std::optional<Scalar>& alpha_arg,
|
||||
@ -222,7 +222,7 @@ Tensor binary_op_tensor(
|
||||
return convert(v_output);
|
||||
}
|
||||
|
||||
Tensor quantized_binary_op_tensor(
|
||||
static Tensor quantized_binary_op_tensor(
|
||||
const Tensor& self_arg,
|
||||
const Tensor& other_arg,
|
||||
const double scale,
|
||||
@ -310,7 +310,7 @@ Tensor quantized_binary_op_tensor(
|
||||
return convert_quantized(v_output);
|
||||
}
|
||||
|
||||
Tensor& binary_op_tensor_(
|
||||
static Tensor& binary_op_tensor_(
|
||||
Tensor& self_arg,
|
||||
const Tensor& other_arg,
|
||||
const std::optional<Scalar>& alpha_arg,
|
||||
@ -384,7 +384,7 @@ Tensor& binary_op_tensor_(
|
||||
return self_arg;
|
||||
}
|
||||
|
||||
Tensor add_scalar(
|
||||
static Tensor add_scalar(
|
||||
const Tensor& self_arg,
|
||||
const Scalar& other,
|
||||
const Scalar& alpha) {
|
||||
@ -392,7 +392,10 @@ Tensor add_scalar(
|
||||
self_arg, other, std::optional<Scalar>(alpha), VK_KERNEL(add_scalar));
|
||||
}
|
||||
|
||||
Tensor& add_scalar_(Tensor& self, const Scalar& other, const Scalar& alpha) {
|
||||
static Tensor& add_scalar_(
|
||||
Tensor& self,
|
||||
const Scalar& other,
|
||||
const Scalar& alpha) {
|
||||
return binary_op_scalar_(
|
||||
self, other, std::optional<Scalar>(alpha), VK_KERNEL(add_scalar_inplace));
|
||||
}
|
||||
@ -433,7 +436,7 @@ Tensor quantized_div(
|
||||
self_arg, other_arg, scale, zero_point, VK_KERNEL(quantized_div));
|
||||
}
|
||||
|
||||
Tensor add_tensor(
|
||||
static Tensor add_tensor(
|
||||
const Tensor& self_arg,
|
||||
const Tensor& other_arg,
|
||||
const Scalar& alpha) {
|
||||
@ -441,7 +444,7 @@ Tensor add_tensor(
|
||||
self_arg, other_arg, std::optional<Scalar>(alpha), VK_KERNEL(add));
|
||||
}
|
||||
|
||||
Tensor& add_tensor_(
|
||||
static Tensor& add_tensor_(
|
||||
Tensor& self,
|
||||
const Tensor& other_arg,
|
||||
const Scalar& alpha) {
|
||||
@ -449,7 +452,7 @@ Tensor& add_tensor_(
|
||||
self, other_arg, std::optional<Scalar>(alpha), VK_KERNEL(add_inplace));
|
||||
}
|
||||
|
||||
Tensor sub_scalar(
|
||||
static Tensor sub_scalar(
|
||||
const Tensor& self_arg,
|
||||
const Scalar& other,
|
||||
const Scalar& alpha) {
|
||||
@ -460,7 +463,10 @@ Tensor sub_scalar(
|
||||
VK_KERNEL(add_scalar));
|
||||
}
|
||||
|
||||
Tensor& sub_scalar_(Tensor& self, const Scalar& other, const Scalar& alpha) {
|
||||
static Tensor& sub_scalar_(
|
||||
Tensor& self,
|
||||
const Scalar& other,
|
||||
const Scalar& alpha) {
|
||||
return binary_op_scalar_(
|
||||
self,
|
||||
other,
|
||||
@ -468,7 +474,7 @@ Tensor& sub_scalar_(Tensor& self, const Scalar& other, const Scalar& alpha) {
|
||||
VK_KERNEL(add_scalar_inplace));
|
||||
}
|
||||
|
||||
Tensor sub_tensor(
|
||||
static Tensor sub_tensor(
|
||||
const Tensor& self_arg,
|
||||
const Tensor& other_arg,
|
||||
const Scalar& alpha) {
|
||||
@ -476,7 +482,7 @@ Tensor sub_tensor(
|
||||
self_arg, other_arg, std::optional<Scalar>(alpha), VK_KERNEL(sub));
|
||||
}
|
||||
|
||||
Tensor& sub_tensor_(
|
||||
static Tensor& sub_tensor_(
|
||||
Tensor& self,
|
||||
const Tensor& other_arg,
|
||||
const Scalar& alpha) {
|
||||
@ -484,27 +490,27 @@ Tensor& sub_tensor_(
|
||||
self, other_arg, std::optional<Scalar>(alpha), VK_KERNEL(sub_inplace));
|
||||
}
|
||||
|
||||
Tensor mul_scalar(const Tensor& self_arg, const Scalar& other) {
|
||||
static Tensor mul_scalar(const Tensor& self_arg, const Scalar& other) {
|
||||
return binary_op_scalar(
|
||||
self_arg, other, std::optional<Scalar>(), VK_KERNEL(mul_scalar));
|
||||
}
|
||||
|
||||
Tensor& mul_scalar_(Tensor& self, const Scalar& other) {
|
||||
static Tensor& mul_scalar_(Tensor& self, const Scalar& other) {
|
||||
return binary_op_scalar_(
|
||||
self, other, std::optional<Scalar>(), VK_KERNEL(mul_scalar_inplace));
|
||||
}
|
||||
|
||||
Tensor mul_tensor(const Tensor& self_arg, const Tensor& other_arg) {
|
||||
static Tensor mul_tensor(const Tensor& self_arg, const Tensor& other_arg) {
|
||||
return binary_op_tensor(
|
||||
self_arg, other_arg, std::optional<Scalar>(), VK_KERNEL(mul));
|
||||
}
|
||||
|
||||
Tensor& mul_tensor_(Tensor& self, const Tensor& other_arg) {
|
||||
static Tensor& mul_tensor_(Tensor& self, const Tensor& other_arg) {
|
||||
return binary_op_tensor_(
|
||||
self, other_arg, std::optional<Scalar>(), VK_KERNEL(mul_inplace));
|
||||
}
|
||||
|
||||
Tensor div_scalar(const Tensor& self_arg, const Scalar& other) {
|
||||
static Tensor div_scalar(const Tensor& self_arg, const Scalar& other) {
|
||||
return binary_op_scalar(
|
||||
self_arg,
|
||||
1.0 / other.to<float>(),
|
||||
@ -512,7 +518,7 @@ Tensor div_scalar(const Tensor& self_arg, const Scalar& other) {
|
||||
VK_KERNEL(mul_scalar));
|
||||
}
|
||||
|
||||
Tensor& div_scalar_(Tensor& self, const Scalar& other) {
|
||||
static Tensor& div_scalar_(Tensor& self, const Scalar& other) {
|
||||
return binary_op_scalar_(
|
||||
self,
|
||||
1.0 / other.to<float>(),
|
||||
@ -520,31 +526,31 @@ Tensor& div_scalar_(Tensor& self, const Scalar& other) {
|
||||
VK_KERNEL(mul_scalar_inplace));
|
||||
}
|
||||
|
||||
Tensor div_tensor(const Tensor& self_arg, const Tensor& other_arg) {
|
||||
static Tensor div_tensor(const Tensor& self_arg, const Tensor& other_arg) {
|
||||
return binary_op_tensor(
|
||||
self_arg, other_arg, std::optional<Scalar>(), VK_KERNEL(div));
|
||||
}
|
||||
|
||||
Tensor& div_tensor_(Tensor& self, const Tensor& other_arg) {
|
||||
static Tensor& div_tensor_(Tensor& self, const Tensor& other_arg) {
|
||||
return binary_op_tensor_(
|
||||
self, other_arg, std::optional<Scalar>(), VK_KERNEL(div_inplace));
|
||||
}
|
||||
|
||||
Tensor pow(const Tensor& self, const Tensor& other) {
|
||||
static Tensor pow(const Tensor& self, const Tensor& other) {
|
||||
return binary_op_tensor(self, other, std::optional<Scalar>(), VK_KERNEL(pow));
|
||||
}
|
||||
|
||||
Tensor& pow_(Tensor& self, const Tensor& other) {
|
||||
static Tensor& pow_(Tensor& self, const Tensor& other) {
|
||||
return binary_op_tensor_(
|
||||
self, other, std::optional<Scalar>(), VK_KERNEL(pow_inplace));
|
||||
}
|
||||
|
||||
Tensor pow_tensor_scalar(const Tensor& self, const Scalar& other) {
|
||||
static Tensor pow_tensor_scalar(const Tensor& self, const Scalar& other) {
|
||||
return binary_op_scalar(
|
||||
self, other, std::optional<Scalar>(), VK_KERNEL(pow_tensor_scalar));
|
||||
}
|
||||
|
||||
Tensor& pow_tensor_scalar_(Tensor& self, const Scalar& other) {
|
||||
static Tensor& pow_tensor_scalar_(Tensor& self, const Scalar& other) {
|
||||
return binary_op_scalar_(
|
||||
self,
|
||||
other,
|
||||
@ -552,12 +558,12 @@ Tensor& pow_tensor_scalar_(Tensor& self, const Scalar& other) {
|
||||
VK_KERNEL(pow_tensor_scalar_inplace));
|
||||
}
|
||||
|
||||
Tensor pow_scalar_tensor(const Scalar& self, const Tensor& other) {
|
||||
static Tensor pow_scalar_tensor(const Scalar& self, const Tensor& other) {
|
||||
return binary_op_scalar(
|
||||
other, self, std::optional<Scalar>(), VK_KERNEL(pow_scalar_tensor));
|
||||
}
|
||||
|
||||
Tensor floor_divide_scalar(const Tensor& self, const Scalar& other) {
|
||||
static Tensor floor_divide_scalar(const Tensor& self, const Scalar& other) {
|
||||
TORCH_CHECK(
|
||||
other.to<float>() != 0.0f, "floor_divide_scalar: can't divide by zero");
|
||||
return binary_op_scalar(
|
||||
@ -567,7 +573,7 @@ Tensor floor_divide_scalar(const Tensor& self, const Scalar& other) {
|
||||
VK_KERNEL(floor_mul_scalar));
|
||||
}
|
||||
|
||||
Tensor& floor_divide_scalar_(Tensor& self, const Scalar& other) {
|
||||
static Tensor& floor_divide_scalar_(Tensor& self, const Scalar& other) {
|
||||
TORCH_CHECK(
|
||||
other.to<float>() != 0.0f, "floor_divide_scalar_: can't divide by zero");
|
||||
return binary_op_scalar_(
|
||||
@ -577,12 +583,12 @@ Tensor& floor_divide_scalar_(Tensor& self, const Scalar& other) {
|
||||
VK_KERNEL(floor_mul_scalar_inplace));
|
||||
}
|
||||
|
||||
Tensor floor_divide_tensor(const Tensor& self, const Tensor& other) {
|
||||
static Tensor floor_divide_tensor(const Tensor& self, const Tensor& other) {
|
||||
return binary_op_tensor(
|
||||
self, other, std::optional<Scalar>(), VK_KERNEL(floor_divide));
|
||||
}
|
||||
|
||||
Tensor& floor_divide_tensor_(Tensor& self, const Tensor& other_arg) {
|
||||
static Tensor& floor_divide_tensor_(Tensor& self, const Tensor& other_arg) {
|
||||
return binary_op_tensor_(
|
||||
self,
|
||||
other_arg,
|
||||
@ -590,8 +596,6 @@ Tensor& floor_divide_tensor_(Tensor& self, const Tensor& other_arg) {
|
||||
VK_KERNEL(floor_divide_inplace));
|
||||
}
|
||||
|
||||
#ifdef USE_VULKAN_API
|
||||
|
||||
TORCH_LIBRARY_IMPL(aten, Vulkan, m) {
|
||||
m.impl(TORCH_SELECTIVE_NAME("aten::add.Scalar"), TORCH_FN(add_scalar));
|
||||
m.impl(TORCH_SELECTIVE_NAME("aten::add_.Scalar"), TORCH_FN(add_scalar_));
|
||||
@ -631,9 +635,8 @@ TORCH_LIBRARY_IMPL(aten, Vulkan, m) {
|
||||
TORCH_FN(floor_divide_tensor_));
|
||||
}
|
||||
|
||||
#endif /* USE_VULKAN_API */
|
||||
|
||||
} // namespace ops
|
||||
} // namespace vulkan
|
||||
} // namespace native
|
||||
} // namespace at
|
||||
#endif /* USE_VULKAN_API */
|
||||
|
@ -53,7 +53,7 @@ inline bool is_pointwise(const IntArrayRef weight_size) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Conv2dMethod determine_method(
|
||||
static Conv2dMethod determine_method(
|
||||
const IntArrayRef weight_size,
|
||||
const IntArrayRef stride,
|
||||
const IntArrayRef padding,
|
||||
@ -359,7 +359,7 @@ struct Params final {
|
||||
api::utils::vec2 clamp;
|
||||
};
|
||||
|
||||
void record_op(
|
||||
static void record_op(
|
||||
api::Context* const context,
|
||||
api::ShaderInfo& compute_shader,
|
||||
vTensor& v_output,
|
||||
@ -432,7 +432,7 @@ struct QParams final {
|
||||
api::utils::vec2 clamp;
|
||||
};
|
||||
|
||||
void record_quantized_op(
|
||||
static void record_quantized_op(
|
||||
api::Context* const context,
|
||||
api::ShaderInfo& compute_shader,
|
||||
vTensor& v_output,
|
||||
@ -787,56 +787,11 @@ Tensor convolution(
|
||||
input, c10::make_intrusive<Conv2dPackedContext>(conv_context));
|
||||
}
|
||||
|
||||
Tensor quantized_convolution(
|
||||
const Tensor& input,
|
||||
const Tensor& weight,
|
||||
const std::optional<Tensor>& bias,
|
||||
const IntArrayRef stride,
|
||||
const IntArrayRef padding,
|
||||
const IntArrayRef dilation,
|
||||
const bool transposed,
|
||||
const IntArrayRef output_padding,
|
||||
const int64_t groups,
|
||||
const double out_scale,
|
||||
const int64_t out_zero_point) {
|
||||
if (transposed) {
|
||||
return run_tconv2d_context(
|
||||
input,
|
||||
c10::make_intrusive<Conv2dPackedContext>(Conv2dPackedContext(
|
||||
weight,
|
||||
bias,
|
||||
stride,
|
||||
padding,
|
||||
dilation,
|
||||
transposed,
|
||||
false,
|
||||
output_padding,
|
||||
groups)));
|
||||
}
|
||||
|
||||
Conv2dPackedContext conv_context = Conv2dPackedContext(
|
||||
weight,
|
||||
bias,
|
||||
stride,
|
||||
padding,
|
||||
dilation,
|
||||
transposed,
|
||||
true,
|
||||
output_padding,
|
||||
groups);
|
||||
|
||||
return run_qconv2d_context(
|
||||
input,
|
||||
out_scale,
|
||||
out_zero_point,
|
||||
c10::make_intrusive<Conv2dPackedContext>(conv_context));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace conv1d {
|
||||
|
||||
vTensor pack_weights_using_width_packing(const Tensor& weight_arg) {
|
||||
static vTensor pack_weights_using_width_packing(const Tensor& weight_arg) {
|
||||
Tensor weight = weight_arg;
|
||||
|
||||
if (weight.is_cpu()) {
|
||||
@ -862,7 +817,7 @@ vTensor pack_weights_using_width_packing(const Tensor& weight_arg) {
|
||||
* This is a full implementation. For algorithm details, refer to the shader
|
||||
* kernel code.
|
||||
*/
|
||||
Tensor run_conv1d_context_impl(
|
||||
static Tensor run_conv1d_context_impl(
|
||||
const Tensor& input_arg,
|
||||
const Tensor& weight_arg,
|
||||
const std::optional<Tensor>& bias_arg_opt,
|
||||
@ -1150,7 +1105,7 @@ c10::intrusive_ptr<Conv2dPackedContext> create_qtconv2d_context(
|
||||
output_max));
|
||||
}
|
||||
|
||||
Tensor run_conv2d_context_impl(
|
||||
static Tensor run_conv2d_context_impl(
|
||||
const Tensor& input_arg,
|
||||
const c10::intrusive_ptr<Conv2dPackedContext>& conv_context,
|
||||
double scale,
|
||||
@ -1291,30 +1246,6 @@ Tensor run_qconv2d_context(
|
||||
return run_conv2d_context_impl(input_arg, conv_context, scale, zero_point);
|
||||
}
|
||||
|
||||
Tensor quantized_conv2d(
|
||||
const Tensor& input,
|
||||
const Tensor& weight,
|
||||
const std::optional<Tensor>& bias,
|
||||
IntArrayRef stride,
|
||||
IntArrayRef padding,
|
||||
IntArrayRef dilation,
|
||||
int64_t groups,
|
||||
double out_scale,
|
||||
int64_t out_zero_point) {
|
||||
return quantized_convolution(
|
||||
input,
|
||||
weight,
|
||||
bias,
|
||||
stride,
|
||||
padding,
|
||||
dilation,
|
||||
false,
|
||||
{{0, 0}},
|
||||
groups,
|
||||
out_scale,
|
||||
out_zero_point);
|
||||
}
|
||||
|
||||
/* Backwards compatibility */
|
||||
Conv2dOpContext::Conv2dOpContext(Conv2dPackedContext conv_context)
|
||||
: conv_context_{std::move(conv_context)} {}
|
||||
@ -1444,7 +1375,7 @@ c10::intrusive_ptr<Conv1dPackedContext> create_conv1d_context(
|
||||
Conv1dPackedContext(weight, bias, stride, padding, dilation, groups));
|
||||
}
|
||||
|
||||
Tensor convolution1d(
|
||||
static Tensor convolution1d(
|
||||
const Tensor& input,
|
||||
const Tensor& weight,
|
||||
const std::optional<Tensor>& bias,
|
||||
|
@ -123,7 +123,7 @@ void transfer_vulkan_to_cpu(vTensor& v_src, Tensor& dst) {
|
||||
.to(convert_dtype(v_src.dtype()));
|
||||
}
|
||||
|
||||
void transfer_vulkan_to_vulkan(vTensor& src, vTensor& dst) {
|
||||
static void transfer_vulkan_to_vulkan(vTensor& src, vTensor& dst) {
|
||||
api::Context* const context = api::context();
|
||||
|
||||
api::PipelineBarrier pipeline_barrier{};
|
||||
|
@ -28,7 +28,7 @@ Tensor _empty_affine_quantized(
|
||||
});
|
||||
}
|
||||
|
||||
Tensor empty_memory_format(
|
||||
static Tensor empty_memory_format(
|
||||
const IntArrayRef sizes,
|
||||
const std::optional<ScalarType> dtype,
|
||||
const std::optional<c10::Layout> layout,
|
||||
@ -46,7 +46,7 @@ Tensor empty_memory_format(
|
||||
});
|
||||
}
|
||||
|
||||
Tensor empty_strided(
|
||||
static Tensor empty_strided(
|
||||
const IntArrayRef sizes,
|
||||
const IntArrayRef /* strides */,
|
||||
const std::optional<ScalarType> dtype,
|
||||
|
@ -135,7 +135,8 @@ TORCH_LIBRARY_IMPL(aten, Vulkan, m) {
|
||||
|
||||
} // namespace
|
||||
|
||||
std::vector<c10::intrusive_ptr<LinearPackedContext>> pack_linear_op_contexts(
|
||||
static std::vector<c10::intrusive_ptr<LinearPackedContext>>
|
||||
pack_linear_op_contexts(
|
||||
const std::vector<Tensor>& params_cpu,
|
||||
int64_t num_layers) {
|
||||
TORCH_CHECK(
|
||||
|
@ -78,7 +78,7 @@ Tensor run_layernorm_context(
|
||||
return std::get<0>(native_layer_norm_output);
|
||||
}
|
||||
|
||||
Tensor layer_norm(
|
||||
static Tensor layer_norm(
|
||||
const at::Tensor& input_arg,
|
||||
IntArrayRef normalized_shape,
|
||||
const std::optional<Tensor>& weight_opt /* optional */,
|
||||
|
@ -171,7 +171,7 @@ TORCH_LIBRARY_IMPL(aten, Vulkan, m) {
|
||||
|
||||
} // namespace
|
||||
|
||||
std::vector<c10::intrusive_ptr<LinearPackedContext>>
|
||||
static std::vector<c10::intrusive_ptr<LinearPackedContext>>
|
||||
pack_lstm_linear_op_contexts(
|
||||
const std::vector<Tensor>& params_cpu,
|
||||
int64_t num_layers) {
|
||||
|
@ -1,3 +1,4 @@
|
||||
#ifdef USE_VULKAN_API
|
||||
#include <ATen/native/vulkan/ops/Common.h>
|
||||
#include <ATen/native/vulkan/ops/QuantizedFunctions.h>
|
||||
#include <ATen/native/vulkan/ops/Utils.h>
|
||||
@ -161,13 +162,13 @@ Tensor dequantize_helper(
|
||||
return convert(v_output);
|
||||
}
|
||||
|
||||
double q_scale(const Tensor& self) {
|
||||
static double q_scale(const Tensor& self) {
|
||||
TORCH_CHECK(self.is_vulkan(), "Expecting a vulkan tensor for q_scale");
|
||||
const vTensor& v_input = convert(self);
|
||||
return v_input.get_scale();
|
||||
}
|
||||
|
||||
int64_t q_zero_point(const Tensor& self) {
|
||||
static int64_t q_zero_point(const Tensor& self) {
|
||||
TORCH_CHECK(self.is_vulkan(), "Expecting a vulkan tensor for q_zero_point");
|
||||
const vTensor& v_input = convert(self);
|
||||
return v_input.get_zero_point();
|
||||
@ -179,8 +180,6 @@ Tensor dequantize(const Tensor& self) {
|
||||
return dequantize_helper(self, q_scale, zero_point, kFloat);
|
||||
}
|
||||
|
||||
#ifdef USE_VULKAN_API
|
||||
|
||||
TORCH_LIBRARY_IMPL(aten, Vulkan, m) {
|
||||
m.impl(
|
||||
TORCH_SELECTIVE_NAME("aten::quantize_per_tensor"), quantize_per_tensor);
|
||||
@ -192,9 +191,8 @@ TORCH_LIBRARY_IMPL(aten, Vulkan, m) {
|
||||
m.impl(TORCH_SELECTIVE_NAME("aten::dequantize.self"), dequantize);
|
||||
}
|
||||
|
||||
#endif /* USE_VULKAN_API */
|
||||
|
||||
} // namespace ops
|
||||
} // namespace vulkan
|
||||
} // namespace native
|
||||
} // namespace at
|
||||
#endif /* USE_VULKAN_API */
|
||||
|
@ -12,7 +12,9 @@ namespace ops {
|
||||
|
||||
using namespace api::utils;
|
||||
|
||||
Tensor& uniform_(
|
||||
#ifdef USE_VULKAN_API
|
||||
|
||||
static Tensor& uniform_(
|
||||
Tensor& self,
|
||||
const double from,
|
||||
const double to,
|
||||
@ -57,7 +59,7 @@ Tensor& uniform_(
|
||||
return self;
|
||||
}
|
||||
|
||||
Tensor rand_like(
|
||||
static Tensor rand_like(
|
||||
const at::Tensor& input_arg,
|
||||
const std::optional<c10::ScalarType> /* not implemented */,
|
||||
const std::optional<c10::Layout> /* not implemented */,
|
||||
@ -71,7 +73,7 @@ Tensor rand_like(
|
||||
return input_arg.clone().detach().uniform_(0.0, 1.0);
|
||||
}
|
||||
|
||||
Tensor& normal_(
|
||||
static Tensor& normal_(
|
||||
Tensor& self,
|
||||
const double mean,
|
||||
const double std,
|
||||
@ -118,7 +120,7 @@ Tensor& normal_(
|
||||
return self;
|
||||
}
|
||||
|
||||
Tensor randn_like(
|
||||
static Tensor randn_like(
|
||||
const at::Tensor& input_arg,
|
||||
const std::optional<c10::ScalarType> /* not implemented */,
|
||||
const std::optional<c10::Layout> /* not implemented */,
|
||||
@ -130,8 +132,6 @@ Tensor randn_like(
|
||||
return input_arg.clone().detach().normal_(0.0, 1.0);
|
||||
}
|
||||
|
||||
#ifdef USE_VULKAN_API
|
||||
|
||||
TORCH_LIBRARY_IMPL(aten, Vulkan, m) {
|
||||
m.impl(TORCH_SELECTIVE_NAME("aten::uniform_"), TORCH_FN(uniform_));
|
||||
m.impl(TORCH_SELECTIVE_NAME("aten::rand_like"), TORCH_FN(rand_like));
|
||||
|
@ -8,7 +8,7 @@ namespace native {
|
||||
namespace vulkan {
|
||||
namespace ops {
|
||||
|
||||
Tensor view_internal(const Tensor& self_arg, const IntArrayRef shape) {
|
||||
static Tensor view_internal(const Tensor& self_arg, const IntArrayRef shape) {
|
||||
api::Context* const context = api::context();
|
||||
|
||||
Tensor self = self_arg.is_vulkan() ? self_arg : self_arg.vulkan();
|
||||
@ -52,7 +52,7 @@ inline Tensor view(const Tensor& self_arg, IntArrayRef shape) {
|
||||
return view_internal(self_arg, shape);
|
||||
}
|
||||
|
||||
Tensor _reshape_alias(
|
||||
static Tensor _reshape_alias(
|
||||
const Tensor& self_arg,
|
||||
const IntArrayRef shape,
|
||||
const IntArrayRef strides) {
|
||||
|
@ -9,7 +9,7 @@ namespace vulkan {
|
||||
namespace ops {
|
||||
using namespace api::utils;
|
||||
|
||||
Tensor upsample_nearest2d(
|
||||
static Tensor upsample_nearest2d(
|
||||
const Tensor& input_arg,
|
||||
const IntArrayRef output_sizes,
|
||||
const std::optional<double> scales_h,
|
||||
@ -94,7 +94,7 @@ Tensor upsample_nearest2d(
|
||||
return convert(v_output);
|
||||
}
|
||||
|
||||
Tensor upsample_bilinear2d(
|
||||
static Tensor upsample_bilinear2d(
|
||||
const Tensor& input_arg,
|
||||
const IntArrayRef output_sizes,
|
||||
bool align_corners,
|
||||
|
@ -1,5 +1,6 @@
|
||||
#include <ATen/native/vulkan/impl/Packing.h>
|
||||
#include <ATen/native/vulkan/ops/Common.h>
|
||||
#include <ATen/native/vulkan/ops/Utils.h>
|
||||
|
||||
#ifndef AT_PER_OPERATOR_HEADERS
|
||||
#include <ATen/Functions.h>
|
||||
|
@ -767,7 +767,7 @@ if(NOT MSVC)
|
||||
set_source_files_properties(${PROJECT_SOURCE_DIR}/torch/csrc/distributed/c10d/socket.cpp PROPERTIES COMPILE_OPTIONS "-Wno-error=deprecated")
|
||||
endif()
|
||||
|
||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND NOT USE_VULKAN AND NOT USE_IOS AND NOT USE_COREML_DELEGATE)
|
||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang" AND NOT USE_IOS AND NOT USE_COREML_DELEGATE)
|
||||
target_compile_options_if_supported(torch_cpu "-Wmissing-prototypes")
|
||||
target_compile_options_if_supported(torch_cpu "-Werror=missing-prototypes")
|
||||
get_target_property(TORCH_CPU_SOURCES torch_cpu SOURCES)
|
||||
|
Reference in New Issue
Block a user