Skip to content
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
2 changes: 1 addition & 1 deletion backends/cadence/hifi/operators/op_mean.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ using executorch::aten::RuntimeContext;
using executorch::aten::ScalarType;
using executorch::aten::Tensor;
using executorch::runtime::ArrayRef;
using std::optional;
using torch::executor::Error;
using torch::executor::optional;

namespace impl {
namespace HiFi {
Expand Down
4 changes: 2 additions & 2 deletions backends/cadence/hifi/operators/op_quantized_matmul_out.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ void inline _typed_quantized_matmul(
int64_t X_zero_point,
const Tensor& Y,
int64_t Y_zero_point,
const exec_aten::optional<Tensor>& bias,
const std::optional<Tensor>& bias,
int64_t out_multiplier,
int64_t out_shift,
int64_t out_zero_point,
Expand Down Expand Up @@ -182,7 +182,7 @@ void quantized_matmul_out(
int64_t X_zero_point,
const Tensor& Y,
int64_t Y_zero_point,
const exec_aten::optional<Tensor>& bias,
const std::optional<Tensor>& bias,
int64_t out_multiplier,
int64_t out_shift,
int64_t out_zero_point,
Expand Down
4 changes: 2 additions & 2 deletions backends/cadence/hifi/operators/op_slice_copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Tensor& slice_copy_Tensor_out(
KernelRuntimeContext& ctx,
const Tensor& in,
int64_t dim,
exec_aten::optional<int64_t> start_val,
exec_aten::optional<int64_t> end_val,
std::optional<int64_t> start_val,
std::optional<int64_t> end_val,
int64_t step,
Tensor& out) {
(void)ctx;
Expand Down
4 changes: 2 additions & 2 deletions backends/cadence/hifi/operators/operators.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ void quantized_linear_out(
const ::executorch::aten::Tensor& out_multiplier,
const ::executorch::aten::Tensor& out_shift,
int64_t out_zero_point,
const ::executorch::aten::optional<::executorch::aten::Tensor>& offset,
const ::std::optional<::executorch::aten::Tensor>& offset,
::executorch::aten::Tensor& out);

void quantized_linear_per_tensor_out(
Expand All @@ -80,7 +80,7 @@ void quantized_linear_per_tensor_out(
int64_t out_multiplier,
int64_t out_shift,
int64_t out_zero_point,
const ::executorch::aten::optional<::executorch::aten::Tensor>& offset,
const ::std::optional<::executorch::aten::Tensor>& offset,
::executorch::aten::Tensor& out);

void quantized_conv2d_nhwc_out(
Expand Down
2 changes: 1 addition & 1 deletion backends/cortex_m/ops/cmsis_scratch_buffer_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class CMSISScratchBufferContext final {
Tensor& scratch_buffer,
const Tensor& weights,
const Tensor& weight_zero_point,
const torch::executor::optional<Tensor>& bias)
const ::std::optional<Tensor>& bias)
: scratch_ptr_(scratch_buffer.mutable_data_ptr<int8_t>()),
total_size_(scratch_buffer.size(0)),
base_ptr_(reinterpret_cast<uint8_t*>(scratch_ptr_)),
Expand Down
4 changes: 2 additions & 2 deletions backends/cortex_m/ops/op_quantized_linear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Tensor& quantized_linear_out(
const Tensor& weight_zero_point,
const Tensor& weight_multiplier,
const Tensor& weight_shift,
const torch::executor::optional<Tensor>& bias,
const ::std::optional<Tensor>& bias,
const Tensor& bias_multiplier,
const Tensor& bias_shift,
const Tensor& scratch_buffer,
Expand Down Expand Up @@ -155,7 +155,7 @@ Tensor quantized_linear(
const Tensor& weight_zero_point,
const Tensor& weight_multiplier,
const Tensor& weight_shift,
const torch::executor::optional<Tensor>& bias,
const ::std::optional<Tensor>& bias,
const Tensor& bias_multiplier,
const Tensor& bias_shift,
const Tensor& scratch_buffer,
Expand Down
18 changes: 9 additions & 9 deletions backends/vulkan/test/op_tests/dequantize_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ Tensor& dequantize_per_tensor_out(
int64_t quant_min,
int64_t quant_max,
ScalarType dtype,
executorch::aten::optional<ScalarType> out_dtype,
std::optional<ScalarType> out_dtype,
Tensor& out);

Tensor& dequantize_per_token_out(
Expand All @@ -57,7 +57,7 @@ Tensor& dequantize_per_channel_out(
int64_t quant_min,
int64_t quant_max,
ScalarType dtype,
executorch::aten::optional<ScalarType> out_dtype,
std::optional<ScalarType> out_dtype,
Tensor& out);

Tensor& dequantize_per_tensor_tensor_args_out(
Expand All @@ -67,7 +67,7 @@ Tensor& dequantize_per_tensor_tensor_args_out(
int64_t quant_min,
int64_t quant_max,
ScalarType dtype,
executorch::aten::optional<ScalarType> out_dtype,
std::optional<ScalarType> out_dtype,
Tensor& out);

// Wrapper function for dequantize_per_tensor_out without context
Expand All @@ -78,7 +78,7 @@ Tensor& dequantize_per_tensor_out_no_context(
int64_t quant_min,
int64_t quant_max,
ScalarType dtype,
executorch::aten::optional<ScalarType> out_dtype,
std::optional<ScalarType> out_dtype,
Tensor& out) {
return torch::executor::native::dequantize_per_tensor_out(
input, scale, zero_point, quant_min, quant_max, dtype, out_dtype, out);
Expand Down Expand Up @@ -107,7 +107,7 @@ Tensor& dequantize_per_channel_out_no_context(
int64_t quant_min,
int64_t quant_max,
ScalarType dtype,
executorch::aten::optional<ScalarType> out_dtype,
std::optional<ScalarType> out_dtype,
Tensor& out) {
return torch::executor::native::dequantize_per_channel_out(
input,
Expand All @@ -129,7 +129,7 @@ Tensor& dequantize_per_tensor_tensor_args_out_no_context(
int64_t quant_min,
int64_t quant_max,
ScalarType dtype,
executorch::aten::optional<ScalarType> out_dtype,
std::optional<ScalarType> out_dtype,
Tensor& out) {
return torch::executor::native::dequantize_per_tensor_tensor_args_out(
input, scale, zero_point, quant_min, quant_max, dtype, out_dtype, out);
Expand All @@ -149,7 +149,7 @@ at::Tensor dequantize_per_tensor_aten(
ScalarType et_dtype = at_scalartype_to_et_scalartype(dtype);
ScalarType et_out_dtype = at_scalartype_to_et_scalartype(out_dtype);

executorch::aten::optional<ScalarType> opt_et_out_dtype(et_out_dtype);
std::optional<ScalarType> opt_et_out_dtype(et_out_dtype);

WRAP_TO_ATEN(dequantize_per_tensor_out_no_context, 7)
(input,
Expand Down Expand Up @@ -204,7 +204,7 @@ at::Tensor dequantize_per_channel_aten(
ScalarType et_dtype = at_scalartype_to_et_scalartype(dtype);
ScalarType et_out_dtype = at_scalartype_to_et_scalartype(out_dtype);

executorch::aten::optional<ScalarType> opt_et_out_dtype(et_out_dtype);
std::optional<ScalarType> opt_et_out_dtype(et_out_dtype);

WRAP_TO_ATEN(dequantize_per_channel_out_no_context, 8)
(input,
Expand Down Expand Up @@ -233,7 +233,7 @@ at::Tensor dequantize_per_tensor_tensor_args_aten(
ScalarType et_dtype = at_scalartype_to_et_scalartype(dtype);
ScalarType et_out_dtype = at_scalartype_to_et_scalartype(out_dtype);

executorch::aten::optional<ScalarType> opt_et_out_dtype(et_out_dtype);
std::optional<ScalarType> opt_et_out_dtype(et_out_dtype);

WRAP_TO_ATEN(dequantize_per_tensor_tensor_args_out_no_context, 7)
(input,
Expand Down
14 changes: 7 additions & 7 deletions backends/vulkan/test/op_tests/quantize_affine_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ at::Tensor quantize_affine_reference_impl(
const at::Tensor& input_,
const std::vector<int64_t>& block_size,
const at::Tensor& scale,
const c10::optional<at::Tensor>& zero_point_opt,
const std::optional<at::Tensor>& zero_point_opt,
int64_t quant_min,
int64_t quant_max,
at::ScalarType out_dtype,
c10::optional<std::string> zero_point_domain_opt = std::string("INT")) {
std::optional<std::string> zero_point_domain_opt = std::string("INT")) {
constexpr float kEps = 1e-7f;

const int64_t ndim = input_.dim();
Expand Down Expand Up @@ -138,11 +138,11 @@ at::Tensor dequantize_affine_reference_impl(
const at::Tensor& input_,
const std::vector<int64_t>& block_size,
const at::Tensor& scale,
const c10::optional<at::Tensor>& zero_point_opt,
const std::optional<at::Tensor>& zero_point_opt,
int64_t quant_min,
int64_t quant_max,
at::ScalarType out_dtype,
c10::optional<std::string> zero_point_domain_opt = std::string("INT")) {
std::optional<std::string> zero_point_domain_opt = std::string("INT")) {
const int64_t ndim = input_.dim();
_check_dims("input", block_size.size(), ndim);

Expand Down Expand Up @@ -252,7 +252,7 @@ at::Tensor quantize_affine_reference_impl(
input,
block_size,
scale,
c10::optional<at::Tensor>(zero_point),
std::optional<at::Tensor>(zero_point),
quant_min,
quant_max,
dtype,
Expand All @@ -272,7 +272,7 @@ at::Tensor dequantize_affine_reference_impl(
input,
block_size,
scale,
c10::optional<at::Tensor>(zero_point),
std::optional<at::Tensor>(zero_point),
quant_min,
quant_max,
dtype,
Expand Down Expand Up @@ -1373,4 +1373,4 @@ TEST(VulkanChooseQParamsAffineTest, test_symmetric_no_clipping_narrow_range) {
10, // quant_max (narrow range)
1e-5, // eps
at::kFloat); // input dtype
}
}
4 changes: 2 additions & 2 deletions codegen/api/et_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ def return_names(f: NativeFunction, *, fallback_name: str = "result") -> Sequenc
JIT_TO_CPP_DEFAULT = {
"False": "false",
"True": "true",
"None": "torch::execustd::nullopt", # UGH this one is type directed
"None": "std::nullopt", # UGH this one is type directed
"[]": "{}",
"contiguous_format": "torch::executorch::MemoryFormat::Contiguous",
"long": "torch::executorch::kLong",
Expand Down Expand Up @@ -278,7 +278,7 @@ def default_expr(d: str, t: Type) -> str:

if isinstance(t, OptionalType):
if d == "None":
return "torch::executor::nullopt"
return "std::nullopt"

return default_expr(d, t.elem)

Expand Down
2 changes: 1 addition & 1 deletion codegen/api/types/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class OptionalCType(CType):

def cpp_type(self, *, strip_ref: bool = False) -> str:
# Do not pass `strip_ref` recursively.
return f"torch::executor::optional<{self.elem.cpp_type()}>"
return f"std::optional<{self.elem.cpp_type()}>"

def remove_const_ref(self) -> CType:
return OptionalCType(self.elem.remove_const_ref())
Expand Down
6 changes: 3 additions & 3 deletions extension/aten_util/make_aten_functor_from_et_functor.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ struct type_map<torch::executor::Tensor> final {

// Optional.
template <class T>
struct type_map<torch::executor::optional<T>> final {
struct type_map<std::optional<T>> final {
using type = std::optional<typename type_map<T>::type>;
};

template <class T>
struct type_map<torch::executor::optional<T>&> final {
struct type_map<std::optional<T>&> final {
using type = std::optional<typename type_map<T>::type>&;
};

Expand Down Expand Up @@ -166,7 +166,7 @@ struct type_convert<
typename remove_const_ref<AOptional>::type::value_type>> &&
std::is_same_v<
typename remove_const_ref<EOptional>::type,
torch::executor::optional<
std::optional<
typename remove_const_ref<EOptional>::type::value_type>>>>
final {
public:
Expand Down
Loading
Loading