address PR comments (#3312)

* address PR comments

* PR comments

* PR comments

* disable logging

* typo

Co-authored-by: Ethan Tao <ettao@microsoft.com>
This commit is contained in:
ytaous 2020-03-25 19:35:12 -07:00 committed by GitHub
parent b38fc0d541
commit 66c7579c93
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 16 additions and 20 deletions

View file

@ -55,20 +55,20 @@ union MLFloat16 {
MLFloat16() : val(0) {}
// Taken from https://stackoverflow.com/a/60047308/12627730
float as_float(uint32_t x) const {
float AsFloat(uint32_t x) const {
float out = 0.0f;
std::memcpy(&out, &x, sizeof(x));
return out;
}
// Taken from https://stackoverflow.com/a/60047308/12627730
uint32_t as_uint(float x) const {
uint32_t AsUint(float x) const {
uint32_t out = 0;
std::memcpy(&out, &x, sizeof(x));
return out;
}
float half_to_float(const uint16_t x) const {
float HalfToFloat(const uint16_t x) const {
uint16_t half = x;
if (endian::native == endian::big) {
// Taken from https://stackoverflow.com/a/2182184/12627730
@ -81,7 +81,7 @@ union MLFloat16 {
const uint32_t e = (half & 0x7C00) >> 10; // exponent
const uint32_t m = (half & 0x03FF) << 13; // mantissa
// evil log2 bit hack to count leading zeros in denormalized format
const uint32_t v = as_uint(static_cast<float>(m)) >> 23;
const uint32_t v = AsUint(static_cast<float>(m)) >> 23;
uint32_t full = (half & 0x8000) << 16 | (e != 0) * ((e + 112) << 23 | m) |
((e == 0) & (m != 0)) * ((v - 37) << 23 | ((m << (150 - v)) & 0x007FE000)); // sign : normalized : denormalized
@ -93,11 +93,11 @@ union MLFloat16 {
((full << 24) & 0xff000000); // byte 0 to byte 3
}
return as_float(full);
return AsFloat(full);
}
operator float() const {
return half_to_float(val);
return HalfToFloat(val);
}
};

View file

@ -97,7 +97,7 @@ class IExecutionProvider {
virtual std::shared_ptr<KernelRegistry> GetKernelRegistry() const;
/**
Get the device id of current excution provider
Get the device id of current execution provider
*/
virtual int GetDeviceId() const { return -1; };

View file

@ -25,9 +25,7 @@ TransposeMatMul::TransposeMatMul(const OpKernelInfo& info)
}
Status TransposeMatMul::Compute(OpKernelContext* context) const {
auto* context_internal = dynamic_cast<OpKernelContextInternal*>(context);
ORT_ENFORCE(context_internal, "Failed to get OpKernelContextInternal instance.");
concurrency::ThreadPool* thread_pool = context_internal->GetOperatorThreadPool();
concurrency::ThreadPool* thread_pool = context->GetOperatorThreadPool();
const Tensor* A = context->Input<Tensor>(0);
const Tensor* B = context->Input<Tensor>(1);
@ -40,9 +38,6 @@ Status TransposeMatMul::Compute(OpKernelContext* context) const {
ORT_RETURN_IF_ERROR(helper.Compute(A->Shape(), B->Shape(), trans_a, trans_b));
Tensor* Y = context->Output(0, helper.OutputShape());
if (Y->DataType() != DataTypeImpl::GetType<float>()) {
ORT_NOT_IMPLEMENTED("TransposeMatMul CPU operator only supports float inputs.");
}
const size_t num_offsets = helper.OutputOffsets().size();
for (size_t i = 0; i < num_offsets; ++i) {

View file

@ -222,8 +222,8 @@ ExecutionFrame::ExecutionFrame(const std::vector<int>& feed_mlvalue_idxs, const
: nullptr;
buffers_[mem_patterns_->locations[i]] = BufferUniquePtr(buffer, alloc);
// comment out following line to see the size of activation
// printf("Allocated memory for activations, size: %zu\n", mem_patterns_->patterns[i].PeakSize());
// log size of activation. Keep it commented out for now to avoid log flooding.
// VLOGS(session_state_.Logger(), 1) << "Allocated memory for activations, size: " << mem_patterns_->patterns[i].PeakSize();
}
}
}
@ -343,8 +343,11 @@ Status ExecutionFrame::AllocateMLValueTensorPreAllocateBuffer(OrtValue& ort_valu
// be generous and use the buffer if it's large enough. log a warning though as it indicates a bad model
if (buffer_num_elements >= required_num_elements) {
// Todo: View Operator is reusing the buffer bigger than the required size. Disabling warming message for now.
//LOGS_DEFAULT(WARNING) << message;
// View Operator is reusing the buffer bigger than the required size.
// Disabling warning message for now. The op is in the process of being deprecated.
#ifndef ENABLE_TRAINING
LOGS(session_state_.Logger(), WARNING) << message;
#endif
} else {
return ORT_MAKE_STATUS(ONNXRUNTIME, FAIL, message);
}

View file

@ -275,9 +275,7 @@ static void RunTest_v8(const std::string test_name, int64_t batch_size, int64_t
Model model(test_name, false, DefaultLoggingManager().DefaultLogger());
auto& graph = model.MainGraph();
auto status = CreateSubgraph(graph, options, options.add_bad_shape ? failure_message : "");
if (!status.IsOK()) {
return;
}
ASSERT_STATUS_OK(status);
auto& proto = graph.ToGraphProto();
ScanOpTester test{8};