Commit 94e3a2e4 authored by Shucai Xiao's avatar Shucai Xiao
Browse files

change size_t to int

parent 26bd92d8
......@@ -68,7 +68,7 @@ struct argument : raw_data<argument>
std::vector<argument> get_sub_objects() const;
/// Return the ith element
argument element(std::size_t i) const;
argument element(int i) const;
private:
void assign_buffer(std::function<char*()> d);
......
......@@ -25,7 +25,7 @@ struct array_type<void, Ts...> : std::common_type<Ts...>
template <class R, class... Ts>
using array_type_t = typename array_type<R, Ts...>::type;
template <class T, std::size_t N, std::size_t... I>
template <class T, int N, int... I>
constexpr std::array<std::remove_cv_t<T>, N> to_array_impl(T (&a)[N], seq<I...>)
{
return {{a[I]...}};
......@@ -41,7 +41,7 @@ constexpr std::array<detail::array_type_t<Result, Ts...>, sizeof...(Ts)> make_ar
constexpr std::array<int, 0> make_array() { return {}; }
template <class T, std::size_t N>
template <class T, int N>
constexpr auto to_array(T (&a)[N])
{
return detail::to_array_impl(a, detail::gens<N>{});
......@@ -49,7 +49,7 @@ constexpr auto to_array(T (&a)[N])
namespace detail {
template <std::size_t Offset = 0, class Array, std::size_t... I>
template <int Offset = 0, class Array, int... I>
constexpr auto rearray_impl(Array a, seq<I...>)
{
return make_array(a[I + Offset]...);
......@@ -57,13 +57,13 @@ constexpr auto rearray_impl(Array a, seq<I...>)
} // namespace detail
template <class T, std::size_t N>
template <class T, int N>
constexpr auto pop_front(std::array<T, N> a)
{
return detail::rearray_impl(a, detail::gens<N - 1>{});
}
template <class T, std::size_t N>
template <class T, int N>
constexpr auto pop_back(std::array<T, N> a)
{
return detail::rearray_impl<1>(a, detail::gens<N - 1>{});
......
......@@ -15,7 +15,7 @@ struct src_file
{
fs::path path;
std::pair<const char*, const char*> content;
std::size_t len() const { return content.second - content.first; }
int len() const { return content.second - content.first; }
};
struct src_compiler
......
......@@ -18,7 +18,7 @@ struct dynamic_loader
dynamic_loader(const fs::path& p);
dynamic_loader(const char* image, std::size_t size);
dynamic_loader(const char* image, int size);
dynamic_loader(const std::vector<char>& buffer);
......
......@@ -17,7 +17,7 @@ struct module;
struct eliminate_allocation
{
std::string allocation_op{};
std::size_t alignment = 32;
int alignment = 32;
std::string name() const { return "eliminate_allocation"; }
void apply(module& p) const;
};
......
......@@ -19,7 +19,7 @@ bool enabled(const char* name);
bool disabled(const char* name);
std::vector<std::string> env(const char* name);
std::size_t value_of(const char* name, std::size_t fallback = 0);
int value_of(const char* name, int fallback = 0);
std::string string_value_of(const char* name, std::string fallback = "");
......@@ -38,9 +38,9 @@ bool disabled(T)
}
template <class T>
std::size_t value_of(T, std::size_t fallback = 0)
int value_of(T, int fallback = 0)
{
static const std::size_t result = value_of(T::value(), fallback);
static const int result = value_of(T::value(), fallback);
return result;
}
......
......@@ -11,7 +11,7 @@ inline namespace MIGRAPHX_INLINE_NS {
std::vector<char> read_buffer(const std::string& filename);
std::string read_string(const std::string& filename);
void write_buffer(const std::string& filename, const char* buffer, std::size_t size);
void write_buffer(const std::string& filename, const char* buffer, int size);
void write_buffer(const std::string& filename, const std::vector<char>& buffer);
} // namespace MIGRAPHX_INLINE_NS
......
......@@ -35,7 +35,7 @@ struct fix_f
}
};
template <std::size_t...>
template <int...>
struct seq
{
using type = seq;
......@@ -44,12 +44,12 @@ struct seq
template <class, class>
struct merge_seq;
template <std::size_t... Xs, std::size_t... Ys>
template <int... Xs, int... Ys>
struct merge_seq<seq<Xs...>, seq<Ys...>> : seq<Xs..., (sizeof...(Xs) + Ys)...>
{
};
template <std::size_t N>
template <int N>
struct gens : merge_seq<typename gens<N / 2>::type, typename gens<N - N / 2>::type>
{
};
......@@ -63,27 +63,27 @@ struct gens<1> : seq<0>
{
};
template <class F, std::size_t... Ns>
template <class F, int... Ns>
constexpr void repeat_c_impl(F f, seq<Ns...>)
{
swallow{(f(std::integral_constant<std::size_t, Ns>{}), 0)...};
swallow{(f(std::integral_constant<int, Ns>{}), 0)...};
}
template <class F, std::size_t... Ns>
template <class F, int... Ns>
constexpr auto sequence_c_impl(F&& f, seq<Ns...>)
{
return f(std::integral_constant<std::size_t, Ns>{}...);
return f(std::integral_constant<int, Ns>{}...);
}
} // namespace detail
template <std::size_t N, class F>
template <int N, class F>
constexpr void repeat_c(F f)
{
detail::repeat_c_impl(f, detail::gens<N>{});
}
template <std::size_t N, class F>
template <int N, class F>
constexpr auto sequence_c(F&& f)
{
return detail::sequence_c_impl(f, detail::gens<N>{});
......
......@@ -12,9 +12,9 @@ inline namespace MIGRAPHX_INLINE_NS {
template <class T, class F>
void gemm(tensor_view<T> cmat, tensor_view<T> amat, tensor_view<T> bmat, F alpha, F beta)
{
std::size_t n_dims = cmat.get_shape().lens().size();
std::size_t dim_0 = n_dims - 2;
std::size_t dim_1 = n_dims - 1;
int n_dims = cmat.get_shape().lens().size();
int dim_0 = n_dims - 2;
int dim_1 = n_dims - 1;
auto k = amat.get_shape().lens()[dim_1];
assert(amat.get_shape().lens()[dim_1] == bmat.get_shape().lens()[dim_0]);
......
......@@ -21,7 +21,7 @@ template <>
struct hash<migraphx::instruction_ref>
{
using argument_type = migraphx::instruction_ref;
using result_type = std::size_t;
using result_type = int;
result_type operator()(const migraphx::instruction_ref& x) const noexcept
{
return std::hash<migraphx::instruction*>{}(migraphx::as_address(x));
......
......@@ -10,7 +10,7 @@ inline namespace MIGRAPHX_INLINE_NS {
std::string to_json_string(const value& val);
value from_json_string(const std::string& str);
value from_json_string(const char* str, std::size_t size);
value from_json_string(const char* str, int size);
} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx
......
......@@ -16,7 +16,7 @@ struct file_options
program load(const std::string& filename, const file_options& options = file_options{});
program load_buffer(const std::vector<char>& buffer, const file_options& options = file_options{});
program
load_buffer(const char* buffer, std::size_t size, const file_options& options = file_options{});
load_buffer(const char* buffer, int size, const file_options& options = file_options{});
void save(const program& p,
const std::string& filename,
......
......@@ -8,7 +8,7 @@ namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {
template <typename T>
std::shared_ptr<T> make_shared_array(size_t size)
std::shared_ptr<T> make_shared_array(int size)
{
return std::shared_ptr<T>(new T[size](), std::default_delete<T[]>()); // NOLINT
}
......
......@@ -127,7 +127,7 @@ struct module
bool has_instruction(instruction_ref ins) const;
std::size_t size() const;
int size() const;
instruction_ref begin() const;
instruction_ref end() const;
......
......@@ -9,7 +9,7 @@ inline namespace MIGRAPHX_INLINE_NS {
std::vector<char> to_msgpack(const value& v);
value from_msgpack(const std::vector<char>& buffer);
value from_msgpack(const char* buffer, std::size_t size);
value from_msgpack(const char* buffer, int size);
} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx
......
......@@ -18,8 +18,8 @@ namespace op {
struct capture
{
std::size_t ins_index;
std::function<void(std::size_t ins_index, std::vector<argument>)> f{};
int ins_index;
std::function<void(int ins_index, std::vector<argument>)> f{};
template <class Self, class F>
static auto reflect(Self& self, F f)
{
......
......@@ -39,8 +39,8 @@ struct dot
"} x {" + to_string_range(b.lens()) + "}");
}
std::size_t dim_0 = a.lens().size() - 2;
std::size_t dim_1 = a.lens().size() - 1;
int dim_0 = a.lens().size() - 2;
int dim_1 = a.lens().size() - 1;
if(a.lens()[dim_1] != b.lens()[dim_0])
{
MIGRAPHX_THROW("DOT: inner dimensions do not match: {" + to_string_range(a.lens()) +
......
......@@ -62,7 +62,7 @@ struct gather
argument result{output_shape};
// negative axis means counting dimensions from back
auto lens = args[0].get_shape().lens();
std::size_t axis_dim_size = lens[axis];
int axis_dim_size = lens[axis];
// max dimension in axis
visit_all(result, args[0])([&](auto output, auto data) {
args[1].visit([&](auto indices) {
......
......@@ -15,7 +15,7 @@ namespace op {
struct get_tuple_elem
{
std::size_t index = 0;
int index = 0;
template <class Self, class F>
static auto reflect(Self& self, F f)
......
......@@ -85,7 +85,7 @@ struct loop
auto* in_data = iter_stat.data();
auto* out_data = scan_out.data();
std::size_t out_size = iter_stat.get_shape().bytes();
int out_size = iter_stat.get_shape().bytes();
assert((iter + 1) * out_size <= scan_out.get_shape().bytes());
std::copy(in_data, in_data + out_size, out_data + iter * out_size);
}
......
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