Unverified Commit ee80cee9 authored by Paul Fultz II's avatar Paul Fultz II Committed by GitHub
Browse files

Merge branch 'master' into gpu_slice_test

parents 6d06226d f958d56f
......@@ -2,9 +2,11 @@
#define MIGRAPH_GUARD_MIGRAPHLIB_KERNELS_HPP
#include <migraph/argument.hpp>
#include <migraph/config.hpp>
#include <hip/hip_runtime_api.h>
namespace migraph {
inline namespace MIGRAPH_INLINE_NS {
namespace gpu {
namespace device {
......@@ -12,6 +14,7 @@ void contiguous(hipStream_t stream, argument result, argument arg);
} // namespace device
} // namespace gpu
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph
#endif
......@@ -3,9 +3,11 @@
#define MIGRAPH_GUARD_RTGLIB_DEVICE_MUL_HPP
#include <migraph/argument.hpp>
#include <migraph/config.hpp>
#include <hip/hip_runtime_api.h>
namespace migraph {
inline namespace MIGRAPH_INLINE_NS {
namespace gpu {
namespace device {
......@@ -19,6 +21,7 @@ void mul(hipStream_t stream,
} // namespace device
} // namespace gpu
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph
#endif
......@@ -3,8 +3,10 @@
#include <string>
#include <migraph/instruction_ref.hpp>
#include <migraph/config.hpp>
namespace migraph {
inline namespace MIGRAPH_INLINE_NS {
struct program;
namespace gpu {
......@@ -15,6 +17,7 @@ struct eliminate_workspace
void apply(program& p) const;
};
} // namespace gpu
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph
#endif
......@@ -2,9 +2,11 @@
#define MIGRAPH_GUARD_RTGLIB_FUSE_OPS_HPP
#include <migraph/program.hpp>
#include <migraph/config.hpp>
#include <migraph/gpu/context.hpp>
namespace migraph {
inline namespace MIGRAPH_INLINE_NS {
namespace gpu {
......@@ -16,7 +18,7 @@ struct fuse_ops
};
} // namespace gpu
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph
#endif
......@@ -10,6 +10,7 @@
#include <migraph/gpu/miopen.hpp>
#include <migraph/gpu/hip.hpp>
#include <migraph/dfor.hpp>
#include <migraph/config.hpp>
#include <migraph/gpu/device/contiguous.hpp>
#include <migraph/gpu/device/add.hpp>
#include <migraph/iterator_for.hpp>
......@@ -18,6 +19,7 @@
#include <utility>
namespace migraph {
inline namespace MIGRAPH_INLINE_NS {
namespace gpu {
struct miopen_gemm
......@@ -27,10 +29,11 @@ struct miopen_gemm
shape compute_shape(const std::vector<shape>& inputs) const;
argument
compute(context& ctx, const shape& output_shape, const std::vector<argument>& args) const;
int output_alias(const std::vector<shape>& shapes) const { return shapes.size() - 1; }
};
} // namespace gpu
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph
#endif
......@@ -2,9 +2,11 @@
#define MIGRAPH_GUARD_MIGRAPHLIB_HIP_HPP
#include <migraph/operators.hpp>
#include <migraph/config.hpp>
#include <utility>
namespace migraph {
inline namespace MIGRAPH_INLINE_NS {
namespace gpu {
migraph::argument allocate_gpu(const migraph::shape& s, bool host = false);
......@@ -67,6 +69,7 @@ struct hip_write
{
return to_gpu(args.front());
}
int output_alias(const std::vector<shape>&) const { return 0; }
};
struct hip_copy
......@@ -82,8 +85,11 @@ struct hip_copy
copy_to_gpu(args[0], args[1]);
return args[1];
}
int output_alias(const std::vector<shape>&) const { return 1; }
};
} // namespace gpu
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph
#endif
......@@ -7,6 +7,7 @@
#include <migraph/operators.hpp>
#include <migraph/generate.hpp>
#include <migraph/shape_for_each.hpp>
#include <migraph/config.hpp>
#include <migraph/gpu/miopen.hpp>
#include <migraph/gpu/hip.hpp>
#include <migraph/dfor.hpp>
......@@ -18,6 +19,7 @@
#include <utility>
namespace migraph {
inline namespace MIGRAPH_INLINE_NS {
namespace gpu {
struct miopen_leaky_relu
......@@ -27,10 +29,11 @@ struct miopen_leaky_relu
shape compute_shape(const std::vector<shape>& inputs) const;
argument
compute(context& ctx, const shape& output_shape, const std::vector<argument>& args) const;
int output_alias(const std::vector<shape>& shapes) const { return shapes.size() - 1; }
};
} // namespace gpu
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph
#endif
......@@ -2,9 +2,11 @@
#define MIGRAPH_GUARD_RTGLIB_MIOPEN_LOWERING_HPP
#include <migraph/program.hpp>
#include <migraph/config.hpp>
#include <migraph/gpu/context.hpp>
namespace migraph {
inline namespace MIGRAPH_INLINE_NS {
namespace gpu {
struct lowering
......@@ -15,7 +17,7 @@ struct lowering
};
} // namespace gpu
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph
#endif
......@@ -4,8 +4,10 @@
#include <migraph/manage_ptr.hpp>
#include <migraph/operators.hpp>
#include <miopen/miopen.h>
#include <migraph/config.hpp>
namespace migraph {
inline namespace MIGRAPH_INLINE_NS {
namespace gpu {
using miopen_handle = MIGRAPH_MANAGE_PTR(miopenHandle_t, miopenDestroy);
......@@ -115,7 +117,7 @@ inline fused_operator_args make_fused_args()
}
} // namespace gpu
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph
#endif
......@@ -7,6 +7,7 @@
#include <migraph/operators.hpp>
#include <migraph/generate.hpp>
#include <migraph/shape_for_each.hpp>
#include <migraph/config.hpp>
#include <migraph/gpu/miopen.hpp>
#include <migraph/gpu/hip.hpp>
#include <migraph/dfor.hpp>
......@@ -18,6 +19,7 @@
#include <utility>
namespace migraph {
inline namespace MIGRAPH_INLINE_NS {
namespace gpu {
struct hip_mul
......@@ -25,10 +27,11 @@ struct hip_mul
std::string name() const { return "gpu::mul"; }
shape compute_shape(const std::vector<shape>& inputs) const;
argument compute(context&, const shape&, const std::vector<argument>& args) const;
int output_alias(const std::vector<shape>& shapes) const { return shapes.size() - 1; }
};
} // namespace gpu
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph
#endif
......@@ -7,6 +7,7 @@
#include <migraph/operators.hpp>
#include <migraph/generate.hpp>
#include <migraph/shape_for_each.hpp>
#include <migraph/config.hpp>
#include <migraph/gpu/miopen.hpp>
#include <migraph/gpu/hip.hpp>
#include <migraph/dfor.hpp>
......@@ -18,6 +19,7 @@
#include <utility>
namespace migraph {
inline namespace MIGRAPH_INLINE_NS {
namespace gpu {
struct miopen_pooling
......@@ -29,10 +31,11 @@ struct miopen_pooling
shape compute_shape(const std::vector<shape>& inputs) const;
argument
compute(context& ctx, const shape& output_shape, const std::vector<argument>& args) const;
int output_alias(const std::vector<shape>& shapes) const { return shapes.size() - 1; }
};
} // namespace gpu
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph
#endif
......@@ -7,6 +7,7 @@
#include <migraph/operators.hpp>
#include <migraph/generate.hpp>
#include <migraph/shape_for_each.hpp>
#include <migraph/config.hpp>
#include <migraph/gpu/miopen.hpp>
#include <migraph/gpu/hip.hpp>
#include <migraph/dfor.hpp>
......@@ -18,6 +19,7 @@
#include <utility>
namespace migraph {
inline namespace MIGRAPH_INLINE_NS {
namespace gpu {
struct miopen_relu
......@@ -27,10 +29,11 @@ struct miopen_relu
shape compute_shape(const std::vector<shape>& inputs) const;
argument
compute(context& ctx, const shape& output_shape, const std::vector<argument>& args) const;
int output_alias(const std::vector<shape>& shapes) const { return shapes.size() - 1; }
};
} // namespace gpu
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph
#endif
......@@ -3,9 +3,11 @@
#include <migraph/manage_ptr.hpp>
#include <migraph/operators.hpp>
#include <migraph/config.hpp>
#include <rocblas.h>
namespace migraph {
inline namespace MIGRAPH_INLINE_NS {
namespace gpu {
using rocblas_handle_ptr = MIGRAPH_MANAGE_PTR(rocblas_handle, rocblas_destroy_handle);
......@@ -14,7 +16,7 @@ rocblas_handle_ptr create_rocblas_handle_ptr();
rocblas_handle_ptr create_rocblas_handle_ptr(hipStream_t s);
} // namespace gpu
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph
#endif
......@@ -7,6 +7,7 @@
#include <migraph/operators.hpp>
#include <migraph/generate.hpp>
#include <migraph/shape_for_each.hpp>
#include <migraph/config.hpp>
#include <migraph/gpu/miopen.hpp>
#include <migraph/gpu/hip.hpp>
#include <migraph/dfor.hpp>
......@@ -18,6 +19,7 @@
#include <utility>
namespace migraph {
inline namespace MIGRAPH_INLINE_NS {
namespace gpu {
struct miopen_softmax
......@@ -27,10 +29,11 @@ struct miopen_softmax
shape compute_shape(const std::vector<shape>& inputs) const;
argument
compute(context& ctx, const shape& output_shape, const std::vector<argument>& args) const;
int output_alias(const std::vector<shape>& shapes) const { return shapes.size() - 1; }
};
} // namespace gpu
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph
#endif
......@@ -2,8 +2,10 @@
#define MIGRAPH_GUARD_MIGRAPHLIB_MIOPEN_TARGET_HPP
#include <migraph/program.hpp>
#include <migraph/config.hpp>
namespace migraph {
inline namespace MIGRAPH_INLINE_NS {
namespace gpu {
struct target
......@@ -12,7 +14,9 @@ struct target
std::vector<pass> get_passes(migraph::context& gctx) const;
migraph::context get_context() const;
};
} // namespace gpu
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph
#endif
......@@ -5,6 +5,7 @@
#include <migraph/gpu/context.hpp>
namespace migraph {
inline namespace MIGRAPH_INLINE_NS {
namespace gpu {
......@@ -17,7 +18,7 @@ struct write_literals
};
} // namespace gpu
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph
#endif
......@@ -5,6 +5,7 @@
#include <utility>
namespace migraph {
inline namespace MIGRAPH_INLINE_NS {
namespace gpu {
shape miopen_leaky_relu::compute_shape(const std::vector<shape>& inputs) const
......@@ -33,5 +34,5 @@ argument miopen_leaky_relu::compute(context& ctx,
}
} // namespace gpu
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph
......@@ -27,6 +27,7 @@
#include <utility>
namespace migraph {
inline namespace MIGRAPH_INLINE_NS {
namespace gpu {
struct miopen_apply
......@@ -50,9 +51,9 @@ struct miopen_apply
{
check_shape(s, apply_convolution(it));
}
else if(it->name() == "activation")
else if(it->name() == "relu")
{
check_shape(s, apply_activation(it));
check_shape(s, apply_relu(it));
}
else if(it->name() == "leaky_relu")
{
......@@ -131,17 +132,13 @@ struct miopen_apply
ins, miopen_pooling{op, std::move(pd)}, ins->inputs().at(0), output);
}
instruction_ref apply_activation(instruction_ref ins)
instruction_ref apply_relu(instruction_ref ins)
{
auto&& op = any_cast<op::activation>(ins->get_operator());
auto ad = make_relu();
if(op.mode == "relu")
{
auto output = insert_allocation(ins, ins->get_shape());
return prog->replace_instruction(
ins, miopen_relu{std::move(ad)}, ins->inputs().at(0), output);
}
return ins;
auto ad = make_relu();
auto output = insert_allocation(ins, ins->get_shape());
return prog->replace_instruction(
ins, miopen_relu{std::move(ad)}, ins->inputs().at(0), output);
}
instruction_ref apply_leaky_relu(instruction_ref ins)
......@@ -224,4 +221,5 @@ struct miopen_apply
void lowering::apply(program& p) const { miopen_apply{&p, ctx}.apply(); }
} // namespace gpu
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph
......@@ -5,6 +5,7 @@
#include <utility>
namespace migraph {
inline namespace MIGRAPH_INLINE_NS {
namespace gpu {
shape hip_mul::compute_shape(const std::vector<shape>& inputs) const
......@@ -21,5 +22,5 @@ argument hip_mul::compute(context& ctx, const shape&, const std::vector<argument
}
} // namespace gpu
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph
......@@ -5,6 +5,7 @@
#include <utility>
namespace migraph {
inline namespace MIGRAPH_INLINE_NS {
namespace gpu {
shape miopen_pooling::compute_shape(const std::vector<shape>& inputs) const
......@@ -37,5 +38,5 @@ argument miopen_pooling::compute(context& ctx,
}
} // namespace gpu
} // namespace MIGRAPH_INLINE_NS
} // namespace migraph
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