Skip to content

PR to add accuracy verification to auto_scheduler#21

Open
islavutin wants to merge 2 commits intomainfrom
auto_scheduler_accuracy
Open

PR to add accuracy verification to auto_scheduler#21
islavutin wants to merge 2 commits intomainfrom
auto_scheduler_accuracy

Conversation

@islavutin
Copy link

@apeskov , @elvin-n - guys, would you please review and provide your feedback

3rdparty/dmlc-core/src/io/line_split.cc
3rdparty/dmlc-core/src/io/local_filesys.cc
3rdparty/dmlc-core/src/io/recordio_split.cc
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you please point which function requires compilation of this set of files?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.



virtual Array<tvm::runtime::NDArray> GetOutput(const Array<MeasureInput>& inputs,
const Array<BuildResult>& build_results, int verbose) = 0;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation string is required.
GetXXX sounds like a getter, but suppose it's one more version of method Run with reported outputs.

LayoutRewriteOption layout_rewrite_option;
/*! \brief Names of some user defined input data used in program measuring. */
Array<String> task_input_names;
/*! \brief keeping custom seed to reproduce randomly generated input values */
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments should start from capital letter.


void SetReferenceTensors(Array<tvm::runtime::NDArray> arr);

void SetTarget(Target target, Target target_host);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need these setters? All this fields are public.

/*! \brief Names of some user defined input data used in program measuring. */
Array<String> task_input_names;
/*! \brief keeping custom seed to reproduce randomly generated input values */
int custom_seed;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I still wondering about random generator behaviour on different platforms. I guess different std library may produce different random arrays with same seed. I don't think that using seed is acceptable in that case.


#faked ref to extract task
#TODO: without it, initial serialization crashes... how to solve it more elegantly?
ref = [tvm.nd.empty((1, 1))]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very suspicious comment. Looks like constructor of SearchTask object with default arguments produces invalid object. I guess it should be clarified and improved.

Looks like None value in field of type Array<NDArray> leads to wrong searialization.

original_target_host = task.target_host

ref_target = tvm.target.Target("llvm", host="llvm")
_ffi_api.SetTarget(task, ref_target, None)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rewriting targets field of original task is not elegant solution. Is it possible to make a copy of search task object with ref_taget?


results = local_runner.get_ouput(measure_inputs, build_results)

_ffi_api.SetReferenceTensors(task, results)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using of function _ffi_api.SetReferenceTensors is a workaround. I'm personally sure that ffi infrastructure allow to set and get values of native object without special setting methods.

from . import _ffi_api


import tvm
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where do you use tvm module in this file? Do you really need it? I guess from tvm.target import Target will be better.

TVM_REGISTER_GLOBAL("tvm.contrib.random.random_fill").set_body([](TVMArgs args, TVMRetValue* ret) {
RandomThreadLocalEntry* entry = RandomThreadLocalEntry::ThreadLocal();
DLTensor* out = args[0];
int seed = args[1];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a lot of usage random_fill function with only one argument. By this you changed semantic and now all of them will crash. Please make it optional.

i.Save(fs);
}

delete fs;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using of external tmp file for serialisation is not nice. It may confuse some one (including me). Moreover it cannot be easily enhanced to RPC case.

First option is to use direct serialisation into json.

example:

  std::string bytes;
  runtime::NDArray arr = data.ref_output_tensors[0];
  dmlc::MemoryStringStream stream(&bytes);
  ci.Save(&stream);
  writer->WriteArrayItem(bytes);

It has a critical issue, because "bytes" array may contain special chars like ", \t, \n and other. Alternative way to keep it as hex.

Second option is to change the place where we keep "ref_output_tensors". I'm not sure that "SearchTask" object is the best choice.

error_msg = make_traceback_info()

shutil.rmtree(os.path.dirname(build_res.filename))
toc = time.time()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toc unused


shutil.rmtree(os.path.dirname(build_res.filename))
toc = time.time()
time.sleep(cooldown_interval)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no loop for which we would do this cooldown

number,
repeat,
min_repeat_ms,
cooldown_interval,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cooldown_interval is not seen as necessary.
it might make sense to use(cooldown_interval_ms, limit_zero_time_iteration, repeats_to_cooldown) for func.time_evaluator

loc_args = []

# pylint: disable=consider-using-enumerate
for idx in range(len(args)):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for idx, arg in enumerate(args): will simplify the code a little bit

dev.sync()
costs = time_f(*loc_args).results

idx = len(loc_args) - 1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idx is unused

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants