You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

specsuse.js 1.5 kB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
12345678910111213141516171819202122232425262728293031
  1. window.ACC_CARD_TYPE = [{ k: 'T4', v: 'T4' }, { k: 'A100', v: 'A100' }, { k: 'V100', v: 'V100' }, { k: 'ASCEND910', v: 'Ascend 910' }, { k: 'MLU270', v: 'MLU270' }, { k: 'RTX3080', v: 'RTX3080' }];
  2. window.getListValueWithKey = (list, key, k = 'k', v = 'v', defaultV = '') => {
  3. for (let i = 0, iLen = list.length; i < iLen; i++) {
  4. const listI = list[i];
  5. if (listI[k] === key) return listI[v];
  6. }
  7. return defaultV;
  8. };
  9. window.renderSpecStr = (spec, showPoint, langObj) => {
  10. showPoint = false;
  11. var ngpu = `${spec.ComputeResource}: ${spec.AccCardsNum + '*' + getListValueWithKey(ACC_CARD_TYPE, spec.AccCardType)}`;
  12. var gpuMemStr = spec.GPUMemGiB != 0 ? `${langObj.gpu_memory}: ${spec.GPUMemGiB}GB, ` : '';
  13. var sharedMemStr = spec.ShareMemGiB != 0 ? `, ${langObj.shared_memory}: ${spec.ShareMemGiB}GB` : '';
  14. var pointStr = showPoint ? `, ${spec.UnitPrice == 0 ? langObj.free : spec.UnitPrice + langObj.point_hr}` : '';
  15. var specStr = `${ngpu}, CPU: ${spec.CpuCores}, ${gpuMemStr}${langObj.memory}: ${spec.MemGiB}GB${sharedMemStr}${pointStr}`;
  16. return specStr;
  17. };
  18. window.renderSpecsSelect = (specsSel, data, showPoint, langObj) => {
  19. specsSel.empty();
  20. data = data || [];
  21. var oValue = specsSel.attr('ovalue');
  22. for (var i = 0, iLen = data.length; i < iLen; i++) {
  23. var spec = data[i];
  24. var specStr = window.renderSpecStr(spec, showPoint, langObj);
  25. specsSel.append(`<option name="spec_id" value="${spec.ID}" queueCode="${spec.QueueCode}">${specStr}</option>`);
  26. }
  27. oValue && specsSel.val(oValue);
  28. }