output.bufs[idx].size = output_tensor_size;
/** user needs to free this */
output.bufs[idx].addr = calloc (1, output_tensor_size);
+ if (output.bufs[idx].addr == NULL) {
+ logerr (TAG, "Unable to allocate output buffer\n");
+ break;
+ }
-#ifdef __FPGA__
- api_->fpga_memcpy (output_segment->getDmabuf (),
- segt->getOutputSegmentOffset (idx),
- output.bufs[idx].addr, output.bufs[idx].size);
-#else
auto func = std::bind (TrinityVision2::manipulateData, model, idx, false,
std::placeholders::_1, std::placeholders::_2,
std::placeholders::_3);
- int status =
- comm_.insertGenericBuffer (segt->getOutputSegment (idx)->getData () +
- segt->getOutputSegmentOffset (idx),
- &output.bufs[idx], func);
-
+ void *dst;
+#ifdef __FPGA__
+ /* this is fpga workaround codes for syncing output data */
+ dst = calloc (1, output_tensor_size);
+ if (dst == NULL) {
+ logerr (TAG, "Unable to allocate FPGA temp buffer\n");
+ break;
+ }
+ api_->fpga_memcpy (output_segment->getDmabuf (),
+ segt->getOutputSegmentOffset (idx), dst,
+ output_tensor_size);
+#else
+ dst = output_segment->getData () + segt->getOutputSegmentOffset (idx);
+#endif
+ int status = comm_.insertGenericBuffer (dst, &output.bufs[idx], func);
if (status != 0) {
logerr (TAG, "Failed to return output buffer: %d\n", status);
}
+#ifdef __FPGA__
+ free (dst);
#endif
}
}
need_model_ = need_model;
verify_ = verify;
+ trinity_format_ = false;
mute_ = false;
sync_ = false;
dump_ = false;
std::cerr << " -d <arg> \t Set a device node path (e.g., /dev/triv2-0)\n";
std::cerr << " -n <arg> \t Set output notimode [intr|polling]\n";
std::cerr << " -p <arg> \t Set profile level [visa|layer]\n";
+ std::cerr << " -t \t\t Enable trinity data format\n";
std::cerr << " -m \t\t Mute stdout/stderr messages\n";
std::cerr << " -s \t\t Enable run sync mode\n";
std::cerr << " -o \t\t Enable output dump mode\n";
optind = 0;
opterr = 0;
- while ((c = getopt (argc, argv, "d:n:p:msho")) != -1) {
+ while ((c = getopt (argc, argv, "d:n:p:tmsho")) != -1) {
switch (c) {
case 'd':
setNodePath (optarg);
case 'p':
setProfLevel (optarg);
break;
+ case 't':
+ setTrinityFormat ();
+ break;
case 'm':
setMute ();
break;
*/
info_in.num_info = meta->input_seg_num;
for (uint32_t idx = 0; idx < info_in.num_info; idx++) {
- info_in.info[idx].layout = DATA_LAYOUT_NHWC;
+ if (trinity_format_)
+ info_in.info[idx].layout = DATA_LAYOUT_TRIV2;
+ else
+ info_in.info[idx].layout = DATA_LAYOUT_NHWC;
info_in.info[idx].type = DATA_TYPE_QASYMM8;
}
info_out.num_info = meta->output_seg_num;
for (uint32_t idx = 0; idx < info_out.num_info; idx++) {
- info_out.info[idx].layout = DATA_LAYOUT_NHWC;
+ if (trinity_format_)
+ info_out.info[idx].layout = DATA_LAYOUT_TRIV2;
+ else
+ info_out.info[idx].layout = DATA_LAYOUT_NHWC;
info_out.info[idx].type = DATA_TYPE_QASYMM8;
}
npudev_h getDeviceHandle () { return dev_; }
static void setDump () { dump_ = true; }
+ void setTrinityFormat () { trinity_format_ = true; }
void setSync () { sync_ = true; }
void setMute ();
void setNotiMode (const std::string mode);
npu_notimode noti_mode_;
profile_level_type prof_level_;
bool need_model_;
-
+ bool trinity_format_;
bool mute_;
bool sync_;
bool verify_;